public override void Attack(LocatableObject obj) { animationState = ShipAnimationState.None; path = null; SpaceShip ship = (SpaceShip)obj; for (int i = 0; i < speed; i++) { if (Math.Sqrt(Math.Pow(ship.Position.X - Position.X, 2) + Math.Pow(ship.Position.Y - Position.Y, 2)) <= visibility * 0.8) { fire(ship); break; } else { MoveTo(ship.Position); } } }
public void fire(SpaceShip ship) { ship.GetDamage(damage); animationState = ShipAnimationState.Attack; }