Exemplo n.º 1
0
 public MineField(int columns, int rows, int numberOfMines)
 {
     Columns    = columns;
     Rows       = rows;
     GameState  = GameState.NotStarted;
     _mineCells = new MineCell[columns, rows];
     MakeActionWithField((x, y) => _mineCells[x, y] = new MineCell());
     _numberOfMines = numberOfMines;
     _gameWatch     = new Stopwatch();
     _cellsToOpen   = Columns * Rows - _numberOfMines;
     FieldSettings  = new FieldSettings(columns, rows, numberOfMines);
 }
Exemplo n.º 2
0
        public void FillField(int firstColumn, int firstRow)
        {
            var numberOfMines = _numberOfMines;
            var random        = new Random();

            while (numberOfMines > 0)
            {
                var column = random.Next(Columns);
                var row    = random.Next(Rows);
                if (_mineCells[column, row].HasMine || column == firstColumn && row == firstRow)
                {
                    continue;
                }
                _mineCells[column, row] = new MineCell(true, false, false);
                numberOfMines--;
            }
        }