Beispiel #1
0
 private void FillWithCommands(List <ICommand> commands)
 {
     for (int i = 0; i < commands.Count; i++)
     {
         commandManager.AddToQueue(commands[i]);
     }
 }
Beispiel #2
0
    void Start()
    {
        commandManager = new CommandsManager(CommandsManager.UpdateMethod.EVENT_DRIVEN);

        var commands = new List <ICommand>();

        commands.Add(new CorutineCommand("A", 1f, this, "Context 1", "Context 2", "Context 3"));
        commands.Add(new CorutineCommand("B", 1f, this, "Context 1", "Context 2", "Context 3"));
        commands.Add(new CorutineCommand("C", 1f, this, "Context 1", "Context 3"));
        commands.Add(new CorutineCommand("D", 1f, this, "Context 1", "Context 3"));
        commands.Add(new CorutineCommand("E", 1f, this, "Context 2"));
        commands.Add(new CorutineCommand("F", 1f, this, "Context 2"));
        commands.Add(new CorutineCommand("G", 1f, this, "Context 2", "Context 3"));
        commands.Add(new CorutineCommand("H", 1f, this, "Context 2"));
        commands.Add(new CorutineCommand("I", 1f, this, "Context 3"));
        commands.Add(new CorutineCommand("J", 1f, this, "Context 3"));

        var changeUpdateModeEvent  = new ChangeUpdateModeCommand("Change to UpdateMethod.EVENT_DRIVEN", CommandsManager.UpdateMethod.EVENT_DRIVEN, commandManager, "Context 1", "Context 2", "Context 3");
        var changeUpdateModeManual = new ChangeUpdateModeCommand("Change to UpdateMethod.MANUAL", CommandsManager.UpdateMethod.MANUAL, commandManager, "Context 1", "Context 2", "Context 3");

        var contexts = new List <IContext>();

        contexts.Add(new BaseContext("Context 1"));
        contexts.Add(new BaseContext("Context 2"));
        contexts.Add(new BaseContext("Context 3"));

        Action StartManualUpdate = () =>
        {
            FillWithCommands(commands);
            commandManager.AddToQueue(changeUpdateModeEvent);
        };

        Action StartEventUpdate = () =>
        {
            FillWithCommands(commands);
            commandManager.AddToQueue(changeUpdateModeManual);
        };

        changeUpdateModeEvent.OnExecutionComplete  += (c) => StartEventUpdate();
        changeUpdateModeManual.OnExecutionComplete += (c) => StartManualUpdate();

        StartEventUpdate();
        FillWithContexts(contexts);
    }