Beispiel #1
0
 public bool checkCollision(Vector2 location, Enemy enemy, Zone currentZone, int level)
 {
     for (int i = (int) location.Y; i < (int) (location.Y + enemy.getWalkingSize().Y); i++)
     {
         for (int j = (int) location.X; j < (int) (location.X + enemy.getWalkingSize().X); j++)
         {
             if (currentZone.getCollisionMap()[level].getCollisionMap()[i, j] == false || currentZone.getTrafficMap()[level].getTrafficMap()[i, j] == true || currentZone.getEnemyMap()[level].getTrafficMap()[i, j] == true)
             {
                 return false;
             }
         }
     }
     return true;
 }
Beispiel #2
0
 private void createEnemy(string type, Vector2 location, int facingDirection, int currentZoneLevel, Zone currentZone)
 {
     Console.WriteLine("creating enemy");
     spawnEnemiesLeft--;
     Enemy enemy;
     if (type == "Goblin")
     {
         enemy = new Goblin(location, facingDirection, currentZoneLevel);
         currentZone.getEnemies().Add(enemy);
         currentZone.getEnemyMap()[currentZoneLevel].insertEnemy(enemy);
     }
     else if (type == "Rabbit")
     {
         enemy = new Rabbit(location, facingDirection, currentZoneLevel);
         currentZone.getEnemies().Add(enemy);
         currentZone.getEnemyMap()[currentZoneLevel].insertEnemy(enemy);
     }
 }