public static Board LoadState(GameState state) { Board newBoard = new Board(state.Rows, state.Columns) { board = state.Board, gameTime = state.GameTime }; for (int i = 0; i < state.Rows; i++) { for (int j = 0; j < state.Columns; j++) { if (newBoard.board[i, j].IsFlagged) { newBoard.flaggedSquares++; if (newBoard.board[i, j].IsMine) { newBoard.minesCount++; newBoard.correctlyFlaggedMines++; } } else if (newBoard.board[i, j].IsMine) { newBoard.minesCount++; } if (newBoard.board[i, j].IsMine && newBoard.board[i, j].IsRevealed) { newBoard.gameOver = true; } } } if (newBoard.CheckGameWon()) { newBoard.gameOver = true; } return(newBoard); }