public void OnMessage(MessageArgs messageArgs) { if (QuestMachine.debug) { Debug.Log("Quest Machine: QuestCounter[" + name + "].OnMessage(" + messageArgs.message + ", " + messageArgs.parameter + ")", m_quest); } switch (messageArgs.message) { case DataSynchronizer.DataSourceValueChangedMessage: m_currentValue = messageArgs.intValue; break; case QuestMachineMessages.SetQuestCounterMessage: m_currentValue = messageArgs.intValue; break; case QuestMachineMessages.IncrementQuestCounterMessage: m_currentValue += messageArgs.intValue; break; default: if (messageEventList == null) { break; } for (int i = 0; i < messageEventList.Count; i++) { var messageEvent = messageEventList[i]; if (messageEvent != null && messageArgs.Matches(messageEvent.message, messageEvent.parameter) && QuestMachineMessages.IsRequiredID(messageArgs.sender, QuestMachineTags.ReplaceTags(messageEvent.senderID, m_quest)) && QuestMachineMessages.IsRequiredID(messageArgs.target, QuestMachineTags.ReplaceTags(messageEvent.targetID, m_quest))) { switch (messageEvent.operation) { case QuestCounterMessageEvent.Operation.ModifyByLiteralValue: m_currentValue += messageEvent.literalValue; break; case QuestCounterMessageEvent.Operation.ModifyByParameter: m_currentValue += messageArgs.intValue; break; case QuestCounterMessageEvent.Operation.SetToLiteralValue: m_currentValue = messageEvent.literalValue; break; case QuestCounterMessageEvent.Operation.SetToParameter: m_currentValue = messageArgs.intValue; break; } } } break; } SetValue(m_currentValue, QuestCounterSetValueMode.DontInformDataSync); }
/// <summary> /// Assigns a quest giver to the quest. /// </summary> /// <param name="questGiverTextInfo">Identifying information about the quest giver.</param> public void AssignQuestGiver(QuestParticipantTextInfo questGiverTextInfo) { if (questGiverTextInfo == null) { return; } questGiverID = questGiverTextInfo.id; if (!StringField.IsNullOrEmpty(questGiverTextInfo.id)) { speakers.Add(StringField.GetStringValue(questGiverTextInfo.id)); } QuestMachineTags.AddTagValuesToDictionary(tagDictionary, questGiverTextInfo.textTable); tagDictionary.SetTag(QuestMachineTags.QUESTGIVERID, questGiverTextInfo.id); tagDictionary.SetTag(QuestMachineTags.QUESTGIVER, questGiverTextInfo.displayName); }
public void SetListeners(bool enable) { if (!Application.isPlaying || (enable && m_isListening) || (!enable && !m_isListening)) { return; } m_isListening = enable; if (enable) { switch (updateMode) { case QuestCounterUpdateMode.DataSync: MessageSystem.AddListener(this, DataSynchronizer.DataSourceValueChangedMessage, name); break; case QuestCounterUpdateMode.Messages: MessageSystem.AddListener(this, QuestMachineMessages.SetQuestCounterMessage, name); MessageSystem.AddListener(this, QuestMachineMessages.IncrementQuestCounterMessage, name); break; default: if (Debug.isDebugBuild) { Debug.LogWarning("Quest Machine: Internal error. Unrecognized counter update mode '" + updateMode + "'. Please contact the developer.", m_quest); } break; } if (messageEventList != null) { for (int i = 0; i < messageEventList.Count; i++) { var messageEvent = messageEventList[i]; if (messageEvent != null) { MessageSystem.AddListener(this, QuestMachineTags.ReplaceTags(messageEvent.message, m_quest), QuestMachineTags.ReplaceTags(messageEvent.parameter, m_quest)); } } } } else { MessageSystem.RemoveListener(this); } }
private void OnWizardCreate() { QuestMachineTags.AddQuestTagsToTextTable(QuestEditorWindow.selectedQuest, textTable); Debug.Log("Quest Machine: Copied all tags mentioned in " + QuestEditorWindow.selectedQuest + " to " + textTable + ".", textTable); }
/// <summary> /// Adds any tags in the string to the tags dictionary. /// </summary> /// <param name="s"></param> protected virtual void AddTagsToDictionary(string s) { QuestMachineTags.AddTagsToDictionary(tagDictionary, s); }
/// <summary> /// Sets sub-objects' runtime references to this quest. /// </summary> public void SetRuntimeReferences() { // Set references in start info: if (Application.isPlaying) { m_timeCooldownLastChecked = GameTime.time; } if (autostartConditionSet != null) { autostartConditionSet.SetRuntimeReferences(this, null); } if (offerConditionSet != null) { offerConditionSet.SetRuntimeReferences(this, null); } QuestContent.SetRuntimeReferences(offerConditionsUnmetContentList, this, null); QuestContent.SetRuntimeReferences(offerContentList, this, null); // Set references in counters: if (counterList != null) { for (int i = 0; i < counterList.Count; i++) { counterList[i].SetRuntimeReferences(this); } } // Set references in state info: if (stateInfoList != null) { for (int i = 0; i < stateInfoList.Count; i++) { var stateInfo = QuestStateInfo.GetStateInfo(stateInfoList, (QuestState)i); if (stateInfo != null) { stateInfo.SetRuntimeReferences(this, null); } } } // Set references in nodes: if (nodeList != null) { for (int i = 0; i < nodeList.Count; i++) { if (nodeList[i] != null) { nodeList[i].InitializeRuntimeReferences(this); } } for (int i = 0; i < nodeList.Count; i++) { if (nodeList[i] != null) { nodeList[i].ConnectRuntimeNodeReferences(); } } for (int i = 0; i < nodeList.Count; i++) { if (nodeList[i] != null) { nodeList[i].SetRuntimeNodeReferences(); } } } // Record list of any nodes' speakers who aren't the quest giver: RecordSpeakersUsedInQuestAndAnyNodes(); // Add tags to dictionary: QuestMachineTags.AddTagsToDictionary(tagDictionary, title); QuestMachineTags.AddTagsToDictionary(tagDictionary, group); if (!StringField.IsNullOrEmpty(questGiverID)) { tagDictionary.SetTag(QuestMachineTags.QUESTGIVERID, questGiverID); } }