.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user