public void LoadQuestsForMascot(string mascotID, int chapterNumber)
        {
            clearCurrentLog();
            Mascot mascot = Service.Get <MascotService>().GetMascot(mascotID);

            LogPanel.SetActive(value: true);
            QuestDefinition        nextAvailableQuest = mascot.GetNextAvailableQuest(chapterNumber);
            int                    num         = ((nextAvailableQuest != null) ? (nextAvailableQuest.QuestNumber - 1) : (-1));
            List <QuestDefinition> validQuests = mascot.GetValidQuests(chapterNumber);

            totalAdventuresItems = validQuests.Count;
            adventureItemsLoaded = 0;
            if (num != -1)
            {
                scrollPosition = (float)num / (float)(totalAdventuresItems - 1);
            }
            else
            {
                scrollPosition = 0f;
            }
            for (int i = 0; i < validQuests.Count; i++)
            {
                CoroutineRunner.Start(loadQuestLogAdventureItem(validQuests[i]), this, "loadQuestLogAdventureItem");
            }
        }
 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 QuestDefinition getAvailableQuest()
        {
            List <Mascot>   list            = Service.Get <MascotService>().Mascots.ToList();
            QuestDefinition questDefinition = null;

            do
            {
                int    index  = UnityEngine.Random.Range(0, list.Count);
                Mascot mascot = list[index];
                list.RemoveAt(index);
                questDefinition = mascot.GetNextAvailableQuest();
            }while (questDefinition == null && list.Count > 0);
            return(questDefinition);
        }
Ejemplo n.º 4
0
    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;
    }