public CommandSelectFSM(PlayerBattleController controller) { data.commandStack = new Stack <EventSelectionPanel>(); data.playerController = controller; data.battleManager = BattleManager.instance; data.battleHUD = BattleManager.BattleHUD; typeToState.Add(CommandPhase.WaitingForInput, new WaitingForInputCommandState(data)); typeToState.Add(CommandPhase.SelectingCommand, new SelectingCommandState(data)); typeToState.Add(CommandPhase.SelectingTarget, new SelectingTargetCommandState(data)); currentState = CommandPhase.WaitingForInput; currentStateImplementation = typeToState[currentState]; }
public void UpdateState(LinkedList <UIActionType> uiInputQueue) { var input = uiInputQueue.First; while (input != null) { var nextState = currentStateImplementation.OnUpdate(input); if (nextState != currentState) { currentStateImplementation = typeToState[nextState]; currentStateImplementation.OnEnter(); currentState = nextState; return; } input = input.Next; } }