Ejemplo n.º 1
0
 public bool HitTest(Enemy enemy)
 {
     if (Life <= 0)
         return false;
     if (enemy.Life <= 0)
         return false;
     Point point = enemy.Point;
     const int halfSize = 17;
     return _point.X - halfSize < point.X && point.X < _point.X + halfSize
         && _point.Y - halfSize < point.Y && point.Y < _point.Y + halfSize;
 }
Ejemplo n.º 2
0
 private void RenderEnemy(Enemy enemy)
 {
     Tuple<string, int, int> resource = ToResource(enemy.Type);
     Point src;
     switch (enemy.Direction.Value)
     {
         case 5:
         case 8:
             src = new Point((short)resource.Item2, (short)(resource.Item3 * 3));
             break;
         case 7:
         case 4:
         case 1:
             src = new Point((short)resource.Item2, (short)resource.Item3);
             break;
         case 9:
         case 6:
         case 3:
             src = new Point((short)resource.Item2, (short)(resource.Item3 * 2));
             break;
         default:
             src = new Point((short)resource.Item2, 0);
             break;
     }
     if (_damagedEnemies.Contains(enemy))
     {
         Renderer.DrawClipWhite(
             resource.Item1,
             src,
             new Size((short)resource.Item2, (short)resource.Item3),
             GetUnitPoint(enemy.Point, resource.Item2, resource.Item3));
         _damagedEnemies.Remove(enemy);
     }
     else
     {
         Renderer.DrawClip(
             resource.Item1,
             src,
             new Size((short)resource.Item2, (short)resource.Item3),
             GetUnitPoint(enemy.Point, resource.Item2, resource.Item3));
     }
 }