Esempio n. 1
0
        public void Open(int row, int col)
        {
            var tile = _tile[row, col];

            if (tile.Status == Flagged)
            {
                SetCursorPosition(0, 1);
                Write("Zone is flagged.        ");
                return;
            }
            if (tile.Mine)
            {
                Game.EndGame();
                ForegroundColor = System.ConsoleColor.Red;
                SetCursorPosition(0, 3);
                for (int r = 0; r < rows; r++)
                {
                    for (int c = 0; c < cols; c++)
                    {
                        if (_tile[r, c].Mine)
                        {
                            Write("  X  ");
                        }
                        else
                        {
                            SetCursorPosition(c * 5 + 5, r + 3);
                        }
                    }
                    WriteLine();
                }
                ResetColor();
                return;
            }
            var count = NumberOfSurroundingMines(row, col);

            SetCursorPosition(col * 5 + 1, row + 3);
            _tile[row, col].Open(count);
            if (count == 0)
            {
                OpenEmpty(row, col);
            }
        }
Esempio n. 2
0
 private void EndGame()
 {
     game.EndGame();
     RemoveTappedListeners();
     outputTextBlock.Text = "You lose :(";
 }