private void Update() { IState myState = _sequence[currStateIndex]; myState.Tick(Time.deltaTime); StateOutput output = myState.GetStateOutput(); switch (output) { case StateOutput.Pass: { if (currStateIndex >= _sequence.Length - 1) { TriggerOnDetect(); } else { //Debug.Log("Pass!"); int i = currStateIndex + 1; GoToState(i); } } break; case StateOutput.Fail: { if (currStateIndex > 0) { GoToState(--currStateIndex); } else { myState.Reset(); } //Debug.Log("Sequence Fail", this); } break; case StateOutput.None: break; } }
public StateOutput GetState(string playerId) { var player = db.Get(playerId); StateOutput output = null; if (player == null) { output = new StateOutput { TotalQuestPercentCompleted = 0, LastMilestoneIndexCompleted = 0 }; } else { output = new StateOutput { TotalQuestPercentCompleted = player.TotalQuestPercentCompleted, LastMilestoneIndexCompleted = player.LastMilestoneIndex }; } return(output); }