Example #1
0
 public static GameCell[,] GenerateStartField(Panel MainPanel, int width, int height)
 {
     GameCell[,] gameField = new GameCell[height, width];
     picField = new PictureBox[height, width];
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < width; j++)
         {
             if (i == 0 || i == height - 1 || j == 0 || j == width - 1)
             {
                 gameField[i, j] = new Ground();
             }
             else if (i == 1 && j == 1)
             {
                 gameField[i, j] = new Cursor();
             }
             else
             {
                 gameField[i, j] = new FreeArea();
             }
             picField[i, j] = new PictureBox()
             {
                 Size     = new Size(30, 30),
                 SizeMode = PictureBoxSizeMode.StretchImage,
                 Location = new Point(j * 30, i * 30),
                 Image    = new Bitmap(gameField[i, j].Image)
             };
             MainPanel.Controls.Add(picField[i, j]);
         }
     }
     return(gameField);
 }
Example #2
0
 private static void DeleteElement(int i, int j, int deltay, int deltax, GameCell[,] gameField, Panel MainPanel, PictureBox[,] pictureField)
 {
     if (i + deltay == gameField.GetLength(0) - 1 || j + deltax == 0)
     {
         return;
     }
     gameField[i + deltay, j + deltax] = new FreeArea();
     gameField[i, j] = new Cursor();
     UpdateCreator(i, j, deltax, deltay, gameField, pictureField, new Cursor(), new FreeArea(), MainPanel);
 }
Example #3
0
 public static void FallDown(int i, int j, GameCell[,] gameField, GameCell p)
 {
     gameField[i + 1, j] = p;
     if (gameField[i + 1, j].Type == "Destructed")
     {
         gameField[i, j] = new Destructed();
     }
     else
     {
         gameField[i, j] = new FreeArea();
     }
 }
Example #4
0
        private static void Teleportation(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int delta, GameCell p, Panel MainPanel)
        {
            if (GameField.TeleportCoords.Count <= 1)
            {
                SkipSecondElements(gameField, pictureField, i, j, delta, 0, MainPanel);
                return;
            }
            gameField[i, j + delta] = new Teleport();
            gameField[i, j]         = new FreeArea();
            int[] curCoords = { i, j + delta };
            SecondUpdate(i, j, delta, 0, gameField, pictureField, new FreeArea(), new Teleport(), MainPanel);
            var nextCoords = ArrayIndexInList(GameField.TeleportCoords, curCoords[0], curCoords[1]) == GameField.TeleportCoords.Count - 1 ? GameField.TeleportCoords[0] : GameField.TeleportCoords[ArrayIndexInList(GameField.TeleportCoords, curCoords[0], curCoords[1]) + 1];

            gameField[nextCoords[0], nextCoords[1]] = p;
            gameField[curCoords[0], curCoords[1]]   = new Teleport();
            SecondUpdate(nextCoords[0], nextCoords[1], 0, 0, gameField, pictureField, new FreeArea(), p, MainPanel);
            _prevSecond = new Teleport();
        }
Example #5
0
 protected static void DieFromEnemy(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int delta, Panel MainPanel)
 {
     gameField[i, j + delta] = _prev;
     gameField[i, j]         = new FreeArea();
     Update(i, j, delta, 0, gameField, pictureField, new FreeArea(), _prev, MainPanel);
 }
Example #6
0
 protected static void MoveOnFreeArea(int i, int j, int y, int x, GameCell[,] gameField, GameCell p)
 {
     gameField[i + y, j + x] = p;
     gameField[i, j]         = new FreeArea();
 }
Example #7
0
 protected static void Die(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int delta, Panel MainPanel)
 {
     gameField[i, j + delta] = new RopeTrap();
     gameField[i, j]         = new FreeArea();
     Update(i, j, delta, 0, gameField, pictureField, new FreeArea(), new RopeTrap(), MainPanel);
 }