third commit
This commit is contained in:
@@ -5,39 +5,30 @@ public partial class Enemy : StaticBody2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void TurnDoneEventHandler();
|
||||
public bool _toMove = false;
|
||||
public int _speed = 100, _reach = 200, _damage = 1, _health = 2;
|
||||
public int _damage = 1, _health = 2;
|
||||
public Vector2 _speed = Vector2.Up, _range = Vector2.Up;
|
||||
public float _movement = 0;
|
||||
public Player _player;
|
||||
public GridMap _grid;
|
||||
public GridMarker _gridMarker;
|
||||
public Commander _commander;
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
base._PhysicsProcess(delta);
|
||||
if (_toMove)
|
||||
{
|
||||
Vector2 moveVector = (_player.Position - Position) * (float)delta;
|
||||
if ((_movement += moveVector.Length()) <= _speed )
|
||||
{
|
||||
MoveAndCollide(moveVector);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_player.Position - Position).Length() <= _reach)
|
||||
{
|
||||
Attack(_player);
|
||||
}
|
||||
_toMove = false;
|
||||
_movement = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Attack(Player PLAYER)
|
||||
public void Attack(Commander COMMANDER)
|
||||
{
|
||||
PLAYER.TakeDamage(_damage, this);
|
||||
QueueFree();
|
||||
COMMANDER.TakeDamage(_damage, this);
|
||||
}
|
||||
|
||||
public void TakeDamage(int DAMAGE, Player ATTACKER)
|
||||
public void PlaceOrMove(GridMarker GRIDMARKER)
|
||||
{
|
||||
_gridMarker = GRIDMARKER;
|
||||
GlobalPosition = _gridMarker.GlobalPosition;
|
||||
}
|
||||
|
||||
public void TakeDamage(int DAMAGE, Commander ATTACKER)
|
||||
{
|
||||
_health -= DAMAGE;
|
||||
GD.Print($"Taking {DAMAGE}, Health is now {_health}");
|
||||
@@ -49,6 +40,6 @@ public partial class Enemy : StaticBody2D
|
||||
|
||||
public void TakeTurn()
|
||||
{
|
||||
_toMove = true;
|
||||
PlaceOrMove(_grid._gridMarkers[(int)(_gridMarker._address.Y + _speed.Y)][(int)(_gridMarker._address.X + _speed.X)]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user