27 lines
753 B
C#
27 lines
753 B
C#
using DoomDeathmatch.Component.MVC.Enemy;
|
|
using DoomDeathmatch.Component.MVC.Health;
|
|
|
|
namespace DoomDeathmatch.Script.Model.Enemy.Attack;
|
|
|
|
public class CloseContinuousAttackBehavior(
|
|
EnemyController parEnemyController,
|
|
HealthController parHealthController,
|
|
float parRadius,
|
|
float parDamage)
|
|
: AttackBehavior(parEnemyController, parHealthController)
|
|
{
|
|
public override bool Attack(double parDeltaTime)
|
|
{
|
|
var distanceSquared =
|
|
(_enemyController.GameObject.Transform.Translation - _healthController.GameObject.Transform.Translation)
|
|
.LengthSquared;
|
|
|
|
if (distanceSquared <= parRadius * parRadius)
|
|
{
|
|
_healthController.TakeDamage(parDamage * (float)parDeltaTime);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |