예제 #1
0
        /// <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);
        }
예제 #2
0
 public void ClearQuestIndicatorStates()
 {
     if (indicatorStates == null)
     {
         return;
     }
     foreach (var kvp in indicatorStates)
     {
         MessageSystem.SendMessageWithTarget(this, kvp.Key, QuestMachineMessages.SetIndicatorStateMessage, id, QuestIndicatorState.None);
     }
     indicatorStates.Clear();
     QuestMachineMessages.RefreshIndicators(questGiverID);
 }