private void Start() { questsScreenController = GetComponentInParent <QuestsScreenController>(); questsScreenController.GetComponent <MainNavBarBackButtonEventToFSMEvent>().enabled = false; currentMascot = Service.Get <MascotService>().ActiveMascot; if (currentMascot == null) { string currentMascotID = questsScreenController.CurrentMascotID; if (!string.IsNullOrEmpty(currentMascotID)) { currentMascot = Service.Get <MascotService>().GetMascot(currentMascotID); } } currentChapter = questsScreenController.CurrentChapterData; if (currentMascot != null) { if (currentChapter.Number > 0) { LoadQuestsForMascot(currentMascot.Name, currentChapter.Number); return; } QuestDefinition nextAvailableQuest = currentMascot.GetNextAvailableQuest(); int chapterNumber = ((nextAvailableQuest != null) ? (nextAvailableQuest.ChapterNumber - 1) : currentMascot.Definition.ChapterData[currentMascot.Definition.ChapterData.Length - 1].Number); LoadQuestsForMascot(currentMascot.Name, chapterNumber); } }
private void onMascotButtonPressed(string mascotName) { QuestsScreenController questsScreenController = GetComponentInParent <QuestsScreenController>(); if (questsScreenController == null) { GameObject gameObject = GetComponentInParent <StateMachineContext>().gameObject; questsScreenController = gameObject.GetComponentInChildren <QuestsScreenController>(); } questsScreenController.CurrentMascotID = mascotName; Service.Get <ICPSwrveService>().Action("game.quest", "mascot", mascotName); }
public void OnStateChanged(string newStateString) { QuestsScreenController componentInParent = GetComponentInParent <QuestsScreenController>(); Mascot mascot = Service.Get <MascotService>().ActiveMascot; QuestsAdventuresState questsAdventuresState = (QuestsAdventuresState)Enum.Parse(typeof(QuestsAdventuresState), newStateString); MascotDefinition.QuestChapterData currentChapterData = componentInParent.CurrentChapterData; if (mascot == null) { string currentMascotID = componentInParent.CurrentMascotID; if (!string.IsNullOrEmpty(currentMascotID)) { mascot = Service.Get <MascotService>().GetMascot(currentMascotID); } mainNav.SetBackButtonVisible(visible: true); } else if (questsAdventuresState == QuestsAdventuresState.Log) { if (firstTimeOpened) { QuestDefinition nextAvailableQuest = mascot.GetNextAvailableQuest(); int num = 0; if (nextAvailableQuest != null) { num = nextAvailableQuest.ChapterNumber - 1; } else { for (int num2 = mascot.Definition.ChapterData.Length - 1; num2 >= 0; num2--) { if (!mascot.Definition.ChapterData[num2].IsPreviewChapter) { num = num2; break; } } } componentInParent.CurrentChapterData = mascot.Definition.ChapterData[num]; firstTimeOpened = false; GameObject gameObject = GameObject.FindWithTag(UIConstants.Tags.UI_Tray_Root); StateMachineContext component = gameObject.GetComponent <StateMachineContext>(); component.SendEvent(new ExternalEvent("ScreenQuestsAdventures", "logQuests")); return; } mainNav.SetBackButtonVisible(visible: false); } else { mainNav.SetBackButtonVisible(visible: true); } Localizer localizer = Service.Get <Localizer>(); switch (questsAdventuresState) { case QuestsAdventuresState.Log: if (mascot != null) { mainNav.SetTitleText(localizer.GetTokenTranslation(mascot.Definition.i18nAdventureLogTitleText)); } break; case QuestsAdventuresState.LogQuests: mainNav.SetTitleText(localizer.GetTokenTranslation(currentChapterData.Name)); break; } firstTimeOpened = false; }