Beispiel #1
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();
            }
        }