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); }
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); }
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); }