Esempio n. 1
0
        public Mine(int width, int height, int numExplosions, int numUndos)
        {
            Width           = width;
            Height          = height;
            MineBoard       = new MineSpace[Height, Width];
            CurrentPosition = new [, ] {
                { 0, 0 }
            };                                  // Start at the top left of the board, just because that seems natural I guess.
            States = new Stack <IMineMemento>();
            CreateMindBoard();
            GameState = GameState.InProgress;

            var topLeftPosition = new[, ] {
                { MineBoard[0, 0].YPosition, MineBoard[0, 0].XPosition }
            };

            ExplosionsRemainingManager = new ExplosionsRemainingManager(numExplosions, topLeftPosition);

            var boardMiddleXPosition = MineBoard[0, Width / 2].XPosition;

            WinLoseMessageManager = new WinLoseMessageManager(topLeftPosition[0, 0], boardMiddleXPosition);

            var topRightPosision = new[, ] {
                { MineBoard[0, 0].YPosition, MineBoard[0, Width - 1].XPosition }
            };

            UndosRemainingManager = new UndosRemainingManager(numUndos, topRightPosision);
        }
Esempio n. 2
0
        public void UndoExplode()
        {
            if (States.Count < 2 || !UndosRemainingManager.UndosRemain())
            {
                return;
            }

            States.Pop();
            var lastState = States.Peek();

            SetMemento(lastState);
            UndosRemainingManager.ReduceUndosRemaining();
            ExplosionsRemainingManager.IncreaseExplosionsRemaining();
        }