Example #1
0
        public Game(DifficultyGame difficulty)
        {
            switch (difficulty)
            {
            case DifficultyGame.Basic:
                NumberTilesInRow    = 10;
                NumberTilesInColumn = 10;
                NumberMines         = 12;
                break;

            case DifficultyGame.Intermediate:
                NumberTilesInRow    = 16;
                NumberTilesInColumn = 16;
                NumberMines         = 40;
                break;

            case DifficultyGame.Advanced:
                NumberTilesInRow    = 30;
                NumberTilesInColumn = 16;
                NumberMines         = 99;
                break;
            }
            minefield = new MineField(NumberTilesInRow, NumberTilesInColumn, NumberMines);
            manager   = new Manager();
            timer     = new Timer();
            Initialize();
        }
Example #2
0
 public Game(int NumberTilesInRow, int NumberTilesInColumn, int NumberMines)
 {
     this.NumberTilesInRow    = NumberTilesInRow;
     this.NumberTilesInColumn = NumberTilesInColumn;
     this.NumberMines         = NumberMines;
     minefield = new MineField(NumberTilesInRow, NumberTilesInColumn, NumberMines);
     manager   = new Manager();
     timer     = new Timer();
     Initialize();
 }
Example #3
0
 public Result StartNewGame(GameConfiguration configuration)
 {
     if (GameStatus == GameStatus.Active)
     {
         return(Result.Fail($"Can't start game. Status is {GameStatus}"));
     }
     minefield     = new MineField(configuration.Width, configuration.Height, configuration.NumberOfMines, _minefieldCreationStrategy);
     display       = new DisplayField(minefield);
     GameStatus    = GameStatus.Active;
     NumberOfMoves = 0;
     return(Result.Ok());
 }
 private void StartNewGame(FieldConfiguration config)
 {
     this.SuspendLayout();
     this.Controls.Remove(field);
     field = new MineField(config);
     this.field.Location                    = new System.Drawing.Point(0, menuStripMain.Height);
     this.field.Name                        = "field";
     this.field.Size                        = new System.Drawing.Size(152, 159);
     this.field.TabIndex                    = 0;
     this.field.NewGameStarted             += new System.EventHandler(this.OnNewGameStarted);
     this.field.RemainingBombsCountChanged += new System.EventHandler(this.OnBombsCountChanged);
     this.field.GameEnded                  += new EventHandler(OnGameEnded);
     this.field.DrawCells();
     this.Controls.Add(field);
     this.mineLabelBombsCount.Value    = config.MinesCount;
     this.mineLabelTime.Value          = 0;
     this.buttonSmileyFace.ParentField = field;
     NormalizeLayoutAndValues();
     this.ResumeLayout();
 }
Example #5
0
 /// <summary>
 /// Resets game-state data for a new game.
 /// </summary>
 /// <param name="width">The width of the new field</param>
 /// <param name="height">The height of the new field</param>
 /// <param name="mineCount">The number of mines in the new field</param>
 /// <param name="startX">The x coordinate of the starting point</param>
 /// <param name="startY">The y coordinate of the starting point</param>
 public static void StartNewGame(MineField field, int startX, int startY)
 {
     CurrentField = new MineField(field.Width, field.Height, field.MineCount, startX, startY);
     startTime    = DateTime.Now;
     timer.Start();
 }
 private void GameNew(MineField field)
 {
     StartNewGame(field.Width, field.Height, field.MineCount);
     newGame = (x, y) => App.StartNewGame(field, x, y);
 }