protected virtual bool IsDoingSimilarGeneratedQuest(Quest quest, QuestListContainer playerQuestListContainer) { if (quest == null || playerQuestListContainer == null || !quest.isProcedurallyGenerated || activeQuests == null) { return(false); } // Check active quests given by this giver: for (int i = 0; i < activeQuests.Count; i++) { var activeQuest = activeQuests[i]; if (activeQuest == null) { continue; } if (activeQuest.tagDictionary.ContainsTag(QuestMachineTags.ACTION) && quest.tagDictionary.ContainsTag(QuestMachineTags.ACTION) && string.Equals(activeQuest.tagDictionary.dict[QuestMachineTags.ACTION], quest.tagDictionary.dict[QuestMachineTags.ACTION]) && activeQuest.tagDictionary.ContainsTag(QuestMachineTags.TARGET) && quest.tagDictionary.ContainsTag(QuestMachineTags.TARGET) && string.Equals(activeQuest.tagDictionary.dict[QuestMachineTags.TARGET], quest.tagDictionary.dict[QuestMachineTags.TARGET])) { return(true); } } return(false); }
public void SelectQuest(QuestListContainer questListContainer, int questListIndex) { if (questListContainer == null) { SelectQuest(null, null, 0); return; } var quest = (0 <= questListIndex && questListIndex < questListContainer.questList.Count) ? questListContainer.questList[questListIndex] : null; SelectQuest(quest, questListContainer, questListIndex); }
public void SelectQuest(QuestListContainer questListContainer) { if (questListContainer == null) { SelectQuest(null, null, 0); return; } var questListIndex = (questListContainer.GetInstanceID() == m_questListContainerInstanceID) ? m_questListIndex : 0; SelectQuest(questListContainer, questListIndex); }
public virtual void Toggle(QuestListContainer questListContainer) { if (isVisible) { Hide(); } else { Show(questListContainer); } }
/// <summary> /// Gives all quests to a quester. /// </summary> /// <param name="questerQuestListContainer">Quester's QuestListContainer.</param> public virtual void GiveAllQuestsToQuester(QuestListContainer questerQuestListContainer) { if (questerQuestListContainer == null || questList.Count == 0) { return; } for (int i = questList.Count - 1; i >= 0; i--) { var quest = questList[i]; if (quest != null && !questerQuestListContainer.ContainsQuest(quest.id)) { GiveQuestToQuester(questList[i], questerQuestListContainer); } } }
/// <summary> /// Adds an instance of a quest to a quester's list. If the quest's maxTimes are reached, /// deletes the quest from the giver. Otherwise starts cooldown timer until it can be /// given again. /// </summary> /// <param name="quest">Quest to give to quester.</param> /// <param name="questerQuestListContainer">Quester's quest list container.</param> public virtual void GiveQuestToQuester(Quest quest, QuestListContainer questerQuestListContainer) { if (quest == null) { return; } if (questerQuestListContainer == null) { Debug.LogWarning("Quest Machine: " + name + ".GiveQuestToQuester - quester (QuestListContainer) is null.", this); return; } var questerTextInfo = new QuestParticipantTextInfo(QuestMachineMessages.GetID(questerQuestListContainer.gameObject), QuestMachineMessages.GetDisplayName(questerQuestListContainer.gameObject), null, null); GiveQuestToQuester(quest, questerTextInfo, questerQuestListContainer); }
public virtual void Repaint(QuestListContainer questListContainer) { if (!isVisible) { return; } this.questListContainer = questListContainer; if (!(enabled && gameObject.activeInHierarchy)) { return; } if (m_refreshCoroutine == null) { m_refreshCoroutine = StartCoroutine(RefreshAtEndOfFrame()); } }
public void SelectQuest(Quest quest, QuestListContainer questListContainer, int questListIndex) { m_quest = quest; m_questSerializedObject = (quest != null) ? new SerializedObject(quest) : null; var questInstanceID = (quest != null) ? quest.GetInstanceID() : 0; if (quest != null && questInstanceID != m_questInstanceID) { m_selectedNodeListIndex = -1; } m_questInstanceID = questInstanceID; m_questListContainerInstanceID = (questListContainer != null) ? questListContainer.GetInstanceID() : 0; m_selectedQuestListContainer = questListContainer; m_questListIndex = questListIndex; m_canvasGUI.AssignQuest(quest); #if DEBUG_QUEST_EDITOR Debug.Log("<color=magenta>QuestEditorWindow.SelectQuest: quest=" + quest + " [instanceID=" + questInstanceID + ", isAsset=" + ((quest != null) ? (!quest.isInstance).ToString() : "NA") + "], questListContainer=" + questListContainer + " [instanceID=" + m_questListContainerInstanceID + "], questListIndex=" + questListIndex + "</color>"); #endif CheckQuestFileVersion(); }
public virtual void Show(QuestListContainer questListContainer) { Show(); Repaint(questListContainer); }
public SwitchQuestData(QuestListContainer questListContainer, int questIndex) { this.questListContainer = questListContainer; this.questIndex = questIndex; }
private void Awake() { questListContainer = GetComponent <QuestListContainer>(); }
/// <summary> /// Adds an instance of a quest to a quester's list. If the quest's maxTimes are reached, /// deletes the quest from the giver. Otherwise starts cooldown timer until it can be /// given again. /// </summary> /// <param name="quest">Quest to give to quester.</param> /// <param name="questerTextInfo">Quester's text info.</param> /// <param name="questerQuestListContainer">Quester's quest list container.</param> public virtual void GiveQuestToQuester(Quest quest, QuestParticipantTextInfo questerTextInfo, QuestListContainer questerQuestListContainer) { if (quest == null) { Debug.LogWarning("Quest Machine: " + name + ".GiveQuestToQuester - quest is null.", this); return; } if (questerTextInfo == null) { Debug.LogWarning("Quest Machine: " + name + ".GiveQuestToQuester - questerTextInfo is null.", this); return; } if (questerQuestListContainer == null) { Debug.LogWarning("Quest Machine: " + name + ".GiveQuestToQuester - questerQuestListContainer is null.", this); return; } // Make a copy of the quest for the quester: var questInstance = quest.Clone(); // Update the version on this QuestGiver: quest.timesAccepted++; if (quest.timesAccepted >= quest.maxTimes) { DeleteQuest(quest.id); } else { quest.StartCooldown(); } // Add the copy to the quester and activate it: questInstance.AssignQuestGiver(myQuestGiverTextInfo); questInstance.AssignQuester(questerTextInfo); questInstance.timesAccepted = 1; if (questerQuestListContainer.questList.Count > 0) { for (int i = questerQuestListContainer.questList.Count - 1; i >= 0; i--) { var inJournal = questerQuestListContainer.questList[i]; if (inJournal == null) { continue; } if (StringField.Equals(inJournal.id, quest.id) && inJournal.GetState() != QuestState.Active) { questInstance.timesAccepted++; questerQuestListContainer.DeleteQuest(inJournal); } } } questerQuestListContainer.deletedStaticQuests.Remove(StringField.GetStringValue(questInstance.id)); questerQuestListContainer.AddQuest(questInstance); questInstance.SetState(QuestState.Active); QuestMachineMessages.RefreshIndicators(questInstance); }