示例#1
0
    protected override void CompleteQuest()
    {
        base.CompleteQuest();
        //Rewards

        OnQuestCompleted?.Invoke();
    }
示例#2
0
 private void OnProgressChanged(int value)
 {
     if (IsCurrentQuestsCompleted)
     {
         OnQuestCompleted?.Invoke(GetCurrentQuests);
     }
 }
示例#3
0
 private void QuestCompleted(Quest quest)
 {
     if (quest == TopPriorityQuest)
     {
         TopPriorityQuest = questLog.GetNextAvailableQuest();
     }
     OnQuestCompleted?.Invoke(quest);
 }
示例#4
0
    protected override void CompleteQuest()
    {
        base.CompleteQuest();
        //Rewards

        OnQuestCompleted?.Invoke();
        poi.OnInteractedWith -= CompleteQuest;
    }
示例#5
0
    public void CompleteQuest(Quest quest)
    {
        quest.Complete();

        //remove questEntry from UI
        if (onQuestCompletedCallback != null)
        {
            onQuestCompletedCallback.Invoke(quest);
        }
    }
示例#6
0
 private bool CheckQuestProgress()
 {
     if (CurrentObjective >= QuestData.objectiveDatas.Length)
     {
         State = QuestState.COMPLETED;
         OnQuestCompleted?.Invoke(ID);
         return(true);
     }
     return(false);
 }
示例#7
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 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);
            }
        }
    private void CheckSubQuests()
    {
        if (IsCompleted)
        {
            return;
        }

        for (int i = 0; i < subQuests_.Count; i++)
        {
            SubQuest quest = subQuests_[i];

            if (quest && quest.IsCompleted)
            {
                if (i + 1 < subQuests_.Count && !subQuests_[i + 1].IsUnlocked)
                {
                    subQuests_[i + 1].UnlockQuest(true);

                    return;
                }


                continue;
            }
            return;
        }

        GameObject player = GameObject.FindGameObjectWithTag("Player");

        if (player)
        {
            Character c = player.GetComponent <Character>();
            if (c)
            {
                c.Xp = c.Xp + xpWhenCompleted;
            }
        }

        questCompleted_ = true;

        CallOnTriggered();
        questCompleted_ = true;

        if (NotifcationManager.Instance)
        {
            NotifcationManager.Instance.AddNotification("Quest Complete!");
        }

        if (OnQuestCompleted != null)
        {
            OnQuestCompleted.Invoke(this);
        }
    }
        private IEnumerator Sequence(List <QuestsTrackerSection> visibleSections, List <QuestsTrackerSection> newSections)
        {
            yield return(new WaitUntil(() => outAnimDone));

            ClearSectionRoutines();

            if (progressRoutine != null)
            {
                StopCoroutine(progressRoutine);
            }
            progressRoutine = StartCoroutine(ProgressSequence());

            //Progress of currently visible sections
            for (int i = 0; i < visibleSections.Count; i++)
            {
                sectionRoutines.Add(StartCoroutine(visibleSections[i].Sequence()));
            }

            yield return(WaitForTaskRoutines());

            //Show and progress of new tasks
            for (int i = 0; i < newSections.Count; i++)
            {
                newSections[i].gameObject.SetActive(true);
                sectionRoutines.Add(StartCoroutine(newSections[i].Sequence()));
            }

            OnLayoutRebuildRequested?.Invoke();
            yield return(WaitForTaskRoutines());

            OnLayoutRebuildRequested?.Invoke();
            //The entry should exit automatically if questCompleted or no progress, therefore the use of MinValue
            DateTime tasksIdleTime = (quest.isCompleted || !hasProgressedThisUpdate) ? DateTime.MinValue : DateTime.Now;

            yield return(new WaitUntil(() => isProgressAnimationDone && !isPinned && (DateTime.Now - tasksIdleTime) > TimeSpan.FromSeconds(3)));

            if (quest.isCompleted)
            {
                OnQuestCompleted?.Invoke(quest);
            }

            for (int i = 0; i < rewardsToNotify.Count; i++)
            {
                OnRewardObtained?.Invoke(rewardsToNotify[i]);
            }

            rewardsToNotify.Clear();

            isReadyForDisposal = true;
        }
示例#10
0
 public void InvokeQuestCompleted(Quest quest)
 {
     Debug.Log("Quest completed");
     OnQuestCompleted.Invoke(quest);
 }
示例#11
0
        public void OnCompleted(Aisling user, bool equipLoot = false)
        {
            OnQuestCompleted?.Invoke(this);

            GiveRewards(user, equipLoot);
        }
示例#12
0
 public static void RaiseQuestCompletedEvent(Quest quest) => OnQuestCompleted?.Invoke(quest);
示例#13
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);
                }
                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;
                        currentTask.justUnlocked   = !oldTaskFound || (currentTask.status != QuestsLiterals.Status.BLOCKED && oldTask.status == QuestsLiterals.Status.BLOCKED);
                        currentTask.oldProgress    = oldTaskFound ? oldTask.progress : 0;
                    }
                    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);
            }

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

            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);
                }
            }

            RestoreProgressFlags(progressedQuest);
        }
示例#14
0
 private void OnQuestHasBeenCompleted(Quest sender)
 {
     OnQuestCompleted?.Invoke(this, sender);
 }