コード例 #1
0
        public void SetUp()
        {
            QuestModel questMock = new QuestModel
            {
                id = MOCK_QUEST_ID, name = "name", description = "description",
            };
            QuestSection sectionMock = new QuestSection
            {
                id = MOCK_SECTION_ID
            };
            QuestTask taskMock = new QuestTask
            {
                id      = MOCK_TASK_ID,
                type    = "single",
                payload = JsonUtility.ToJson(new TaskPayload_Single
                {
                    isDone = false
                })
            };

            sectionMock.tasks = new []
            {
                taskMock
            };
            questMock.sections = new []
            {
                sectionMock
            };
            DataStore.i.Quests.quests.Set(new []
コード例 #2
0
        public void ShowSectionUnlocked(QuestSection section)
        {
            var questNotification = Instantiate(sectionUnlockedPrefab, transform).GetComponent <QuestNotification_SectionUnlocked>();

            questNotification.Populate(section);
            questNotification.gameObject.SetActive(false);
            notificationsQueue.Enqueue(questNotification.gameObject);
        }
コード例 #3
0
        private ReadOnlySpan <byte> ReadQuestSection(ReadOnlySpan <byte> fileData)
        {
            m_questSection = new QuestSection(fileData);
            m_questSection.Validate();

            m_sections.Add(m_questSection);

            return(fileData.Slice(QuestSection.FixedSize));
        }
コード例 #4
0
        public void PopulateProperly_NoSectionName()
        {
            QuestSection section = new QuestSection {
                id = "section", name = "", tasks = new QuestTask[0]
            };

            sectionEntry.Populate(section);
            Assert.IsFalse(sectionEntry.titleContainer.gameObject.activeSelf);
        }
コード例 #5
0
 protected override void Start()
 {
     base.Start();
     ourQuest = QuestManager.Instance.GetQuest("Test Quest");
     if (ourQuest != null)
     {
         ourQuestSection = ourQuest.Sections[3];
     }
 }
コード例 #6
0
 public void Populate(QuestSection section)
 {
     CleanUpTasksList();
     sectionName.text = section.name;
     foreach (QuestTask task in section.tasks)
     {
         CreateTask(task);
     }
 }
コード例 #7
0
    public static void SendTaskProgressed(QuestModel quest, QuestSection section, QuestTask task)
    {
        var data = new Dictionary <string, string>();

        FillQuestData(data, quest);
        FillSectionData(data, section);
        FillTaskData(data, task);
        GenericAnalytics.SendAnalytic(TASK_PROGRESSED, data);
    }
コード例 #8
0
        private FileValidity LoadFileSections()
        {
            m_sections.Clear();

            if (m_fileData.Length < MinimumFileSize)
            {
                return(FileValidity.NotDiablo2File);
            }

            int offset = 0;

            m_headerSection = new HeaderSection(m_fileData);
            m_sections.Add(m_headerSection);
            offset += m_headerSection.Size;

            var validity = ValidateData();

            if (validity == FileValidity.Valid)
            {
                m_questSection = new QuestSection(m_fileData, offset);
                m_sections.Add(m_questSection);
                offset += m_questSection.Size;

                m_waypointSection = new WaypointSection(m_fileData, offset);
                m_sections.Add(m_waypointSection);
                offset += m_waypointSection.Size;

                m_npcSection = new NpcSection(m_fileData, offset);
                m_sections.Add(m_npcSection);
                offset += m_npcSection.Size;

                m_statsSection = new StatsSection(m_fileData, offset);
                m_sections.Add(m_statsSection);
                offset += m_statsSection.Size;

                m_skillSection = new SkillSection(m_fileData, offset, m_headerSection.SkillSectionLength);
                m_sections.Add(m_skillSection);
                offset += m_skillSection.Size;

                m_itemSection = new ItemListSection(m_fileData, offset);
                m_sections.Add(m_itemSection);
                offset += m_itemSection.Size;

                m_corpseSection = new ItemListSection(m_fileData, offset);
                m_sections.Add(m_corpseSection);
                offset += m_corpseSection.Size;

                m_mercenarySection = new MercenaryItemSection(m_fileData, offset);
                m_sections.Add(m_mercenarySection);
                offset += m_mercenarySection.Size;

                //if (offset != m_fileData.Length)
                //    validity = FileValidity.UnknownError;
            }

            return(validity);
        }
コード例 #9
0
 public void Populate(QuestSection section)
 {
     CleanUpTasksList();
     titleContainer.gameObject.SetActive(!string.IsNullOrEmpty(section.name));
     sectionName.text = section.name;
     foreach (QuestTask task in section.tasks)
     {
         CreateTask(task);
     }
 }
コード例 #10
0
        public void PopulateProperly()
        {
            QuestSection section = new QuestSection {
                id = "section", name = "sectionName", tasks = new QuestTask[0]
            };

            sectionEntry.Populate(section);
            Assert.AreEqual(section.name, sectionEntry.sectionTitle.text);
            Assert.IsTrue(sectionEntry.titleContainer.gameObject.activeSelf);
        }
コード例 #11
0
        public void PopulateAndPrepareTasks_JustUnlocked()
        {
            QuestSection section = new QuestSection {
                id = "section", name = "", tasks = new [] { task_justUnlocked }
            };

            sectionEntry.Populate(section);

            //Just unlocked tasks are hidden
            Assert.IsFalse(sectionEntry.taskEntries[task_justUnlocked.id].gameObject.activeSelf);
        }
コード例 #12
0
    private static void FillSectionData(Dictionary <string, string> data, QuestSection section)
    {
        if (section == null)
        {
            return;
        }

        data.Add("section_id", section.id);
        data.Add("section_name", section.name);
        data.Add("section_progress", section.progress.ToString());
    }
コード例 #13
0
        public void PopulateAndPrepareTasks_JustProgressed()
        {
            QuestSection section = new QuestSection {
                id = "section", name = "", tasks = new [] { task_justProgressed }
            };

            sectionEntry.Populate(section);

            //Just progressed tasks are visible
            Assert.IsTrue(sectionEntry.taskEntries[task_justProgressed.id].gameObject.activeSelf);
        }
コード例 #14
0
        public void PopulateAndPrepareTasks_JustCompleted()
        {
            QuestSection section = new QuestSection {
                id = "section", name = "", tasks = new [] { task_justCompleted }
            };

            sectionEntry.Populate(section);

            //Completed tasks that has not been just completed are hidden
            Assert.IsTrue(sectionEntry.taskEntries[task_justCompleted.id].gameObject.activeSelf);
        }
コード例 #15
0
        public void PopulateAndPrepareTasks_Completed()
        {
            QuestSection section = new QuestSection {
                id = "section", name = "", tasks = new [] { task_completed }
            };

            sectionEntry.Populate(section);

            //Completed tasks that has not been just completed are not even added
            Assert.IsFalse(sectionEntry.taskEntries.ContainsKey(task_completed.id));
        }
コード例 #16
0
ファイル: QuestsController.cs プロジェクト: useit015/explorer
        /// <summary>
        /// Update progress in a quest
        /// </summary>
        /// <param name="progressedQuest"></param>
        public void UpdateQuestProgress(QuestModel progressedQuest)
        {
            if (!progressedQuest.canBePinned)
            {
                pinnedQuests.Remove(progressedQuest.id);
            }

            //Alex: Edge case. Quests has no sections/tasks, we ignore the UpdateQuestProgress and remove the cached one.
            if (progressedQuest.sections == null || progressedQuest.sections.Length == 0)
            {
                quests.Remove(progressedQuest.id);
                return;
            }

            //Alex: Edge case. Progressed quest was not included in the initialization.
            // We invoke quests events but no sections or QuestCompleted one.
            if (!quests.TryGetValue(progressedQuest.id, out QuestModel oldQuest))
            {
                quests.Add(progressedQuest.id, progressedQuest);
                OnQuestProgressed?.Invoke(progressedQuest.id);

                return;
            }

            quests[progressedQuest.id] = progressedQuest;
            OnQuestProgressed?.Invoke(progressedQuest.id);

            for (int i = 0; i < progressedQuest.sections.Length; i++)
            {
                QuestSection newQuestSection  = progressedQuest.sections[i];
                QuestSection nextQuestSection = (i + 1) < progressedQuest.sections.Length ? (progressedQuest.sections[i + 1]) : null;

                //Alex: Edge case. New quest reported contains a section that was previously not contained.
                // if it's completed, we call the SectionCompleted event and unlock the next one
                bool sectionCompleted = !oldQuest.TryGetSection(newQuestSection.id, out QuestSection oldQuestSection);

                sectionCompleted = sectionCompleted || Math.Abs(oldQuestSection.progress - newQuestSection.progress) > Mathf.Epsilon && newQuestSection.progress >= 1;

                if (sectionCompleted)
                {
                    OnSectionCompleted?.Invoke(progressedQuest.id, newQuestSection.id);
                    if (nextQuestSection != null)
                    {
                        OnSectionUnlocked?.Invoke(progressedQuest.id, nextQuestSection.id);
                    }
                }
            }

            if (!oldQuest.isCompleted && progressedQuest.isCompleted)
            {
                OnQuestCompleted?.Invoke(progressedQuest.id);
            }
        }
コード例 #17
0
        public void Populate(QuestModel quest, QuestSection section)
        {
            CleanUpTasksList();
            titleContainer.gameObject.SetActive(!string.IsNullOrEmpty(section.name));
            sectionName.text = section.name;
            var orderedTasks = section.tasks.OrderBy(x => x.progress >= 1).ThenBy(x => x.completionTime).ToArray();

            foreach (QuestTask task in orderedTasks)
            {
                CreateTask(quest, task);
            }
        }
コード例 #18
0
    public void BlockQuestPosition(QuestSection qs)
    {
        if (qs == QuestSection.TotalCount)
        {
            return;
        }
        int index = (int)qs;

        questAccessMap[index] = false;
        if (GetComponent <Image>().enabled & openedQuest == -1)
        {
            PrepareBasicQuestWindow();
        }
    }
コード例 #19
0
ファイル: GTwinChest.cs プロジェクト: ZeroWR/AerandyrGame
 protected override void Start()
 {
     base.Start();
     ourQuest = QuestManager.Instance.GetQuest("Test Quest");
     if (ourQuest != null)
     {
         ourQuestSection = ourQuest.Sections[1];
     }
     colliderCallbackSource = GetComponentInChildren <ColliderCallbackSource>();
     if (colliderCallbackSource != null)
     {
         colliderCallbackSource.TriggerEnter += this.OnSeenChest;
     }
 }
コード例 #20
0
 private void RestoreProgressFlags(QuestModel progressedQuest)
 {
     progressedQuest.oldProgress = progressedQuest.progress;
     for (int index = 0; index < progressedQuest.sections.Length; index++)
     {
         QuestSection section = progressedQuest.sections[index];
         for (var index2 = 0; index2 < section.tasks.Length; index2++)
         {
             section.tasks[index2].justProgressed = false;
             section.tasks[index2].justUnlocked   = false;
             section.tasks[index2].oldProgress    = section.tasks[index2].progress;
         }
     }
 }
コード例 #21
0
        public void SetUp()
        {
            QuestModel questMock = new QuestModel {
                id = MOCK_QUEST_ID, status = QuestsLiterals.Status.ON_GOING
            };
            QuestSection sectionMock = new QuestSection {
                id = MOCK_SECTION_ID
            };
            QuestTask taskMock = new QuestTask {
                id = MOCK_TASK_ID
            };

            sectionMock.tasks  = new [] { taskMock };
            questMock.sections = new [] { sectionMock };
            DataStore.i.Quests.quests.Set(new []
コード例 #22
0
        public void SetUp()
        {
            QuestModel questMock = new QuestModel {
                id = MOCK_QUEST_ID
            };
            QuestSection sectionMock = new QuestSection {
                id = MOCK_SECTION_ID
            };
            QuestTask taskMock = new QuestTask {
                id = MOCK_TASK_ID
            };

            sectionMock.tasks  = new [] { taskMock };
            questMock.sections = new [] { sectionMock };
            DataStore.i.Quests.quests.Set(new [] { (questMock.id, questMock) });
コード例 #23
0
    public void UnblockQuestPosition(QuestSection qs, bool prepareQuestIfNone)
    {
        if (qs == QuestSection.TotalCount)
        {
            return;
        }
        byte index = (byte)qs;

        questAccessMap[index] = true;
        if (GetComponent <Image>().enabled & openedQuest == -1)
        {
            PrepareBasicQuestWindow();
        }
        if (activeQuests[index] == Quest.NoQuest && prepareQuestIfNone)
        {
            StartNewQuestAwaiting(index);
        }
    }
コード例 #24
0
    public void UnblockQuestPosition(QuestSection qs)
    {
        if (qs == QuestSection.TotalCount)
        {
            return;
        }
        int index = (int)qs;

        questAccessMap[index] = true;
        if (GetComponent <Image>().enabled & openedQuest == -1)
        {
            PrepareBasicQuestWindow();
        }
        if (activeQuests[index] == Quest.NoQuest)
        {
            StartCoroutine(WaitForNewQuest(index));
        }
    }
コード例 #25
0
        public void Populate(QuestModel newQuest)
        {
            quest           = newQuest;
            questTitle.text = quest.name;
            SetIcon(quest.icon);
            QuestSection currentSection = quest.sections.First(x => x.progress < 1f);

            sectionTitle.text   = $"{currentSection.name} - {currentSection.progress * 100}%";
            progress.fillAmount = currentSection.progress;

            CleanUpTasksList();
            foreach (QuestTask task in currentSection.tasks)
            {
                CreateTask(task);
            }
            expandCollapseButton.gameObject.SetActive(currentSection.tasks.Length > 0);
            SetExpandCollapseState(true);
        }
コード例 #26
0
        public void Populate(QuestModel newQuest)
        {
            quest           = newQuest;
            questTitle.text = quest.name;
            SetIcon(quest.icon);
            QuestSection currentSection = quest.sections.First(x => x.progress < 1f);
            string       separator      = String.IsNullOrEmpty(currentSection.name) ? "" : " - ";

            sectionTitle.text = $"{currentSection.name}{separator}{(currentSection.progress * 100):0.0}%";
            progressTarget    = currentSection.progress;

            CleanUpTasksList();
            foreach (QuestTask task in currentSection.tasks)
            {
                CreateTask(task);
            }
            expandCollapseButton.gameObject.SetActive(currentSection.tasks.Length > 0);
            SetExpandCollapseState(true);
        }
コード例 #27
0
        public void Populate(QuestSection newSection)
        {
            sequenceState = SequenceState.NotStarted;
            ClearTaskRoutines();

            section = newSection;
            QuestTask[] allTasks = section.tasks;
            titleContainer.SetActive(!string.IsNullOrEmpty(section.name));
            sectionTitle.text = section.name;

            bool          hasCompletedTasksToShow = false;
            List <string> entriesToRemove         = taskEntries.Keys.ToList();

            for (int index = 0; index < allTasks.Length; index++)
            {
                QuestTask task = allTasks[index];
                //We only show completed quests that has been just completed to show the progress
                if (!taskEntries.ContainsKey(task.id) && (task.status == QuestsLiterals.Status.BLOCKED || (task.progress >= 1 && !task.justProgressed)))
                {
                    continue;
                }

                entriesToRemove.Remove(task.id);
                if (!taskEntries.TryGetValue(task.id, out QuestsTrackerTask taskEntry))
                {
                    taskEntry = CreateTask();
                    //New tasks are invisible
                    taskEntry.gameObject.SetActive(!task.justUnlocked);
                    taskEntries.Add(task.id, taskEntry);
                }

                taskEntry.Populate(task);
                taskEntry.transform.SetSiblingIndex(index);
            }

            for (int index = 0; index < entriesToRemove.Count; index++)
            {
                DestroyTaskEntry(entriesToRemove[index]);
            }
            OnLayoutRebuildRequested?.Invoke();
        }
コード例 #28
0
 private void Update()
 {
     if (Controller == null)
     {
         if (this.itemModels.Any())
         {
             this.Clear();
         }
     }
     else
     {
         if (Controller.CurrentQuest != null)
         {
             if (this.currentlyShowingSection != Controller.CurrentQuest.CurrentSection)
             {
                 this.CurrentlyShowingSection = Controller.CurrentQuest.CurrentSection;
             }
         }
         else if (CurrentlyShowingSection != null)
         {
             CurrentlyShowingSection = null;                 //CurrentQuest is null, so set the CurrentlyShowingSection to null;
         }
     }
 }
コード例 #29
0
 public void Populate(QuestSection section)
 {
     sectionName.text = section.name;
     taskName.text    = section.tasks.FirstOrDefault()?.name;
 }
コード例 #30
0
        /// <summary>
        /// Update progress in a quest
        /// </summary>
        /// <param name="progressedQuest"></param>
        public void UpdateQuestProgress(QuestModel progressedQuest)
        {
            if (!progressedQuest.canBePinned)
            {
                pinnedQuests.Remove(progressedQuest.id);
            }

            //Alex: Edge case. Quests has no sections/tasks, we ignore the UpdateQuestProgress and remove the cached one.
            if (progressedQuest.sections == null || progressedQuest.sections.Length == 0)
            {
                quests.Remove(progressedQuest.id);
                return;
            }

            //Alex: Edge case. Progressed quest was not included in the initialization. We dont invoke quests events
            if (!quests.TryGetValue(progressedQuest.id, out QuestModel oldQuest))
            {
                RestoreProgressFlags(progressedQuest);
                quests.Add(progressedQuest.id, progressedQuest);
                if (!progressedQuest.isCompleted)
                {
                    OnNewQuest?.Invoke(progressedQuest.id);
                    QuestsControllerAnalytics.SendQuestDiscovered(progressedQuest);
                }

                return;
            }

            quests[progressedQuest.id]  = progressedQuest;
            progressedQuest.oldProgress = oldQuest.progress;

            for (int index = 0; index < progressedQuest.sections.Length; index++)
            {
                QuestSection newQuestSection = progressedQuest.sections[index];

                bool oldQuestSectionFound = oldQuest.TryGetSection(newQuestSection.id, out QuestSection oldQuestSection);

                for (int index2 = 0; index2 < newQuestSection.tasks.Length; index2++)
                {
                    QuestTask currentTask = newQuestSection.tasks[index2];
                    if (oldQuestSectionFound)
                    {
                        bool oldTaskFound = oldQuestSection.TryGetTask(currentTask.id, out QuestTask oldTask);
                        currentTask.justProgressed = !oldTaskFound || currentTask.progress != oldTask.progress;
                        if (currentTask.justProgressed)
                        {
                            QuestsControllerAnalytics.SendTaskProgressed(progressedQuest, newQuestSection, currentTask);
                        }

                        currentTask.justUnlocked = !oldTaskFound || (currentTask.status != QuestsLiterals.Status.BLOCKED && oldTask.status == QuestsLiterals.Status.BLOCKED);
                        currentTask.oldProgress  = oldTaskFound ? oldTask.progress : 0;
                        if (oldTaskFound && oldTask.status != QuestsLiterals.Status.COMPLETED && currentTask.status == QuestsLiterals.Status.COMPLETED)
                        {
                            QuestsControllerAnalytics.SendTaskCompleted(progressedQuest, newQuestSection, currentTask);
                        }
                    }
                    else
                    {
                        currentTask.justProgressed = false;
                        currentTask.justUnlocked   = false;
                        currentTask.oldProgress    = 0;
                    }
                }
            }


            // If quest is not blocked anymore or being secret has been just started, we call NewQuest event.
            if (!progressedQuest.isCompleted &&
                ((oldQuest.status == QuestsLiterals.Status.BLOCKED && progressedQuest.status != QuestsLiterals.Status.BLOCKED) ||
                 (progressedQuest.visibility == QuestsLiterals.Visibility.SECRET && oldQuest.status == QuestsLiterals.Status.NOT_STARTED && progressedQuest.status != QuestsLiterals.Status.NOT_STARTED)))
            {
                OnNewQuest?.Invoke(progressedQuest.id);
                QuestsControllerAnalytics.SendQuestDiscovered(progressedQuest);
            }

            OnQuestUpdated?.Invoke(progressedQuest.id, HasProgressed(progressedQuest, oldQuest));
            if (!oldQuest.isCompleted && progressedQuest.isCompleted)
            {
                QuestsControllerAnalytics.SendQuestCompleted(progressedQuest);
            }

            if (progressedQuest.rewards == null)
            {
                progressedQuest.rewards = new QuestReward[0];
            }

            for (int index = 0; index < progressedQuest.rewards.Length; index++)
            {
                QuestReward newReward = progressedQuest.rewards[index];

                //Alex: Edge case. New quest reported contains a reward that was previously not contained.
                // If it's completed, we call the RewardObtained event
                bool oldRewardFound = oldQuest.TryGetReward(newReward.id, out QuestReward oldReward);
                bool rewardObtained = (!oldRewardFound && newReward.status == QuestsLiterals.RewardStatus.OK) || (newReward.status != oldReward.status && newReward.status == QuestsLiterals.RewardStatus.OK);
                if (rewardObtained)
                {
                    OnRewardObtained?.Invoke(progressedQuest.id, newReward.id);
                    QuestsControllerAnalytics.SendRewardObtained(progressedQuest, newReward);
                }
            }

            RestoreProgressFlags(progressedQuest);
        }