Exemplo n.º 1
0
        /// <summary>
        /// Adds actions to set up the quest giver's quest indicators to the return node.
        /// </summary>
        protected virtual void AddReturnNodeIndicators(QuestBuilder questBuilder, QuestNode returnNode, List <QuestAction> actionList, QuestEntity entity)
        {
            // Indicator when active:
            var indicatorAction = questBuilder.CreateSetIndicatorAction(questBuilder.quest.id, entity.id, QuestIndicatorState.Talk);

            actionList.Add(indicatorAction);

            // Indicator when true:
            indicatorAction = questBuilder.CreateSetIndicatorAction(questBuilder.quest.id, entity.id, QuestIndicatorState.None);
            actionList      = returnNode.GetStateInfo(QuestNodeState.True).actionList;
            actionList.Add(indicatorAction);
        }
Exemplo n.º 2
0
        protected virtual void AddCounterAndNode()
        {
            var quest = QuestEditorWindow.selectedQuest;

            if (quest == null)
            {
                return;
            }

            // Add counter:
            var existingCounter = quest.GetCounter(counterName); // Delete existing first.

            if (existingCounter != null)
            {
                quest.counterList.Remove(existingCounter);
            }
            var counter             = new QuestCounter(new StringField(counterName), Mathf.Max(0, min), min, max, QuestCounterUpdateMode.Messages);
            var messageAndParameter = incrementMessage.Split(':');

            counter.messageEventList.Add(new QuestCounterMessageEvent(new StringField(quest.id),
                                                                      new StringField(messageAndParameter[0]), new StringField(messageAndParameter[1]),
                                                                      QuestCounterMessageEvent.Operation.ModifyByLiteralValue, 1));
            quest.counterList.Add(counter);

            // Add a new node:
            var parentNode = GetParentNode(quest);

            if (parentNode == null)
            {
                return;
            }
            var node = new QuestNode(new StringField(string.Format(hudInstructionsText, min.ToString(), max.ToString())), new StringField(), QuestNodeType.Condition);

            quest.nodeList.Add(node);
            node.childIndexList.AddRange(parentNode.childIndexList);
            parentNode.childIndexList.Clear();
            parentNode.childIndexList.Add(quest.nodeList.Count - 1);
            node.canvasRect = new Rect(parentNode.canvasRect.x + QuestNode.DefaultNodeWidth + 20, parentNode.canvasRect.y, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight);

            // Add success node if specified:
            if (leadsToSuccess)
            {
                AddSuccessNode(quest, node);
            }

            // Set node's counter condition:
            var condition = ScriptableObjectUtility.CreateScriptableObject <CounterQuestCondition>();

            condition.name                 = "counterCondition";
            condition.counterIndex         = quest.GetCounterIndex(counterName);
            condition.counterValueMode     = CounterValueConditionMode.AtLeast;
            condition.requiredCounterValue = new QuestNumber(max);
            node.conditionSet.conditionList.Add(condition);
            AddAndSaveSubasset(condition);

            // Set node's UI content:
            var stateInfo = node.GetStateInfo(QuestNodeState.Active);

            var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD);

            AddBodyContent(hudContentList, hudInstructionsText);
            AddBodyContent(hudContentList, hudCountText);

            var journalContentList = stateInfo.GetContentList(QuestContentCategory.Journal);

            AddBodyContent(journalContentList, journalText);

            var dialogueContentList = stateInfo.GetContentList(QuestContentCategory.Dialogue);

            AddBodyContent(dialogueContentList, dialogueText);

            // Add alert action:
            if (!string.IsNullOrEmpty(hudInstructionsText))
            {
                var alertAction = ScriptableObjectUtility.CreateScriptableObject <AlertQuestAction>();
                AddBodyContent(alertAction.contentList, hudInstructionsText);
                stateInfo.actionList.Add(alertAction);
                AddAndSaveSubasset(alertAction);
            }

            // Update quest's internal references:
            quest.SetRuntimeReferences();

            // Refresh editor windows:
            QuestEditorWindow.RepaintNow();              // Quest Editor window.
            QuestEditorWindow.RepaintCurrentEditorNow(); // Inspector.
        }
Exemplo n.º 3
0
        protected virtual void AddMessageNode()
        {
            var quest = QuestEditorWindow.selectedQuest;

            if (quest == null)
            {
                return;
            }

            // Add a new node:
            var parentNode = GetParentNode(quest);

            if (parentNode == null)
            {
                return;
            }
            var node = new QuestNode(new StringField(hudText), new StringField(), QuestNodeType.Condition);

            quest.nodeList.Add(node);
            node.childIndexList.AddRange(parentNode.childIndexList);
            parentNode.childIndexList.Clear();
            parentNode.childIndexList.Add(quest.nodeList.Count - 1);
            node.canvasRect = new Rect(parentNode.canvasRect.x + QuestNode.DefaultNodeWidth + 20, parentNode.canvasRect.y, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight);

            // Add success node if specified:
            if (leadsToSuccess)
            {
                AddSuccessNode(quest, node);
            }

            // Set node's counter condition:
            var condition = ScriptableObjectUtility.CreateScriptableObject <MessageQuestCondition>();

            condition.name      = "messageCondition";
            condition.message   = new StringField(message);
            condition.parameter = new StringField(parameter);
            condition.value     = new MessageValue();
            node.conditionSet.conditionList.Add(condition);
            AddAndSaveSubasset(condition);

            // Set node's UI content:
            var stateInfo = node.GetStateInfo(QuestNodeState.Active);

            var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD);

            hudContentList.Add(CreateBodyContent(hudText));

            var journalContentList = stateInfo.GetContentList(QuestContentCategory.Journal);

            journalContentList.Add(CreateBodyContent(journalText));

            var dialogueContentList = stateInfo.GetContentList(QuestContentCategory.Dialogue);

            dialogueContentList.Add(CreateBodyContent(dialogueText));

            // Add alert action:
            var alertAction = ScriptableObjectUtility.CreateScriptableObject <AlertQuestAction>();

            alertAction.contentList.Add(CreateBodyContent(hudText));
            stateInfo.actionList.Add(alertAction);
            AddAndSaveSubasset(alertAction);

            // Update quest's internal references:
            quest.SetRuntimeReferences();

            // Refresh editor windows:
            QuestEditorWindow.RepaintNow();              // Quest Editor window.
            QuestEditorWindow.RepaintCurrentEditorNow(); // Inspector.
        }