Unity-Design-Pattern icon indicating copy to clipboard operation
Unity-Design-Pattern copied to clipboard

Behavioral Patterns ----Command Pattern-----Example3

Open pbsmart opened this issue 6 years ago • 2 comments

这个例子写的有Bug 一旦UnDo后 进行新的命令就就会出现Bug 原因是UnDo后 再进行Command 没有清除之前的Comand

pbsmart avatar Aug 29 '19 08:08 pbsmart

可以把添加命令代码改为

MoveCommand moveCommand = new MoveCommand(moveCommandReciever, direction, moveDistance, objectToMove);
        moveCommand.Execute();
        commands.Insert(currentCommandNum,moveCommand);
        currentCommandNum++;
        while (commands.Count>currentCommandNum)
        {
            commands.RemoveAt(commands.Count - 1);
        }

pbsmart avatar Aug 29 '19 08:08 pbsmart

大佬,快回来改bug了

lsjsoft avatar Dec 22 '21 01:12 lsjsoft