Exemplo n.º 1
0
        public bool DoRedo()
        {
            if (redoActions.Count == 0)
            {
                return(false);
            }

            //remove from redo list
            Action action = redoActions[redoActions.Count - 1];

            redoActions.RemoveAt(redoActions.Count - 1);

            //do redo
            action.DoRedo();
            ActionRedo?.Invoke(action);

            //add to undo list
            if (undoActions.Count + 1 >= maxLevel)
            {
                undoActions[0].Destroy();
                ActionDestroy?.Invoke(undoActions[0]);
                undoActions.RemoveAt(0);
            }
            undoActions.Add(action);

            ListOfActionsChanged?.Invoke(this, EventArgs.Empty);

            return(true);
        }
Exemplo n.º 2
0
        public void Clear()
        {
            bool existsData = undoActions.Count != 0 || redoActions.Count != 0;

            foreach (Action action in redoActions)
            {
                action.Destroy();
                ActionDestroy?.Invoke(action);
            }
            redoActions.Clear();

            foreach (Action action in undoActions)
            {
                action.Destroy();
                ActionDestroy?.Invoke(action);
            }
            undoActions.Clear();

            if (existsData)
            {
                ListOfActionsChanged?.Invoke(this, EventArgs.Empty);
            }

            WasCleaned?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 3
0
    public ActionDestroy Destroy(GameObject go)
    {
        var destroy = new ActionDestroy(go);

        Add(destroy);

        return(destroy);
    }
Exemplo n.º 4
0
        public void CommitAction(Action action)
        {
            foreach (Action a in redoActions)
            {
                a.Destroy();
                ActionDestroy?.Invoke(a);
            }
            redoActions.Clear();

            if (undoActions.Count + 1 >= maxLevel)
            {
                undoActions[0].Destroy();
                ActionDestroy?.Invoke(undoActions[0]);
                undoActions.RemoveAt(0);
            }

            undoActions.Add(action);

            ListOfActionsChanged?.Invoke(this, EventArgs.Empty);
        }