示例#1
0
 public void FlagSquare(int row, int col)
 {
     if (gameOver)
     {
         return;
     }
     if (!board[row, col].IsFlagged && !board[row, col].IsRevealed)
     {
         board[row, col].IsFlagged = true;
         SquareFlagged.Raise(this, new SquareEventArgs(row, col));
         flaggedSquares++;
         if (board[row, col].IsMine)
         {
             correctlyFlaggedMines++;
         }
         if (CheckGameWon())
         {
             OnGameWon();
         }
     }
     else if (board[row, col].IsFlagged)
     {
         UnflagSquare(row, col);
     }
 }
示例#2
0
 public void RecreateBoard()
 {
     for (int i = 0; i < rows; i++)
     {
         for (int j = 0; j < columns; j++)
         {
             if (board[i, j].IsFlagged)
             {
                 SquareFlagged.Raise(this, new SquareEventArgs(i, j));
             }
             else if (board[i, j].IsRevealed && !board[i, j].IsMine)
             {
                 SafeSquareRevealed.Raise(this, new SquareEventArgs(i, j, board[i, j].AdjacentMines));
             }
             else if (board[i, j].IsRevealed)
             {
                 MineRevealed.Raise(this, new SquareEventArgs(i, j));
             }
         }
     }
 }