//changes the count on the elment panels based on the tutorial public static void ChangeTextOnElementPanels(MainMenuController.Tutorial tutorialType) { string text; if (tutorialType == MainMenuController.Tutorial.Gathering) { text = GatheringTutorialElementPanelText; } else if (tutorialType == MainMenuController.Tutorial.Crafting) { text = CraftingTutorialElementPanelText; } else { return; } foreach (CraftingTutorialComponent component in AllTutorialsComponents[tutorialType]) { if (component.gameObject.name.Contains(ElementPanelName)) { component.SetText(text); } } }
//shows the tutorial message public static void DisplayTutorialMessage(MainMenuController.Tutorial tutorialType) { if (tutorialType == MainMenuController.Tutorial.BuyHint) { CraftingTutorialController.SetTutorialMessageBoard(BuyingHintMessage); } }
//brings all the components of a certain type to the front public static void ActivateTutorialComponents(MainMenuController.Tutorial tutorialType) { if (AllTutorialsComponents.ContainsKey(tutorialType)) { ActiveTutorialType = tutorialType; ChangeTextOnElementPanels(tutorialType); foreach (CraftingTutorialComponent component in AllTutorialsComponents[tutorialType]) { component.ActivateComponent(); } } }
//brings all the components in a tutorial back to their natural sort order public static void DeactivateTutorialComponents(MainMenuController.Tutorial tutorialType) { //sets element panels to zero ElementPanelsActive = 0; ActiveTutorialType = MainMenuController.Tutorial.None; foreach (CraftingTutorialComponent component in AllTutorialsComponents[tutorialType]) { component.DeactivateComponent(); } HideTutorialMessage(); }
/// <summary> /// Times the tutorial completion. /// </summary> /// <returns>The tutorial completion.</returns> /// <param name="tutorial">The tutorial that was completed.</param> private IEnumerator TimeTutorialCompletion(BeginTutorial tutorial, MainMenuController.Tutorial tutorialEnum) { float timeInTutorial = 0; while (!tutorialHasEnded) { timeInTutorial += Time.deltaTime; yield return(new WaitForFixedUpdate()); } #if DEBUG Debug.Log("This tutorial took " + timeInTutorial + " to complete"); #endif SetTutorialComplete(tutorialEnum); GetEndEvent(tutorial)(timeInTutorial); }
//used as a constructor: changes the tutorial this component is associated with public void Reinitialize(MainMenuController.Tutorial TutorialType) { Unitialize(); //starts up the references again EstablishReferences(); //changes the type this.TutorialType = TutorialType; //adds its to the dictionary of all the components in each tutorial if (!AllTutorialsComponents.ContainsKey(TutorialType)) { AllTutorialsComponents.Add(TutorialType, new List <CraftingTutorialComponent>()); } else if (TutorialType == ActiveTutorialType) { ActivateComponent(); } AllTutorialsComponents[TutorialType].Add(this); }
/// <summary> /// Exectes the tutorial. And times how long it takes the user to complete /// </summary> /// <param name="tutorial">The tutorial that is being run.</param> public void ExecuteTutorial(BeginTutorial tutorial, MainMenuController.Tutorial tutorialEnum) { if (tutorial == null) { return; } else { tutorial(); } //turns on the mask to cover the game ToggleMask(true); tutorialHasEnded = false; TutorialActive = true; //sets the enum to track which tutorial the script is executing CurrentTutorial = tutorialEnum; StartCoroutine(TimeTutorialCompletion(tutorial, tutorialEnum)); }
//triggers the tutorial as complete in the player prefs bool private void SetTutorialComplete(MainMenuController.Tutorial tutorial) { if (tutorial == MainMenuController.Tutorial.Gathering) { Utility.SetPlayerPrefIntAsBool(GlobalVars.ELEMENTS_DRAGGED_TUTORIAL_KEY, true); } else if (tutorial == MainMenuController.Tutorial.Crafting) { Utility.SetPlayerPrefIntAsBool(GlobalVars.CRAFTING_TUTORIAL_KEY, true); } else if (tutorial == MainMenuController.Tutorial.TierSwitch) { Utility.SetPlayerPrefIntAsBool(GlobalVars.TIER_SWITCH_TUTORIAL_KEY, true); } else if (tutorial == MainMenuController.Tutorial.BuyHint) { Utility.SetPlayerPrefIntAsBool(GlobalVars.BUY_HINT_TUTORIAL_KEY, true); } else if (tutorial == MainMenuController.Tutorial.UpgradePowerup) { Utility.SetPlayerPrefIntAsBool(GlobalVars.UPGRADE_POWERUP_TUTORIAL_KEY, true); } }
//takes an event call from main menu controller and executes the corresponding tutorial //uses an enum Tutorial from MainMenuController to decide which tutorial to execute private void TutorialEventHandler(MainMenuController.Tutorial tutorial) { Utility.Log(tutorial + " is now playing"); //#####out //if (tutorial == MainMenuController.Tutorial.Gathering) { //ExecuteTutorial(OnElementsDraggedIntoGatheringTutorialBegan, tutorial); //} else if (tutorial == MainMenuController.Tutorial.Crafting) { ExecuteTutorial(OnCraftingModeTutorialBegan, tutorial); } else if (tutorial == MainMenuController.Tutorial.TierSwitch) { ExecuteTutorial(OnTierSwitchingTutorialBegan, tutorial); } else if (tutorial == MainMenuController.Tutorial.BuyHint) { ExecuteTutorial(OnBuyHintTutorialBegan, tutorial); } else if (tutorial == MainMenuController.Tutorial.UpgradePowerup) { ExecuteTutorial(OnBuyPowerUpUpgradeTutorialBegan, tutorial); } }
/// <summary> /// Exectes the tutorial. And times how long it takes the user to complete /// </summary> /// <param name="tutorial">The tutorial that is being run.</param> public void ExecuteTutorial(BeginTutorial tutorial, MainMenuController.Tutorial tutorialEnum) { if (tutorial == null) { return; } else { tutorial(); } //turns on the mask to cover the game ToggleMask(true); tutorialHasEnded = false; TutorialActive = true; //sets the enum to track which tutorial the script is executing CurrentTutorial = tutorialEnum; StartCoroutine (TimeTutorialCompletion(tutorial, tutorialEnum)); }
//used as a constructor: changes the tutorial this component is associated with public void Reinitialize(MainMenuController.Tutorial TutorialType) { Unitialize(); //starts up the references again EstablishReferences(); //changes the type this.TutorialType = TutorialType; //adds its to the dictionary of all the components in each tutorial if (!AllTutorialsComponents.ContainsKey(TutorialType)) { AllTutorialsComponents.Add(TutorialType, new List<CraftingTutorialComponent>()); } else if (TutorialType == ActiveTutorialType) { ActivateComponent(); } AllTutorialsComponents[TutorialType].Add(this); }