Esempio n. 1
0
        public List <UndoAction> RedoAction()
        {
            List <UndoAction> ret = new List <UndoAction>();

            if (redoStack.Count > 0)
            {
                UndoAction act = redoStack.Last.Value;
                redoStack.RemoveLast();
                undoStack.AddLast(act);
                ret.Add(act);

                if (act.UndoType == CombatManager.UndoAction.UndoTypes.UndoGroupStart)
                {
                    while (true)
                    {
                        if (redoStack.Count == 0)
                        {
                            break;
                        }
                        act = redoStack.Last.Value;
                        redoStack.RemoveLast();
                        undoStack.AddLast(act);
                        ret.Add(act);

                        if (act.UndoType == CombatManager.UndoAction.UndoTypes.UndoGroupEnd)
                        {
                            break;
                        }
                    }
                }
            }

            return(ret);
        }
Esempio n. 2
0
        public void AddToUndo(UndoAction act)
        {
            if (!IsOwned)
            {
                if (redoStack.Count > 0)
                {
                    tempRedoStack = redoStack;
                    redoStack     = new LinkedList <CombatManager.UndoAction>();
                }

                if (undoStack.Count == 0 ||
                    !undoStack.Last.Value.Equals(act))
                {
                    undoStack.AddLast(act);
                }

                while (undoStack.Count > 5000)
                {
                    undoStack.RemoveFirst();
                }
            }
        }