public void EqualsTest() { StringField a1 = new StringField(123, "a"); StringField aSame = a1; StringField a2 = new StringField(123, "a"); StringField diffValue = new StringField(123, "b"); StringField diffTag = new StringField(999, "a"); IField diffType = new CharField(123, 'a'); Assert.True(a1.Equals(aSame)); Assert.True(a1.Equals(a2)); Assert.False(a1.Equals(diffValue)); Assert.False(a1.Equals(diffTag)); Assert.False(a1.Equals(diffType)); }
/// <summary> /// Returns true if EntityListItemModel instances are equal /// </summary> /// <param name="other">Instance of EntityListItemModel to be compared</param> /// <returns>Boolean</returns> public bool Equals(EntityListItemModel other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( StringField == other.StringField || StringField != null && StringField.Equals(other.StringField) ) && ( RelationNameField == other.RelationNameField || RelationNameField != null && RelationNameField.Equals(other.RelationNameField) ) && ( IntegerField == other.IntegerField || IntegerField != null && IntegerField.Equals(other.IntegerField) )); }
void IMessageHandler.OnMessage(MessageArgs messageArgs) { if (!isChecking || messageArgs.values == null || messageArgs.values.Length < 2 || requiredQuestID == null) { return; } var questID = messageArgs.parameter; if (!StringField.Equals(requiredQuestID, questID)) { return; } var questNodeID = QuestMachineMessages.ArgToString(messageArgs.values[0]); if (!string.IsNullOrEmpty(questNodeID)) { return; } var stateValue = messageArgs.values[1]; var state = (stateValue != null && stateValue.GetType() == typeof(QuestState)) ? (QuestState)stateValue : QuestState.WaitingToStart; if (state == requiredState) { SetTrue(); } }
/// <summary> /// Looks up a node by its ID. /// </summary> public QuestNode GetNode(string questNodeID) { if (string.IsNullOrEmpty(questNodeID) || nodeList == null) { return(null); } return(nodeList.Find(x => StringField.Equals(StringField.GetStringValue(x.id), questNodeID))); }
/// <summary> /// Returns true if EntityViewModel instances are equal /// </summary> /// <param name="other">Instance of EntityViewModel to be compared</param> /// <returns>Boolean</returns> public bool Equals(EntityViewModel other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( StringField == other.StringField || StringField != null && StringField.Equals(other.StringField) ) && ( RelationIdField == other.RelationIdField || RelationIdField != null && RelationIdField.Equals(other.RelationIdField) ) && ( DictionaryField == other.DictionaryField || DictionaryField != null && DictionaryField.Equals(other.DictionaryField) ) && ( IntegerField == other.IntegerField || IntegerField != null && IntegerField.Equals(other.IntegerField) ) && ( DoubleField == other.DoubleField || DoubleField != null && DoubleField.Equals(other.DoubleField) ) && ( DateField == other.DateField || DateField != null && DateField.Equals(other.DateField) ) && ( ExampleType == other.ExampleType || ExampleType != null && ExampleType.Equals(other.ExampleType) ) && ( ExampleStatus == other.ExampleStatus || ExampleStatus != null && ExampleStatus.Equals(other.ExampleStatus) )); }
/// <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); }
public QuestCounter AddCounter(StringField counterName, int initialValue, int minValue, int maxValue, bool randomizeInitialValue, QuestCounterUpdateMode updateMode) { if (quest.counterList.Find(x => StringField.Equals(x.name, counterName)) != null) { if (Debug.isDebugBuild) { Debug.LogWarning("Quest Machine: Counter '" + counterName + "' already exists in QuestBuilder."); } return(null); } var counter = new QuestCounter(counterName, initialValue, minValue, maxValue, updateMode); quest.counterList.Add(counter); return(counter); }
public int GetCounterIndex(string counterName) { if (counterList == null) { return(-1); } for (int i = 0; i < counterList.Count; i++) { var counter = counterList[i]; if (counter != null && StringField.Equals(counter.name, counterName)) { return(i); } } return(-1); }
/// <summary> /// Gets a counter defined in this quest. /// </summary> /// <param name="counterName">The name of the counter defined in the quest.</param> /// <returns>The counter, or null if there is no counter with the specified name.</returns> public QuestCounter GetCounter(string counterName) { if (counterList == null) { return(null); } for (int i = 0; i < counterList.Count; i++) { var counter = counterList[i]; if (counter != null && StringField.Equals(counter.name, counterName)) { return(counter); } } return(null); }
public virtual void OnMessage(MessageArgs messageArgs) { var target = messageArgs.targetString; if (!(string.IsNullOrEmpty(target) || string.Equals(target, myID) || StringField.Equals(QuestMachineMessages.GetID(target), myID))) { return; } switch (messageArgs.message) { case QuestMachineMessages.SetIndicatorStateMessage: SetIndicatorState(messageArgs.parameter, (QuestIndicatorState)messageArgs.firstValue); break; case QuestMachineMessages.RefreshIndicatorMessage: case QuestMachineMessages.RefreshUIsMessage: Repaint(); break; } }
private bool IsContentValidForCurrentSpeaker(QuestContentCategory category) { // Non-dialogue content is always valid: if (category != QuestContentCategory.Dialogue) { return(true); } if (quest == null) { return(true); } // Are quest's current speaker and this node's speaker both the quest giver? if (quest.currentSpeaker == null) { return(StringField.IsNullOrEmpty(speaker) || StringField.Equals(speaker, quest.questGiverID)); } // Otherwise is quest's current speaker same as this node's speaker? return(StringField.Equals(speaker, quest.currentSpeaker.id)); }
public virtual void RefreshFromAllQuests() { InitializeStates(); var allQuests = QuestMachine.GetAllQuestInstances(); foreach (var kvp in allQuests) { var quests = kvp.Value; if (quests == null) { continue; } for (int i = 0; i < quests.Count; i++) { var quest = quests[i]; if (quest == null) { continue; } var questState = quest.GetState(); if (questState == QuestState.Active && quest.indicatorStates != null && quest.indicatorStates.ContainsKey(myID)) { // If the quest specifies an indicator for me, record it: var state = quest.indicatorStates[myID]; states[(int)state].Add(StringField.GetStringValue(quest.id)); } else if (questState == QuestState.WaitingToStart && StringField.Equals(quest.questGiverID, myID) && string.IsNullOrEmpty(quest.questerID)) { // Otherwise if it's offerable by me, record it: var state = quest.canOffer ? hasQuestToOfferState : hasQuestButCannotOfferState; states[(int)state].Add(StringField.GetStringValue(quest.id)); } } } ShowHighestPriorityIndicator(); }
/// <summary> /// Records quests in the player's QuestList that were given by this quest giver /// or active quests for which this quest giver has dialogue content. /// </summary> protected virtual void RecordRelevantPlayerQuests() { activeQuests.Clear(); completedQuests.Clear(); if (playerQuestListContainer == null || playerQuestListContainer.questList == null) { return; } for (int i = 0; i < playerQuestListContainer.questList.Count; i++) { var quest = playerQuestListContainer.questList[i]; if (quest == null) { continue; } var questState = quest.GetState(); if (StringField.Equals(quest.questGiverID, id)) { switch (questState) { case QuestState.Active: activeQuests.Add(quest); break; case QuestState.Successful: case QuestState.Failed: completedQuests.Add(quest); break; } } else if (questState == QuestState.Active && quest.speakers.Contains(StringField.GetStringValue(id))) { activeQuests.Add(quest); } } }
public static bool IsRequiredID(object obj, string id) { return(string.IsNullOrEmpty(id) || StringField.Equals(GetID(obj), id)); }
public bool IsSpeakerQuestGiver(QuestParticipantTextInfo speaker) { return((speaker == null) || StringField.Equals(speaker.id, questGiverID)); }