Exemplo n.º 1
0
        public void RedoTurn()
        {
            var lastTurn = _undoneTurns.Last();

            MineField.RestoreFromSnapshot(lastTurn.MineFieldSnapshot);
            AddTurn(lastTurn.MineFieldSnapshot, lastTurn.PlayerTurnSnapshot, lastTurn.Description, lastTurn.Time);
            _undoneTurns.RemoveAt(_undoneTurns.Count - 1);
        }
Exemplo n.º 2
0
        public void UndoTurn(int turnId)
        {
            var turn = _playerTurns[turnId];

            MineField.RestoreFromSnapshot(turn.MineFieldSnapshot);
            if (turn.GameState != GameStateManager.CurrentState)
            {
                GameStateManager.CurrentState = turn.GameState;
            }
            _undoneTurns.Add(turn);
            _playerTurns.RemoveAt(turnId);
        }
Exemplo n.º 3
0
        public static MineField CreateFromSnapshot(MineFieldSnapshot snapshot)
        {
            var mineField = new MineField(
                snapshot.Width,
                snapshot.Height,
                snapshot.TotalMines,
                snapshot.IsResolvable,
                snapshot.MinePutterDifficulty
                );

            mineField.RestoreFromSnapshot(snapshot);

            return(mineField);
        }
Exemplo n.º 4
0
        public MineFieldRenderer(MineField mineField, GraphicsDevice graphicsDevice, Texture2D tileSet)
        {
            MineField        = mineField;
            GraphicsDevice   = graphicsDevice;
            _tileSet         = tileSet;
            _textureResolver = new TextureResolver(tileSet, MineField.CellSize, MineField.CellSize);

            RenderTarget = new RenderTarget2D(
                GraphicsDevice,
                mineField.Width * mineField.CellSize,
                mineField.Height * mineField.CellSize,
                true,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24
                );

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            MineField.Changed += (sender, args) => Render();
        }
Exemplo n.º 5
0
 public PlayerTurnsContainer(MineField mineField, GameStateManager gameStateManager)
 {
     MineField        = mineField;
     GameStateManager = gameStateManager;
 }