IEnumerator _RunProgram(Program program) { runningProgram = true; Command currentCommand = program.GetCommand(0); while (runningProgram && currentCommand != null) { currentCommand.connectedNode?.ActivateIcon(); currentCommand.Activate(); yield return(new WaitForSeconds(tickTime)); currentCommand.connectedNode?.ActivateIcon(false); Command nextCommand = currentCommand.GetNextCommand(); if (nextCommand == null) { break; } currentCommand = nextCommand; } runningProgram = false; currentRunningProgram = null; print("program done"); }
void Start() { bool lastCommandWasTurn = false; foreach (CommandSlot commandSlot in commandSlots) { if (lastCommandWasTurn) { Command newCommand = CommandPool.Inst.GetCommand <GoStraightCommand>(); newCommand.Activate(commandSlot); lastCommandWasTurn = false; } else { Command newCommand = CommandPool.Inst.GetRandomCommand(); newCommand.Activate(commandSlot); lastCommandWasTurn = (newCommand.GetType() != typeof(GoStraightCommand)); } } }
private void onBeatStarted(Signal signal) { if (!gameIsOver) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.BOARD_MOVE) { if (lastCommandWasTurn) { Command newCommand = CommandPool.Inst.GetCommand <GoStraightCommand>(); newCommand.Activate(this); lastCommandWasTurn = false; } else { Command newCommand = CommandPool.Inst.GetRandomCommand(); newCommand.Activate(this); lastCommandWasTurn = (newCommand.GetType() != typeof(GoStraightCommand)); } } } }