private void PerformUndo() { if (m_undoStack.IsEmpty()) { // nothing to do return; } m_redoStack.Push(m_code); m_code = m_undoStack.Pop(); PerformUndoRedo(m_code); }
public void UndoMove() { if (!GameManager.Instance.Waiting) { StartCoroutine(GameManager.Instance.StartWaiting(0.1f)); _moves.Pop().Rollback(); GameManager.Instance.UpdateMove(); } }
public void Redo() { _isChanging = true; IUndoRedoItem item = _redoStack.Pop(); if (item != null) { item.Redo(); _undoStack.Push(item); } _isChanging = false; }
public void DropoutTest() { var stack = new DropOutStack <string>(3); Assert.IsNull(stack.Pop()); stack.Push("A"); stack.Push("B"); stack.Push("C"); Assert.AreEqual("C", stack.Pop()); Assert.AreEqual("B", stack.Pop()); Assert.AreEqual("A", stack.Pop()); Assert.IsNull(stack.Pop()); stack.Push("A"); stack.Push("B"); stack.Push("C"); Assert.AreEqual("C", stack.Pop()); Assert.AreEqual("B", stack.Pop()); Assert.AreEqual("A", stack.Pop()); Assert.IsNull(stack.Pop()); }
public void Back() { BoardState state = history.Pop(); if (state == null) { return; } foreach (TileState tile in state.tiles) { if (tile.Points == -1) { tilePositions[new BoardPos(tile.grid.X, tile.grid.Y)].setEmpty(emptyTileColor); } else { TileStyle style = getStyle(tile.Points); tilePositions[new BoardPos(tile.grid.X, tile.grid.Y)].setTile(tile.Points, style.Color, style.SecondaryTextColour ? secondaryTextColour : primaryTextColour, movementSpeed, false); } } if (isEndOfGame()) { SaveSystem.RemoveBoard(boardSize.X, boardSize.Y); SaveSystem.SaveScore(score, boardSize.X, boardSize.Y); if (GameOver != null) { GameOver.gameObject.SetActive(true); } } else { SaveSystem.SaveBoard(BuildSaveState()); if (GameOver != null) { GameOver.gameObject.SetActive(false); } } }