Example #1
0
        public void StartGame()
        {
            Game   game   = new Game();
            Person person = new Person();
            Trap   trap   = new Trap();
            Output output = new Output();

            bool firstСondition   = true;
            bool secondСondition  = true;
            int  numericСondition = 0;
            int  x  = 1;
            int  y  = 1;
            int  HP = person.HP;

            while (firstСondition)
            {
                output.GreetPlayer();
                game.CreateField();
                trap.MiningTheField();

                while (secondСondition)
                {
                    person.ToMovePlayer(ref x, ref y);
                    game.Field[y, x] = person.Player;

                    Console.Clear();

                    if (person.Player == trap.Traps[y, x])
                    {
                        game.Field[y, x] = trapSymbol;
                    }
                    game.Field[princessPositionOx, princessPositionOy] = princessSymbol;
                    Console.WriteLine("Твой HP: " + HP);

                    for (int i = 0; i < game.Rows; i++)
                    {
                        for (int j = 0; j < game.Columns; j++)
                        {
                            Console.Write($"{game.Field[i, j] }\t");
                        }
                        Console.WriteLine("\n");
                    }
                    if (game.Field[y, x] == game.Field[princessPositionOx, princessPositionOy])
                    {
                        game.WinCondition(ref firstСondition, ref secondСondition, ref numericСondition);
                    }
                    else if (person.Player == trap.Traps[y, x])
                    {
                        trap.Traps[y, x] = trapSymbol;
                        HP -= trap.Damage;
                        if (HP <= 0)
                        {
                            game.LoseCondition(ref firstСondition, ref secondСondition, ref numericСondition);
                        }
                    }
                    if (game.Field[y, x] != trapSymbol)
                    {
                        game.Field[y, x] = border;
                    }
                }
                game.RestartGame(ref firstСondition, ref secondСondition, ref numericСondition, ref x, ref y, ref HP);
            }
        }