Example #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;
 }
Example #2
0
        public void insertEnemy(Enemy enemy)
        {
            Vector2 walkSize = enemy.getWalkingSize();
            Vector2 size = enemy.getSize();
            Vector2 location = enemy.getLocation();

            fillRectangle(true, (int) location.Y, (int) location.X, (int) walkSize.Y, (int) walkSize.X);
            for (int i = (int) location.Y - ((int) size.Y - (int) walkSize.Y); i < (int) location.Y + (int) size.Y; i++)
            {
                for (int j = (int) location.X; j < (int) location.X + (int) size.X; j++)
                {
                    insertEnemyAtLocation(enemy, i, j);
                }
            }
        }