Ejemplo n.º 1
0
        private static void ExplodeFive(char[,] field, Position2D minePosition)
        {
            int startRow = minePosition.X - 2;
            int endRow   = minePosition.X + 2;

            for (int row = startRow; row <= endRow; row++)
            {
                int startCol = minePosition.Y - 2;
                int endCol   = minePosition.Y + 2;
                for (int col = startCol; col <= endCol; col++)
                {
                    if (CheckField(field, row, col))
                    {
                        field[row, col] = 'X';
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void GameLoop()
        {
            int blownMines = 0;

            while (GameServices.ContainsMines(this.gameField))
            {
                GameServices.PrintResults(this.gameField);
                Position2D inputPosition = GetMoveInput();
                if (GameServices.IsValidMove(this.gameField, inputPosition.X, inputPosition.Y))
                {
                    GameServices.Explode(this.gameField, inputPosition);
                    blownMines++;
                }
                else
                {
                    Console.WriteLine("Invalid move!");
                }
            }

            EndGame(blownMines);
        }
Ejemplo n.º 3
0
        private static void ExplodeFour(char[,] field, Position2D minePosition)
        {
            int startRow = minePosition.X - 2;
            int endRow   = minePosition.X + 2;

            for (int row = startRow; row <= endRow; row++)
            {
                int startCol = minePosition.Y - 2;
                int endCol   = minePosition.Y + 2;
                for (int col = startCol; col <= endCol; col++)
                {
                    bool upRight   = (row == minePosition.X - 2) && (col == minePosition.Y - 2);
                    bool upLeft    = (row == minePosition.X - 2) && (col == minePosition.Y + 2);
                    bool downRight = (row == minePosition.X + 2) && (col == minePosition.Y - 2);
                    bool downLeft  = (row == minePosition.X + 2) && (col == minePosition.Y + 2);

                    if (upRight)
                    {
                        continue;
                    }
                    if (upLeft)
                    {
                        continue;
                    }
                    if (downRight)
                    {
                        continue;
                    }
                    if (downLeft)
                    {
                        continue;
                    }
                    if (CheckField(field, row, col))
                    {
                        field[row, col] = 'X';
                    }
                }
            }
        }