Inheritance: Entity
Esempio n. 1
0
 public override void EnemyCollision(Enemy enemy)
 {
     if(!triggered) {
         triggered = true;
         enemy.Immobilize();
         target = enemy;
     }
 }
Esempio n. 2
0
 public static Direction findPath(Map map, Vector2 pos, Enemy c)
 {
     if (c.Wait > 0)
     {
         c.Wait--;
         return Direction.still;
     }
     Vector2 target = getTarget(map, pos, c.Facing);
     if (target.X != -1)
     {
         int x = pos.X / Game.TILE_WIDTH + 1;
         int y = pos.Y / Game.TILE_HEIGHT + 1;
         return findPath(map, new Point(x, y), target);
     }
     // no sound source
     Random rg = new Random();
     double r = rg.NextDouble();
     if (r < 0.006)
     {
         c.Wait = 20;
         switch (c.Facing)
         {
             case 5:
                 return Direction.left;
             case 1:
                 return Direction.right;
             case 3:
                 return Direction.down;
             case 7:
                 return Direction.up;
         }
     }
     else if (r < 0.012)
     {
         c.Wait = 20;
         switch (c.Facing)
         {
             case 5:
                 return Direction.right;
             case 1:
                 return Direction.left;
             case 3:
                 return Direction.up;
             case 7:
                 return Direction.down;
         }
     }
     else
     {
         switch (c.Facing)
         {
             case 5:
                 return Direction.up;
             case 1:
                 return Direction.down;
             case 3:
                 return Direction.left;
             case 7:
                 return Direction.right;
         }
     }
     return Direction.still;
 }