Esempio n. 1
0
    /// <summary>
    /// 执行移动操作
    /// </summary>
    /// <param name="move"></param>
    private void Move(ICommand move)
    {
        #region 将还原栈和相关UI清空

        var removeList = new List <int>();
        foreach (var item in commandImagesDic.Keys)
        {
            if (item > commandIndex.Value)
            {
                removeList.Add(item);
            }
        }
        foreach (var item in removeList)
        {
            Destroy(commandImagesDic[item].gameObject);
            commandImagesDic.Remove(item);
        }
        RedoStack.Clear();

        #endregion

        //将命令添加到撤销栈中
        UndoStack.Add(move);

        //执行命令
        move.excute();

        AddCommand();

        commandIndex.Value++;
    }