/// <summary> /// Check whether the itemName belongs to any /// of the quest. If it is, update the quest progress. /// </summary> /// <param name="itemName"> /// Name of an Item Prefab. /// </param> /// <returns> /// Whether the quest item is removed from the /// scene. /// </returns> public bool CheckQuestItem(string itemName) { QuestUI finishedQuest = null; foreach (QuestUI quest in activeQuests) { if (quest.CheckObject(itemName)) { bool finished = quest.UpdateProgress(); if (finished) { finishedQuest = quest; // can't delete while looping break; } } } if (finishedQuest != null) { activeQuests.Remove(finishedQuest); string nextQuest = finishedQuest.detail.nextQuestName; if (nextQuest != "" && nextQuest != null) { AddQuest(finishedQuest.detail.nextQuestName); } DisplayQuests(); var args = new QuestEndedEventArgs(); args.questName = finishedQuest.detail.questName; OnQuestEnded?.Invoke(this, args); return(true); } return(false); }
public void OnQuestEndHandler(object source, QuestEndedEventArgs args) { string dialogueName; questDialogueDict.dict.TryGetValue(args.questName, out dialogueName); if (dialogueName != null) { SetDialogue(dialogueName); } }