Beispiel #1
0
        public void GetOutOfCollision()
        {
            Point gp = GetGridPosition();

            for (int x = 0; x < tiles.Length; x++)
            {
                for (int y = 0; y < tiles[x].Length; y++)
                {
                    if (!Level.IsWithinLevelBounds(gp.X + x, gp.Y + y))
                    {
                        while (GetGridPosition().X + x >= Level.gridWidth)
                        {
                            HardMove(-1, 0);
                        }
                        while (GetGridPosition().X + x < 0)
                        {
                            HardMove(1, 0);
                        }
                    }
                }
            }

            while (CheckLevelForCollisions(0, 0))
            {
                HardMove(0, -1);
            }
        }
Beispiel #2
0
 public bool CheckLevelForCollisions(int xDir, int yDir)
 {
     for (int x = 0; x < tiles.Length; x++)
     {
         for (int y = 0; y < tiles[x].Length; y++)
         {
             if (tiles[x][y] != null)
             {
                 if (Level.Collision(tiles[x][y].GetGridPosition().X + xDir, tiles[x][y].GetGridPosition().Y + yDir))
                 {
                     return(true);
                 }
                 else if (Level.BottomCollision(tiles[x][y].GetGridPosition().X + xDir, tiles[x][y].GetGridPosition().Y + yDir))
                 {
                     return(true);
                 }
                 else if (!Level.IsWithinLevelBounds(tiles[x][y].GetGridPosition().X + xDir, tiles[x][y].GetGridPosition().Y + yDir))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }