예제 #1
0
파일: Player.cs 프로젝트: khrpnv/LodeRunner
 public static void Update(int i, int j, int x, int y, GameCell[,] gameField, PictureBox[,] pictureField, GameCell p1, GameCell p2, Panel MainPanel)
 {
     pictureField[i, j].Image         = new Bitmap(gameField[i, j].Image);
     pictureField[i + y, j + x].Image = new Bitmap(gameField[i + y, j + x].Image);
     if (GetClick() != 0 && p1.Type == "Player" || GetClick() != 0 && p2.Type == "Player")
     {
         GameField.IncreaseRecover();
     }
     if (GameField.GetRecover() == 7)
     {
         Destructed.ReviveCell(gameField);
         List <int> coords = GetCoords();
         for (int k = 0; k < coords.Count; k += 2)
         {
             gameField[coords[k], coords[k + 1]] = new Ground();
             Update(coords[k], coords[k + 1], 0, 0, gameField, pictureField, new FreeArea(), new Ground(), MainPanel);
         }
     }
 }
예제 #2
0
 public static void SimpleMovement(GameCell[,] gameField, PictureBox[,] pictureField, string type, Panel MainPanel)
 {
     while (ThreadFlag)
     {
         int[] enemyCoords  = FindPosition(gameField, "BlindEnemy");
         int[] playerCoords = FindPosition(gameField, "Player");
         if (gameField[enemyCoords[0], enemyCoords[1] + 1].Type == "Ground" &&
             gameField[enemyCoords[0], enemyCoords[1] - 1].Type == "Ground")
         {
             return;
         }
         if (gameField[enemyCoords[0], enemyCoords[1] - 1].Type == "RopeTrap")
         {
             Die(gameField, pictureField, enemyCoords[0], enemyCoords[1], -1, MainPanel);
             return;
         }
         if (gameField[enemyCoords[0], enemyCoords[1] + 1].Type == "RopeTrap")
         {
             Die(gameField, pictureField, enemyCoords[0], enemyCoords[1], 1, MainPanel);
             return;
         }
         if (gameField[enemyCoords[0] + 1, enemyCoords[1]].Type == "Destructed")
         {
             SkipElements(gameField, pictureField, enemyCoords[0], enemyCoords[1], 0, 1, MainPanel);
             _prevBlindEnemy = new FreeArea();
             continue;
         }
         if (GameField.GetRecover() < 6 && gameField[enemyCoords[0], enemyCoords[1] + 1].Type == "Ground" && gameField[enemyCoords[0], enemyCoords[1] - 1].Type == "Ground")
         {
             Thread.Sleep(300);
             if (enemyCoords[1] > playerCoords[1])
             {
                 SkipElements(gameField, pictureField, enemyCoords[0], enemyCoords[1], 1, -1, MainPanel);
             }
             else
             {
                 SkipElements(gameField, pictureField, enemyCoords[0], enemyCoords[1], -1, -1, MainPanel);
             }
             continue;
         }
         if (enemyCoords[0] != playerCoords[0])
         {
             SimpleMovement(gameField, pictureField, "BlindEnemy", Func, MainPanel);
             Thread.Sleep(400);
         }
         else if (enemyCoords[0] == playerCoords[0] && enemyCoords[1] < playerCoords[1])
         {
             UsePlayersItems(gameField, pictureField, enemyCoords[0], enemyCoords[1], 1, MainPanel);
             SkipElements(gameField, pictureField, enemyCoords[0], enemyCoords[1], 1, 0, MainPanel);
             Thread.Sleep(200);
         }
         else if (enemyCoords[0] == playerCoords[0] && enemyCoords[1] > playerCoords[1])
         {
             UsePlayersItems(gameField, pictureField, enemyCoords[0], enemyCoords[1], 1, MainPanel);
             SkipElements(gameField, pictureField, enemyCoords[0], enemyCoords[1], -1, 0, MainPanel);
             Thread.Sleep(200);
         }
         if (FindPosition(gameField, "Player")[0] != 0)
         {
             continue;
         }
         Killed = true;
         break;
     }
 }