Ejemplo n.º 1
0
        public static MinnerBoard Create(int _maxX, int _maxY, int _minesNbr)
        {
            if (_maxX == 0 || _maxY == 0 || _minesNbr > _maxX * _maxY)
                throw new ArgumentException();

            var rr = new MinnerBoard();
            //Init the game board
            rr.Board = new List<Field>();
            //Generate the board
            for (int x = 0; x < _maxX; x++)
                for (int y = 0; y < _maxY; y++)
                    rr.Board.Add(new Field(x, y));

           
            rr.MineBoard(_minesNbr);
            rr.SetNumberOfAdjacentMinnedField();   

            return rr;
        }
Ejemplo n.º 2
0
 public void InitNewGame()
 {
     Thread.Sleep(3000);     
     _model = MinnerBoard.Create(Size, Size, (int)(((float)MinesPercentage / 100.0) * Size * Size));
     _plates = new ObservableCollection<ModelViewField>(_model.Board.Select(x => new ModelViewField(x)));
     
     DispatcherHelper.CheckBeginInvokeOnUI(              
        () =>   RaisePropertyChanged(nameof(Plates)));                         
     StartGame();
    
 }