private IEnumerator ExecuteSteps(TutorialStep.Id startingStep) { int startingStepIndex = GetStepIndexFromTutorialStepId(startingStep); for (int i = startingStepIndex; i < steps.Count; i++) { var stepPrefab = steps[i]; runningStep = Instantiate(stepPrefab).GetComponent <TutorialStep>(); currentTutorialStepId = runningStep.stepId; currentTutorialStepIndex = i; UserProfile.GetOwnUserProfile().SetTutorialStepId((int)currentTutorialStepId); runningStep.OnStepStart(); yield return(runningStep.OnStepExecute()); runningStep.OnStepFinished(); Destroy(runningStep.gameObject); } currentTutorialStepId = TutorialStep.Id.FINISHED; UserProfile.GetOwnUserProfile().SetTutorialStepId((int)currentTutorialStepId); runningStep = null; }
private int GetStepIndexFromTutorialStepId(TutorialStep.Id step) { int result = 0; int stepsCount = steps.Count; for (int i = 0; i < stepsCount; i++) { if (steps[i].stepId == step) { result = i; break; } } return(result); }
private void StartTutorialFromStep(TutorialStep.Id stepId) { if (!initialized) { Initialize(); } if (runningStep != null) { StopCoroutine(executeStepsCoroutine); runningStep.OnStepFinished(); Destroy(runningStep.gameObject); runningStep = null; } executeStepsCoroutine = StartCoroutine(ExecuteSteps(stepId)); }
private void OnRenderingStateChanged(bool renderingEnabled, bool prevState) { if (!isTutorialEnabled || !renderingEnabled) { return; } currentTutorialStepId = (TutorialStep.Id)GetTutorialStepFromProfile(); #if UNITY_EDITOR if (debugFlagStartingValue != 0) { currentTutorialStepId = debugFlagStartingValue; } #endif if (currentTutorialStepId == TutorialStep.Id.FINISHED || runningStep != null) { return; } StartTutorialFromStep(currentTutorialStepId); }