コード例 #1
0
        private static string ReplaceCounterTag(string s, CounterTagType tagType)
        {
            if (string.IsNullOrEmpty(s) || currentQuest == null)
            {
                return(s);
            }

            var counterName = (tagType == CounterTagType.Current || tagType == CounterTagType.AsTime) ? s.Substring(2, s.Length - 3).Trim()
                : s.Substring(3, s.Length - 4).Trim();

            // Look for counter in current quest:
            var counter = currentQuest.GetCounter(counterName);

            if (counter != null)
            {
                return(GetCounterTagValue(counter, tagType));
            }

            // Otherwise look for quest by ID:
            var index = counterName.IndexOf(CounterTagQuestNameSeparator);

            if (index > 0)
            {
                var questName = counterName.Substring(0, index);
                counterName = counterName.Substring(index + 1);
                var quest = QuestMachine.GetQuestInstance(questName);
                counter = (quest != null) ? quest.GetCounter(counterName) : null;
                if (counter != null)
                {
                    return(GetCounterTagValue(counter, tagType));
                }
            }
            return(s);
        }
コード例 #2
0
        private void AdjustCounter(int value, bool set)
        {
            var quest = QuestMachine.GetQuestInstance(questID);

            if (quest == null)
            {
                if (QuestMachine.debug)
                {
                    Debug.LogWarning("Quest Machine: Can't find quest with ID '" + questID + "' to adjust counter " + counterName + ".", this);
                }
                return;
            }
            var counter = quest.GetCounter(counterName);

            if (counter == null)
            {
                if (QuestMachine.debug)
                {
                    Debug.LogWarning("Quest Machine: Can't find counter " + counterName + " in quest '" + questID + "' to adjust its value.", this);
                }
                return;
            }
            if (set)
            {
                counter.currentValue = value;
            }
            else
            {
                counter.currentValue += value;;
            }
        }
コード例 #3
0
        public override void Execute()
        {
            var affectedQuest = StringField.IsNullOrEmpty(questID) ? this.quest : QuestMachine.GetQuestInstance(questID);

            if (affectedQuest == null)
            {
                return;
            }
            affectedQuest.SetQuestIndicatorState(runtimeEntityID, questIndicatorState);
        }
コード例 #4
0
        /// <summary>
        /// Sets the quest to a state. The quest is specified in the
        /// questID property.
        /// </summary>
        /// <param name="state">New state.</param>
        public void SetQuestState(QuestState state)
        {
            var quest = QuestMachine.GetQuestInstance(questID);

            if (quest == null)
            {
                if (QuestMachine.debug)
                {
                    Debug.LogWarning("Quest Machine: Can't find quest with ID '" + questID + "' to set its state.", this);
                }
                return;
            }
            quest.SetState(state);
        }
コード例 #5
0
        /// <summary>
        /// Sets the quest node to a state. The quest and quest node are specified
        /// in the questID and questNodeID properties.
        /// </summary>
        /// <param name="state">New state.</param>
        public void SetQuestNodeState(QuestNodeState state)
        {
            var quest = QuestMachine.GetQuestInstance(questID);

            if (quest == null)
            {
                if (QuestMachine.debug)
                {
                    Debug.LogWarning("Quest Machine: Can't find quest with ID '" + questID + "' to set the state of node with ID '" + questNodeID + "'.", this);
                }
                return;
            }
            var questNode = quest.GetNode(questNodeID);

            if (questNode == null)
            {
                if (QuestMachine.debug)
                {
                    Debug.LogWarning("Quest Machine: Can't find node with ID '" + questNodeID + "' in quest '" + questID + "' to set its state.", this);
                }
                return;
            }
            questNode.SetState(state);
        }