public MineSweeperGame(int columns, int rows, int mines, bool bDoQuestioned, Func<MineSweeperGame,bool,bool> adrawer)
{
this.columns = columns;
this.rows = rows;
this.bDoQuestioned = bDoQuestioned;
drawer = adrawer;
tiles = new Tile[columns, rows];
for (int col = 0; col < columns; col++) {
for (int row = 0; row < rows; row++) {
tiles [col, row] = new Tile (col, row);
}
}
// Place the mines
int minesplaced = 0;
do {
Point p = RandomTile ();
int col = p.X;
int row = p.Y;
if (!tiles [col, row].isMine()) {
tiles [col, row].PlaceMine();
minesplaced++;
}
} while (minesplaced < 10);
// Calculate numbers for each tile
for (int col = 0; col < columns; col++) {
for (int row = 0; row < rows; row++) {
Tile tile = tiles [col, row];
if (!tile.isMine()) {
tile.Value = CalculateTileValue (tile);
}
}
}
// Reset score
currentScore = 0;
drawer (this, false);
}