コード例 #1
0
    //Called when we press a key
    public override void Execute(Transform boxTrans, Command command)
    {
        List<Command> oldCommands = InputHandler.oldCommands;

        if (oldCommands.Count > 0)
        {
            Command latestCommand = oldCommands[oldCommands.Count - 1];

            //Move the box with this command
            latestCommand.Undo(boxTrans);

            //Remove the command from the list
            oldCommands.RemoveAt(oldCommands.Count - 1);
        }
    }
コード例 #2
0
ファイル: CommandPattern.cs プロジェクト: vzru/INFR3110_A1
        public override void Execute(Command command, float value)
        {
            int size = CommandPattern.completedCommands.Count;

            if (size > 0)
            {
                Command currentCommand = CommandPattern.completedCommands[size - 1];

                currentCommand.Undo();

                CommandPattern.completedCommands.RemoveAt(size - 1);

                CommandPattern.undoneCommands.Add(currentCommand);
            }
        }