Exemplo n.º 1
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();
     }
 }
Exemplo n.º 2
0
        protected static void SimpleMovement(GameCell[,] gameField, PictureBox[,] pictureField, string type, Function func, Panel MainPanel)
        {
            int[] enemyCoords = FindPosition(gameField, type);
            int   k           = enemyCoords[0];
            int   f           = enemyCoords[1];

            if (k == 0 && f == 0)
            {
                return;
            }
            if (gameField[k, f - 1] is Ground)
            {
                _direction = 'r';
            }
            if (gameField[k, f + 1] is Ground)
            {
                _direction = 'l';
            }
            if (gameField[k, f - 1].Type == "RopeTrap")
            {
                Die(gameField, pictureField, k, f, -1, MainPanel);
                return;
            }
            if (gameField[k, f + 1].Type == "RopeTrap")
            {
                Die(gameField, pictureField, k, f, 1, MainPanel);
                return;
            }
            if (gameField[k, f + 1].Type == "Player")
            {
                func(gameField, pictureField, k, f, 1, 0, MainPanel);
                _prevEnemy = new FreeArea();
                return;
            }
            else if (gameField[k, f + 1].Type == "Player")
            {
                func(gameField, pictureField, k, f, 1, 0, MainPanel);
                _prevEnemy = new FreeArea();
                return;
            }
            if (_direction == 'r')
            {
                func(gameField, pictureField, k, f, 1, 0, MainPanel);
            }
            else
            {
                func(gameField, pictureField, k, f, -1, 0, MainPanel);
            }
        }
Exemplo n.º 3
0
 private static void AllOtherKeys(GameCell[,] gameField, int i, int j, GameCell elem, Panel MainPanel, PictureBox[,] pictureField)
 {
     if (j == gameField.GetLength(1) - 2 && i == gameField.GetLength(0) - 2)
     {
         CreateElement(i, j, -1, 0, gameField, elem, MainPanel, pictureField);
     }
     else if (j == gameField.GetLength(1) - 2)
     {
         CreateElement(i, j, 1, 0, gameField, elem, MainPanel, pictureField);
     }
     else
     {
         CreateElement(i, j, 0, 1, gameField, elem, MainPanel, pictureField);
     }
 }
Exemplo n.º 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();
        }
Exemplo n.º 5
0
 public static void SetSecondPrev()
 {
     _prevSecond = new FreeArea();
 }
Exemplo n.º 6
0
 private static void LeftRightArrowMovement(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int delta, Panel MainPanel)
 {
     if (j + delta == 0 || j + delta == gameField.GetLength(1) - 1)
     {
         return;
     }
     if (_counter > _boost * 7)
     {
         _boost--;
     }
     if (_activePill > _pill * 20)
     {
         _pill--;
     }
     if (_helmetCount > _helmet * 4)
     {
         _helmet--;
     }
     if (_boost > 0)
     {
         if (gameField[i, j + 2 * delta] is Ground)
         {
             return;
         }
         SkipElements(gameField, pictureField, i, j, 2 * delta, 0, new Player(), MainPanel);
         pictureField[i, j + 2 * delta].Image = new Bitmap("Data\\Icons\\player.png");
         gameField[i, j + 2 * delta]          = new Player();
         _counter++;
         return;
     }
     if (gameField[i, j + delta].Type == "SimpleEnemy" || i == 0)
     {
         DieFromEnemy(gameField, pictureField, i, j, delta, MainPanel);
     }
     if (gameField[i, j + 2 * delta].Type == "Door")
     {
         _doorSide = delta;
     }
     else if (gameField[i, j + delta].Type == "Teleport")
     {
         Teleportation(gameField, pictureField, i, j, delta, new Player(), MainPanel);
         return;
     }
     if (_helmet > 0)
     {
         _helmetCount++;
         if (DetectItems(gameField, pictureField, i, j, delta, MainPanel))
         {
             SkipElements(gameField, pictureField, i, j, delta, 0, new Player(), MainPanel);
             _prev = new FreeArea();
         }
         else
         {
             SkipElements(gameField, pictureField, i, j, delta, 0, new Player(), MainPanel);
         }
         Update(i, j, delta, 0, gameField, pictureField, _prev, new Player(), MainPanel);
         return;
     }
     if (gameField[i - 1, j].Type == "Ladder" && gameField[i, j + delta].Type != "Ground" || gameField[i + 1, j].Type == "Ladder" && gameField[i, j + delta].Type != "Ground")
     {
         MoveOnLadder(i, j, 0, delta, gameField, new Player());
         Update(i, j, delta, 0, gameField, pictureField, new Player(), new Ladder(), MainPanel);
     }
     else if (gameField[i, j + delta].Type != "Ground" && gameField[i, j + delta].Type != "StrongGround" && gameField[i, j + delta].Type != "Door" && gameField[i, j + delta].Type != "Unbreakable" && j + delta > 0)
     {
         if (DetectItems(gameField, pictureField, i, j, delta, MainPanel))
         {
             SkipElements(gameField, pictureField, i, j, delta, 0, new Player(), MainPanel);
             _prev = new FreeArea();
         }
         else
         {
             SkipElements(gameField, pictureField, i, j, delta, 0, new Player(), MainPanel);
         }
         Update(i, j, delta, 0, gameField, pictureField, _prev, new Player(), MainPanel);
     }
 }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
0
 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);
         }
     }
 }
Exemplo n.º 9
0
        protected static void RandomPrize(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, GameCell p, Panel MainPanel)
        {
            MoveOnFreeArea(i, j, y, x, gameField, p);
            Update(i, j, x, y, gameField, pictureField, new FreeArea(), p, MainPanel);
            var rnd   = new Random();
            int index = rnd.Next(1, 5);

            switch (index)
            {
            case 1:
                for (int k = 0; k < 5; k++)
                {
                    Gold.IncreaseCount(20);
                }
                break;

            case 2:
                Gold.SetGoldCount();
                break;

            case 3:
                MessageBox.Show("YOU LOOSE!");
                break;
            }
        }
Exemplo n.º 10
0
 public static void SetSimplePrev()
 {
     _prevEnemy = new FreeArea();
 }
Exemplo n.º 11
0
        public void GameProcess(LodeRunner GameForm, string name)
        {
            Panel MainPanel = new Panel()
            {
                Size      = new Size(1100, 650),
                Location  = new Point(20, 70),
                BackColor = Color.Blue
            };
            GameField GameField1 = new GameField();

            GameForm.Controls.Add(MainPanel);
            Player.AmountOfSteps = 0;
            Gold.SetGoldCount();
            GameField.TeleportCoords.Clear();
            Player.SetPrivateFields();
            SecondPlayer.SetSecondPrev();
            GameField1.GenerateField(MainPanel, name);
            Player.SetThreadFlag(true);
            GameCell[,] field = GameField1.curField;
            Gold.GetAmount(GameForm);
            GameForm.KeyUp += new KeyEventHandler(Key);
            void Key(object sender, KeyEventArgs e)
            {
                if (GameCell.FindPosition(field, "SecondPlayer")[0] != 0)
                {
                    SecondPlayer.MoveSecondHero(e, field, GameField1.curPics, MainPanel);
                    new Thread(() => Fall("SecondPlayer", new SecondPlayer())).Start();
                }
                if (_fallingDown == false)
                {
                    Player.MoveHero(e, field, GameField1.curPics, MainPanel);
                }
                Gold.GetAmount(GameForm);
                new Thread(() => Fall("Player", new Player())).Start();
                void Fall(string type, Player person)
                {
                    int[] coords = GameCell.FindPosition(field, type);
                    int   i      = coords[0];
                    int   j      = coords[1];

                    while (field[i + 1, j].Type == "FreeArea" || field[i + 1, j].Type == "Destructed" || field[i + 1, j].Type == "Gold")
                    {
                        _fallingDown = true;
                        Thread.Sleep(250);
                        Player.Falling(field, GameField1.curPics, i, j, person, MainPanel);
                        i++;
                    }
                    _fallingDown = false;
                }
            }

            if (GameCell.FindPosition(field, "SimpleEnemy")[0] != 0 && GameCell.FindPosition(field, "SimpleEnemy")[1] != 0)
            {
                SimpleEnemy.SetSimplePrev();
                new Thread(() => SimpleEnemy.ForThread(field, GameField1.curPics, MainPanel)).Start();
            }
            if (GameCell.FindPosition(field, "BlindEnemy")[0] != 0 && GameCell.FindPosition(field, "BlindEnemy")[1] != 0)
            {
                BlindEnemy.SetPrevBlind();
                new Thread(() => BlindEnemy.SimpleMovement(field, GameField1.curPics, "BlindEnemy", MainPanel)).Start();
            }
            if (GameCell.FindPosition(field, "Coin")[0] != 0 && GameCell.FindPosition(field, "Coin")[1] != 0)
            {
                Coin.SetPrevCoin();
                new Thread(() => Coin.ForThread(field, GameField1.curPics, MainPanel)).Start();
            }
        }
Exemplo n.º 12
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;
     }
 }
Exemplo n.º 13
0
 public static void SetPrevBlind()
 {
     _prevBlindEnemy = new FreeArea();
 }
Exemplo n.º 14
0
 private static void CreateElement(int i, int j, int y, int x, GameCell[,] gameField, GameCell elem, Panel MainPanel, PictureBox[,] pictureField)
 {
     SkipElementsCreator(gameField, pictureField, i, j, x, y, new Cursor(), MainPanel);
     gameField[i, j] = elem;
     UpdateCreator(i, j, x, y, gameField, pictureField, elem, new Cursor(), MainPanel);
 }
Exemplo n.º 15
0
 protected static void SkipElementsCreator(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, GameCell p, Panel MainPanel)
 {
     gameField[i, j] = _prev;
     UpdateCreator(i, j, x, y, gameField, pictureField, _prev, new Cursor(), MainPanel);
     _prev = gameField[i + y, j + x];
     gameField[i + y, j + x] = new Cursor();
 }
Exemplo n.º 16
0
 private static void SecondUpdate(int i, int j, int x, int y, GameCell[,] gameField, PictureBox[,] pictureField, GameCell p1, GameCell p2, Panel MainPanel)
 {
     pictureField[i, j].Image         = new Bitmap(p1.Image);
     pictureField[i + y, j + x].Image = new Bitmap(p2.Image);
 }
Exemplo n.º 17
0
 protected static void SkipElements(GameCell[,] gameField, PictureBox[,] pictureField, int i, int j, int x, int y, GameCell p, Panel MainPanel)
 {
     gameField[i, j] = _prev;
     Update(i, j, x, y, gameField, pictureField, p, _prev, MainPanel);
     _prev = gameField[i + y, j + x];
     gameField[i + y, j + x] = p;
 }
Exemplo n.º 18
0
 public static void SetPrevCoin()
 {
     _prevCoin = new FreeArea();
 }