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 []
public void ShowSectionUnlocked(QuestSection section) { var questNotification = Instantiate(sectionUnlockedPrefab, transform).GetComponent <QuestNotification_SectionUnlocked>(); questNotification.Populate(section); questNotification.gameObject.SetActive(false); notificationsQueue.Enqueue(questNotification.gameObject); }
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)); }
public void PopulateProperly_NoSectionName() { QuestSection section = new QuestSection { id = "section", name = "", tasks = new QuestTask[0] }; sectionEntry.Populate(section); Assert.IsFalse(sectionEntry.titleContainer.gameObject.activeSelf); }
protected override void Start() { base.Start(); ourQuest = QuestManager.Instance.GetQuest("Test Quest"); if (ourQuest != null) { ourQuestSection = ourQuest.Sections[3]; } }
public void Populate(QuestSection section) { CleanUpTasksList(); sectionName.text = section.name; foreach (QuestTask task in section.tasks) { CreateTask(task); } }
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); }
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); }
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); } }
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); }
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); }
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()); }
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); }
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); }
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)); }
/// <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); } }
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); } }
public void BlockQuestPosition(QuestSection qs) { if (qs == QuestSection.TotalCount) { return; } int index = (int)qs; questAccessMap[index] = false; if (GetComponent <Image>().enabled & openedQuest == -1) { PrepareBasicQuestWindow(); } }
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; } }
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; } } }
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 []
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) });
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); } }
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)); } }
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); }
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); }
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(); }
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; } } }
public void Populate(QuestSection section) { sectionName.text = section.name; taskName.text = section.tasks.FirstOrDefault()?.name; }
/// <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); }