예제 #1
0
        private void DrawStateInfo(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            var foldout    = QuestEditorPrefs.GetStateInfoFoldout(0);
            var newFoldout = QuestEditorUtility.EditorGUILayoutFoldout("States", "Content specific to each state that the quest can be in.", foldout);

            if (newFoldout != foldout)
            {
                QuestEditorPrefs.ToggleStateInfoFoldout(0);
            }
            if (!newFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("This section contains information specific to each state that the quest can be in.", MessageType.None);
                var stateInfoListProperty = serializedObject.FindProperty("m_stateInfoList");
                UnityEngine.Assertions.Assert.IsNotNull(stateInfoListProperty, "Quest Machine: Internal error - m_stateInfoList is null.");
                if (stateInfoListProperty == null)
                {
                    return;
                }
                if (stateInfoListProperty.arraySize == 0)
                {
                    stateInfoListProperty.arraySize = System.Enum.GetNames(typeof(QuestState)).Length;
                }
                if (m_inactiveStateInfoInspectorGUI == null)
                {
                    m_inactiveStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_activeStateInfoInspectorGUI == null)
                {
                    m_activeStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_successfulStateInfoInspectorGUI == null)
                {
                    m_successfulStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_failedStateInfoInspectorGUI == null)
                {
                    m_failedStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_abandonedStateInfoInspectorGUI == null)
                {
                    m_abandonedStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                m_inactiveStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.WaitingToStart), 0, QuestState.WaitingToStart);
                m_activeStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Active), 0, QuestState.Active);
                m_successfulStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Successful), 0, QuestState.Successful);
                m_failedStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Failed), 0, QuestState.Failed);
                m_abandonedStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Abandoned), 0, QuestState.Abandoned);
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
 private void DrawUrgencyFunctionList()
 {
     QuestEditorPrefs.entityTypeUrgencyFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Urgency Functions", "Factors that indicate how urgent it is for the quest giver to generate a quest about this entity type.", QuestEditorPrefs.entityTypeUrgencyFoldout);
     if (!QuestEditorPrefs.entityTypeUrgencyFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         if (m_urgencyFunctionList.count == 0)
         {
             EditorGUILayout.HelpBox("Factors that indicate how urgent it is for the quest giver to generate a quest about this entity type. If you want quest givers to be able to generate a quest about this entity type, add at least one urgency function.", MessageType.Info);
         }
         else
         {
             EditorGUILayout.HelpBox("Factors that indicate how urgent it is for the quest giver to generate a quest about this entity type.", MessageType.None);
         }
         m_urgencyFunctionList.DoLayoutList();
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
 }
예제 #3
0
 private void DrawEffects()
 {
     QuestEditorPrefs.actionEffectsFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Effects", "Effects are the changes to the world state that this action causes.", QuestEditorPrefs.actionEffectsFoldout);
     if (!QuestEditorPrefs.actionEffectsFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         if (m_effectsList.count == 0)
         {
             EditorGUILayout.HelpBox("Changes to the world state that this action causes. If you want this action to represent a change in the world state, add at least one action.", MessageType.Info);
         }
         else
         {
             EditorGUILayout.HelpBox("Changes to the world state that this action causes. ", MessageType.None);
         }
         m_effectsList.DoLayoutList();
         EditorGUILayout.Space();
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
 }
예제 #4
0
 private void DrawRequirements()
 {
     QuestEditorPrefs.actionRequirementsFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Requirements", "Requirements are the world states that must already exist before this action can be undertaken.", QuestEditorPrefs.actionRequirementsFoldout);
     if (!QuestEditorPrefs.actionRequirementsFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         if (m_requirementsList.count == 0)
         {
             EditorGUILayout.HelpBox("World states that must already exist before this action can be undertaken. If any specific world states are required before this action can be done, add them below.", MessageType.None);
         }
         else
         {
             EditorGUILayout.HelpBox("World states that must already exist before this action can be undertaken.", MessageType.None);
         }
         m_requirementsList.DoLayoutList();
         EditorGUILayout.Space();
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
 }
 private void DrawActionList()
 {
     QuestEditorPrefs.entityTypeActionsFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Actions", "Actions that can be done to this entity type.", QuestEditorPrefs.entityTypeActionsFoldout);
     if (!QuestEditorPrefs.entityTypeActionsFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         if (m_actionList.count == 0)
         {
             EditorGUILayout.HelpBox("Actions that can be done to this entity type. If you want quest givers to be able to ask the player to do something to this entity type in a quest, add at least one action. Actions defined on this entity type's parents can also be done to this entity type.", MessageType.Info);
         }
         else
         {
             EditorGUILayout.HelpBox("Actions that can be done to this entity type. Actions defined on this entity type's parents can also be done to this entity type.", MessageType.None);
         }
         m_actionList.DoLayoutList();
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
     EditorGUILayout.PropertyField(serializedObject.FindProperty("m_maxCountInAction"));
 }
예제 #6
0
        private void DrawUI()
        {
            QuestEditorPrefs.questListUIFoldout = QuestEditorUtility.EditorGUILayoutFoldout("UI Settings", "UIs to use.", QuestEditorPrefs.questListUIFoldout);
            if (!QuestEditorPrefs.questListUIFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                var questJournalUIProperty           = serializedObject.FindProperty("m_questJournalUI");
                var questHUDProperty                 = serializedObject.FindProperty("m_questHUD");
                var onlyTrackOneQuestAtATimeProperty = serializedObject.FindProperty("m_onlyTrackOneQuestAtATime");
                if (questJournalUIProperty != null)
                {
                    IQuestJournalUIInspectorFieldAttributeDrawer.DoLayout(questJournalUIProperty,
                                                                          new GUIContent("Quest Journal UI", "The Quest Journal UI to use. If unassigned, use the default journal UI."));
                }
                if (questHUDProperty != null)
                {
                    IQuestHUDInspectorFieldAttributeDrawer.DoLayout(questHUDProperty,
                                                                    new GUIContent("Quest HUD", "The Quest HUD to use. If unassigned, use the default HUD."));
                }
                if (onlyTrackOneQuestAtATimeProperty != null)
                {
                    EditorGUILayout.PropertyField(onlyTrackOneQuestAtATimeProperty);
                }
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #7
0
        private void DrawMainInfo(SerializedObject serializedObject, SerializedProperty nodeProperty)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");

            QuestEditorPrefs.nodeMainInfoFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Quest Node Info", "Quest node main info.", QuestEditorPrefs.nodeMainInfoFoldout);
            if (!QuestEditorPrefs.nodeMainInfoFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                var idProperty           = nodeProperty.FindPropertyRelative("m_id");
                var internalNameProperty = nodeProperty.FindPropertyRelative("m_internalName");
                var stateProperty        = nodeProperty.FindPropertyRelative("m_state");
                var nodeTypeProperty     = nodeProperty.FindPropertyRelative("m_nodeType");
                var isOptionalProperty   = nodeProperty.FindPropertyRelative("m_isOptional");
                var speakerProperty      = nodeProperty.FindPropertyRelative("m_speaker");
                UnityEngine.Assertions.Assert.IsNotNull(idProperty, "Quest Machine: Internal error - m_id is null.");
                UnityEngine.Assertions.Assert.IsNotNull(internalNameProperty, "Quest Machine: Internal error - m_internalName is null.");
                UnityEngine.Assertions.Assert.IsNotNull(stateProperty, "Quest Machine: Internal error - m_state is null.");
                UnityEngine.Assertions.Assert.IsNotNull(nodeTypeProperty, "Quest Machine: Internal error - m_nodeType is null.");
                UnityEngine.Assertions.Assert.IsNotNull(isOptionalProperty, "Quest Machine: Internal error - m_isOptional is null.");
                UnityEngine.Assertions.Assert.IsNotNull(isOptionalProperty, "Quest Machine: Internal error - m_speaker is null.");
                if (idProperty == null || internalNameProperty == null || nodeTypeProperty == null ||
                    isOptionalProperty == null || speakerProperty == null || stateProperty == null)
                {
                    return;
                }

                EditorGUILayout.PropertyField(idProperty, true);
                EditorGUILayout.PropertyField(internalNameProperty, true);
                var prevState = stateProperty.enumValueIndex;
                EditorGUILayout.PropertyField(stateProperty, new GUIContent("Current State", "Current state of this node."));
                var newState = stateProperty.enumValueIndex;
                if (Application.isPlaying && newState != prevState)
                {
                    // State changed in editor at runtime. Perform runtime state change with all the associated processing:
                    stateProperty.enumValueIndex = prevState;
                    serializedObject.ApplyModifiedProperties();
                    var questNode = QuestEditorWindow.selectedQuest.nodeList[QuestEditorWindow.selectedNodeListIndex];
                    questNode.SetState((QuestNodeState)newState);
                    serializedObject.Update();
                }
                var nodeType = (QuestNodeType)nodeTypeProperty.enumValueIndex;
                if (nodeType == QuestNodeType.Passthrough || nodeType == QuestNodeType.Condition)
                {
                    EditorGUILayout.PropertyField(isOptionalProperty);
                }
                EditorGUILayout.PropertyField(speakerProperty);
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #8
0
        private void DrawStateInfo(SerializedObject serializedObject, SerializedProperty nodeProperty, int nodeIndex)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            UnityEngine.Assertions.Assert.IsNotNull(nodeProperty, "Quest Machine: Internal error - nodeProperty is null.");

            //if (GUILayout.Button(new GUIContent("States", "Settings specific to each state that the quest node can be in."), GUI.skin.GetStyle(QuestEditorStyles.CollapsibleHeaderButtonStyleName)))
            //{
            //    QuestEditorPrefs.ToggleStateInfoFoldout(nodeIndex);
            //}
            //if (!QuestEditorPrefs.GetStateInfoFoldout(nodeIndex)) return;

            var foldout    = QuestEditorPrefs.GetStateInfoFoldout(nodeIndex);
            var newFoldout = QuestEditorUtility.EditorGUILayoutFoldout("States", "Settings specific to each state that the quest node can be in.", foldout);

            if (newFoldout != foldout)
            {
                QuestEditorPrefs.ToggleStateInfoFoldout(nodeIndex);
            }
            if (!newFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("This section contains information specific to each state that the node can be in.", MessageType.None);

                var stateInfoListProperty = nodeProperty.FindPropertyRelative("m_stateInfoList");
                if (stateInfoListProperty.arraySize == 0)
                {
                    stateInfoListProperty.arraySize = System.Enum.GetNames(typeof(QuestNodeState)).Length;
                }

                if (inactiveStateInfoInspectorGUI == null)
                {
                    inactiveStateInfoInspectorGUI = new QuestNodeStateInfoInspectorGUI();
                }
                if (activeStateInfoInspectorGUI == null)
                {
                    activeStateInfoInspectorGUI = new QuestNodeStateInfoInspectorGUI();
                }
                if (trueStateInfoInspectorGUI == null)
                {
                    trueStateInfoInspectorGUI = new QuestNodeStateInfoInspectorGUI();
                }
                inactiveStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestNodeState.Inactive), nodeIndex, QuestNodeState.Inactive);
                activeStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestNodeState.Active), nodeIndex, QuestNodeState.Active);
                trueStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestNodeState.True), nodeIndex, QuestNodeState.True);
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #9
0
        protected virtual void DrawOtherSettings()
        {
            QuestEditorPrefs.questListContainerOtherSettingsFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Other Settings", "Miscellaneous settings.", QuestEditorPrefs.questListContainerOtherSettingsFoldout);
            if (!QuestEditorPrefs.questListContainerOtherSettingsFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                DrawOtherSettingsInterior();
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #10
0
 private void DrawParentList()
 {
     QuestEditorPrefs.entityTypeParentsFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Parents", "Parent entity types from which this entity type inherits urgency functions, actions, and drive values.", QuestEditorPrefs.entityTypeParentsFoldout);
     if (!QuestEditorPrefs.entityTypeParentsFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         EditorGUILayout.HelpBox("Parent entity types from which this entity type inherits urgency functions, actions, and drive values.", MessageType.None);
         m_parentList.DoLayoutList();
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
 }
예제 #11
0
        private void DrawDialogueContent()
        {
            QuestEditorPrefs.questGiverDialogueContentFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Dialogue Content", "Quest giver-specific dialogue content.", QuestEditorPrefs.questGiverDialogueContentFoldout);
            if (!QuestEditorPrefs.questGiverDialogueContentFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                var questDialogueUIProperty   = serializedObject.FindProperty("m_questDialogueUI");
                var noQuestsContentsProperty  = serializedObject.FindProperty("m_noQuestsUIContents");
                var offerableContentsProperty = serializedObject.FindProperty("m_offerableQuestsUIContents");
                var activeContentsProperty    = serializedObject.FindProperty("m_activeQuestsUIContents");
                var completedModeProperty     = serializedObject.FindProperty("m_completedQuestDialogueMode");
                if (questDialogueUIProperty != null)
                {
                    IQuestDialogueUIInspectorFieldAttributeDrawer.DoLayout(questDialogueUIProperty,
                                                                           new GUIContent("Quest Dialogue UI", "The Quest Dialogue UI to use when conversing with the player. If unassigned, uses the default dialogue UI."));
                }
                if (completedModeProperty != null)
                {
                    EditorGUILayout.PropertyField(completedModeProperty, true);
                }
                if (noQuestsContentsProperty != null)
                {
                    EditorGUILayout.PropertyField(noQuestsContentsProperty, true);                                   //noQuestsContentGUI.Draw(serializedObject, noQuestsContentsProperty, false);
                }
                if (offerableContentsProperty != null)
                {
                    EditorGUILayout.PropertyField(offerableContentsProperty, true);                                    //offerableQuestsContentGUI.Draw(serializedObject, offerableContentsProperty, false);
                }
                if (activeContentsProperty != null)
                {
                    EditorGUILayout.PropertyField(activeContentsProperty, true);                                 //activeQuestsContentGUI.Draw(serializedObject, activeContentsProperty, false);
                }
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #12
0
        private void DrawDriveValueList()
        {
            QuestEditorPrefs.entityTypeDriveFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Drive Values", "Drive values associated with this entity type.", QuestEditorPrefs.entityTypeDriveFoldout);
            if (!QuestEditorPrefs.entityTypeDriveFoldout)
            {
                return;
            }
            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();

                EditorGUILayout.HelpBox("Drive values associated with this entity type. Drive values influence how entities are used in quests. Design-time values are shown below, not runtime values.", MessageType.None);
                m_driveValueList.DoLayoutList();
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #13
0
        protected virtual void DrawSaveSettings()
        {
            QuestEditorPrefs.questListContainerSaveSettingsFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Save Settings", "What to include in saved games.", QuestEditorPrefs.questListContainerSaveSettingsFoldout);
            if (!QuestEditorPrefs.questListContainerSaveSettingsFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_includeInSavedGameData"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_saveAcrossSceneChanges"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_key"), new GUIContent("Save Key"));
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #14
0
        private void DrawConnectionInfo(SerializedObject serializedObject, SerializedProperty nodeProperty)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            UnityEngine.Assertions.Assert.IsNotNull(nodeProperty, "Quest Machine: Internal error - nodeProperty is null.");

            // Only applicable to Condition nodes:
            var nodeTypeProperty = nodeProperty.FindPropertyRelative("m_nodeType");

            UnityEngine.Assertions.Assert.IsNotNull(nodeTypeProperty, "Quest Machine: Internal error - m_nodeType is null.");
            if (nodeTypeProperty == null)
            {
                return;
            }
            var nodeType = (QuestNodeType)nodeTypeProperty.enumValueIndex;

            if (nodeType != QuestNodeType.Condition)
            {
                return;
            }

            QuestEditorPrefs.trueConnectionFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Conditions", "Conditions that must be true for the node to become true.", QuestEditorPrefs.trueConnectionFoldout);
            if (!QuestEditorPrefs.trueConnectionFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("The conditions below must be true for the node to become true.", MessageType.None);
                if (questConditionsInspectorGUI == null)
                {
                    questConditionsInspectorGUI = new QuestConditionSetInspectorGUI();
                }
                questConditionsInspectorGUI.Draw(nodeProperty.FindPropertyRelative("m_conditionSet"));
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #15
0
 private void DrawText()
 {
     QuestEditorPrefs.actionTextFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Task Text", "The text shown to the player when this action is used in a quest.", QuestEditorPrefs.actionTextFoldout);
     if (!QuestEditorPrefs.actionTextFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         EditorGUILayout.HelpBox("The quest giver uses Task Text to ask the player to do this action. If you include words in braces like {this} they will be substituted by the quest giver's dialect table. Other valid tags:\n{TARGETDESCRIPTOR}: Action's target.\n{DOMAIN}: Target's domain.\n{#COUNTERNAME}: Counter name for task completion.\n{#COUNTERGOAL}: Goal value for counter.", MessageType.None);
         var actionTextProperty = serializedObject.FindProperty("m_actionText");
         if (actionTextProperty == null)
         {
             return;
         }
         EditorGUI.indentLevel++;
         s_activeTextFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Active", "Show this text when the quest is active. Optionally specify message to send when node becomes active; use ':' to separate message and parameter.", s_activeTextFoldout, false);
         if (s_activeTextFoldout)
         {
             EditorGUILayout.PropertyField(actionTextProperty.FindPropertyRelative("m_activeText"));
             EditorGUILayout.PropertyField(serializedObject.FindProperty("m_sendMessageOnActive"));
         }
         s_completedTextFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Completed", "Show this text when the quest is completed. Optionally specify message to send when node is completed; use ':' to separate message and parameter.", s_completedTextFoldout, false);
         if (s_completedTextFoldout)
         {
             EditorGUILayout.PropertyField(actionTextProperty.FindPropertyRelative("m_completedText"));
             EditorGUILayout.PropertyField(actionTextProperty.FindPropertyRelative("m_successText"));
             EditorGUILayout.PropertyField(serializedObject.FindProperty("m_sendMessageOnCompletion"));
         }
         EditorGUI.indentLevel--;
         EditorGUILayout.Space();
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
 }
예제 #16
0
 private void DrawRewardMultipliers()
 {
     QuestEditorPrefs.entityTypeRewardMultipliersFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Reward Multipliers", "Scale points used to give rewards.", QuestEditorPrefs.entityTypeRewardMultipliersFoldout);
     if (!QuestEditorPrefs.entityTypeRewardMultipliersFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         EditorGUILayout.HelpBox("Reward systems give rewards based on an entity's level. Using the multipliers below, " +
                                 "entities can scale reward points. For example, a boss enemy might scale Currency by 10 x its level.", MessageType.None);
         var multipliers = serializedObject.FindProperty("m_rewardMultipliers");
         for (int i = 0; i < multipliers.arraySize; i++)
         {
             EditorGUILayout.PropertyField(multipliers.GetArrayElementAtIndex(i), new GUIContent(((RewardMultiplier)i).ToString()), true);
         }
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
 }
예제 #17
0
        protected void DrawID(string tooltip) // Only used for specific subclasses.
        {
            QuestEditorPrefs.questGiverIDFoldout = QuestEditorUtility.EditorGUILayoutFoldout("ID", tooltip, QuestEditorPrefs.questGiverIDFoldout);
            if (!QuestEditorPrefs.questGiverIDFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                var idProperty          = serializedObject.FindProperty("m_id");
                var displayNameProperty = serializedObject.FindProperty("m_displayName");
                var imageProperty       = serializedObject.FindProperty("m_image");
                var textTableProperty   = serializedObject.FindProperty("m_textTable");
                if (idProperty != null)
                {
                    EditorGUILayout.PropertyField(idProperty);
                }
                if (displayNameProperty != null)
                {
                    EditorGUILayout.PropertyField(displayNameProperty);
                }
                if (imageProperty != null)
                {
                    EditorGUILayout.PropertyField(imageProperty);
                }
                if (textTableProperty != null)
                {
                    EditorGUILayout.PropertyField(textTableProperty);
                }
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #18
0
        private void DrawCounters(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            QuestEditorPrefs.countersFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Counters", "Counters used in this quest.", QuestEditorPrefs.countersFoldout);
            if (!QuestEditorPrefs.countersFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("Quest nodes can track activity using any counters you define below. Examples include counters to track the number collected of a specific item, number of enemies defeated, number of levers pulled, etc.", MessageType.None);
                if (m_counterListInspectorGUI == null)
                {
                    m_counterListInspectorGUI = new QuestCounterListInspectorGUI();
                }
                m_counterListInspectorGUI.Draw(serializedObject, serializedObject.FindProperty("m_counterList"));
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #19
0
        private void DrawAutostartConditions(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            QuestEditorPrefs.autostartFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Autostart", "Conditions that autostart the quest when true.", QuestEditorPrefs.autostartFoldout);
            if (!QuestEditorPrefs.autostartFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("If you specify conditions below, then the quest will automatically become active when the conditions become true.", MessageType.None);
                if (m_autostartConditionSetInspectorGUI == null)
                {
                    m_autostartConditionSetInspectorGUI = new QuestConditionSetInspectorGUI();
                }
                m_autostartConditionSetInspectorGUI.Draw(serializedObject.FindProperty("m_autostartConditionSet"));
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #20
0
        protected virtual void DrawQuestList()
        {
            if (!(0 <= questReorderableList.index && questReorderableList.index <= questReorderableList.count))
            {
                questReorderableList.index = 0;
                SetQuestInEditorWindow(questReorderableList.index);
            }

            questListFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Quests", "Quests on this GameObject.", questListFoldout);
            if (!questListFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                questReorderableList.DoLayoutList();
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #21
0
        private void DrawOfferConditions(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            QuestEditorPrefs.offerFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Offer", "Conditions that must be true before the quest giver can offer the quest.", QuestEditorPrefs.offerFoldout);
            if (!QuestEditorPrefs.offerFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("If you specify conditions below, then they must be true before the quest giver can offer the quest.", MessageType.None);
                if (m_offerConditionSetInspectorGUI == null)
                {
                    m_offerConditionSetInspectorGUI = new QuestConditionSetInspectorGUI();
                }
                m_offerConditionSetInspectorGUI.Draw(serializedObject.FindProperty("m_offerConditionSet"));
                if (m_offerConditionsUnmetContentListDrawer == null)
                {
                    m_offerConditionsUnmetContentListDrawer =
                        new QuestContentListInspectorGUI(new GUIContent("Offer Conditions Unmet Text", "Show this dialogue content when the offer conditions are unmet."), QuestContentCategory.OfferConditionsUnmet);
                }
                if (m_offerContentListDrawer == null)
                {
                    m_offerContentListDrawer =
                        new QuestContentListInspectorGUI(new GUIContent("Offer Text", "Show this dialogue text to offer the quest to the player."), QuestContentCategory.Offer);
                }
                m_offerConditionsUnmetContentListDrawer.Draw(serializedObject, serializedObject.FindProperty("m_offerConditionsUnmetContentList"), true);
                m_offerContentListDrawer.Draw(serializedObject, serializedObject.FindProperty("m_offerContentList"), true);
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #22
0
        private void DrawNodes(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            QuestEditorPrefs.nodesFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Node Order for UIs", "Order in which nodes provide their contributions to UI output.", QuestEditorPrefs.nodesFoldout);
            if (!QuestEditorPrefs.nodesFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("Nodes will provide their contributions to UI output in the order below.", MessageType.None);
                if (m_nodeOrderInspectorGUI == null)
                {
                    m_nodeOrderInspectorGUI = new QuestNodeOrderInspectorGUI();
                }
                m_nodeOrderInspectorGUI.Draw(serializedObject);
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #23
0
        private void DrawMotives()
        {
            QuestEditorPrefs.actionMotivesFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Motives", "Choices of motive text shown to the player when this action is the primary goal of a quest, and the drive values that help quest givers choose which motives fit them best.", QuestEditorPrefs.actionMotivesFoldout);
            if (!QuestEditorPrefs.actionMotivesFoldout)
            {
                return;
            }
            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("The quest giver uses Motive Text if this is the primary action of the quest. If you include words in braces like {this} they will be substituted by the quest giver's dialect table.", MessageType.None);
                var motivesProperty = serializedObject.FindProperty("m_motives");
                if (motivesProperty == null)
                {
                    return;
                }
                int  indexToDelete = -1;
                bool addNewMotive  = false;
                for (int i = 0; i < motivesProperty.arraySize; i++)
                {
                    var motiveProperty = motivesProperty.GetArrayElementAtIndex(i);
                    if (motiveProperty == null)
                    {
                        continue;
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Motive:", EditorStyles.boldLabel);
                    GUILayout.FlexibleSpace();
                    var isLastMotive = (i == motivesProperty.arraySize - 1);
                    if (isLastMotive)
                    {
                        if (GUILayout.Button("-", EditorStyles.miniButtonLeft, GUILayout.Width(30)))
                        {
                            indexToDelete = i;
                        }
                        if (i == motivesProperty.arraySize - 1 && GUILayout.Button("+", EditorStyles.miniButtonRight, GUILayout.Width(30)))
                        {
                            addNewMotive = true;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(30)))
                        {
                            indexToDelete = i;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(motiveProperty, GUIContent.none, true);
                    EditorGUILayout.EndHorizontal();
                }
                if (motivesProperty.arraySize == 0)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Add Motive", GUILayout.Width(80)))
                    {
                        addNewMotive = true;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (addNewMotive)
                {
                    motivesProperty.arraySize++;
                }
                if (indexToDelete != -1)
                {
                    motivesProperty.DeleteArrayElementAtIndex(indexToDelete);
                }
                EditorGUILayout.Space();
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
예제 #24
0
 private void DrawCompletionConditions()
 {
     QuestEditorPrefs.actionCompletionConditionsFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Completion Conditions", "The action is considered complete when these conditions are met.", QuestEditorPrefs.actionCompletionConditionsFoldout);
     if (!QuestEditorPrefs.actionCompletionConditionsFoldout)
     {
         return;
     }
     try
     {
         QuestEditorUtility.EditorGUILayoutBeginGroup();
         EditorGUILayout.HelpBox("The action is considered complete when these conditions are met.", MessageType.None);
         var completionProperty = serializedObject.FindProperty("m_completion");
         if (completionProperty == null)
         {
             return;
         }
         var modeProperty = completionProperty.FindPropertyRelative("m_mode");
         EditorGUILayout.PropertyField(modeProperty);
         if (modeProperty.enumValueIndex == (int)ActionCompletion.Mode.Message)
         {
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_senderID"), new GUIContent("Sender ID", "Required message sender ID, or any sender if blank. Can also be {QUESTERID} or {QUESTGIVERID}. Sender must have a Quest Giver or Entity component."), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_targetID"), new GUIContent("Target ID", "Required message target ID, or any target if blank. Can also be {QUESTERID} or {QUESTGIVERID}. Target must have a Quest Giver or Entity component."), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_message"), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_parameter"), true);
         }
         else
         {
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_baseCounterName"), new GUIContent("Base Counter Name", "Counter name. Entity name will be prefixed to counter name."), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_initialValue"), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_minValue"), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_maxValue"), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_counterValueMode"), true);
             EditorGUILayout.PropertyField(completionProperty.FindPropertyRelative("m_requiredValue"), true);
             var updateModeProperty = completionProperty.FindPropertyRelative("m_updateMode");
             EditorGUILayout.PropertyField(updateModeProperty, new GUIContent("Update Mode"), true);
             if (updateModeProperty.enumValueIndex == (int)QuestCounterUpdateMode.Messages)
             {
                 EditorGUI.indentLevel++;
                 int indexToDelete            = -1;
                 var messageEventListProperty = completionProperty.FindPropertyRelative("m_messageEventList");
                 UnityEngine.Assertions.Assert.IsNotNull(messageEventListProperty, "Quest Machine: Internal error - m_messageEventList is null.");
                 if (messageEventListProperty == null)
                 {
                     return;
                 }
                 for (int i = 0; i < messageEventListProperty.arraySize; i++)
                 {
                     var messageEventProperty = messageEventListProperty.GetArrayElementAtIndex(i);
                     var senderProperty       = messageEventProperty.FindPropertyRelative("m_senderID");
                     var targetProperty       = completionProperty.FindPropertyRelative("m_targetID");
                     var messageProperty      = messageEventProperty.FindPropertyRelative("m_message");
                     var parameterProperty    = messageEventProperty.FindPropertyRelative("m_parameter");
                     var operationProperty    = messageEventProperty.FindPropertyRelative("m_operation");
                     var literalValueProperty = messageEventProperty.FindPropertyRelative("m_literalValue");
                     if (senderProperty == null || targetProperty == null || messageProperty == null || parameterProperty == null ||
                         operationProperty == null || literalValueProperty == null)
                     {
                         return;
                     }
                     EditorGUILayout.PropertyField(senderProperty,
                                                   new GUIContent("Sender ID", "Required message sender ID, or any sender if blank. Can also be {QUESTERID} or {QUESTGIVERID}. Sender must have a Quest Giver or Entity component."), true);
                     EditorGUILayout.PropertyField(targetProperty,
                                                   new GUIContent("Target ID", "Required message target ID, or any target if blank. Can also be {QUESTERID} or {QUESTGIVERID}. Target must have a Quest Giver or Entity component."), true);
                     EditorGUILayout.PropertyField(messageProperty,
                                                   new GUIContent("Message", "When this message and the parameter below are sent, update the counter according to the operation below."), true);
                     EditorGUILayout.PropertyField(parameterProperty,
                                                   new GUIContent("Parameter", "When the message above and this parameter are sent, update the counter according to the operation below."), true);
                     EditorGUILayout.BeginHorizontal();
                     var operation = (QuestCounterMessageEvent.Operation)operationProperty.enumValueIndex;
                     if (operation == QuestCounterMessageEvent.Operation.ModifyByParameter || operation == QuestCounterMessageEvent.Operation.SetToParameter)
                     {
                         EditorGUILayout.PropertyField(operationProperty, GUIContent.none);
                     }
                     else
                     {
                         EditorGUILayout.PropertyField(operationProperty, GUIContent.none);
                         EditorGUILayout.PropertyField(literalValueProperty, GUIContent.none);
                     }
                     if (GUILayout.Button(new GUIContent("-", "Delete this message event.")))
                     {
                         indexToDelete = i;
                     }
                     EditorGUILayout.EndHorizontal();
                 }
                 if (indexToDelete != -1)
                 {
                     messageEventListProperty.DeleteArrayElementAtIndex(indexToDelete);
                 }
                 if (GUILayout.Button(new GUIContent("Add Message", "Add a new message event for the counter."), EditorStyles.miniButton))
                 {
                     messageEventListProperty.arraySize++;
                     var messageEventProperty = messageEventListProperty.GetArrayElementAtIndex(messageEventListProperty.arraySize - 1);
                     messageEventProperty.FindPropertyRelative("m_message").FindPropertyRelative("m_text").stringValue   = string.Empty;
                     messageEventProperty.FindPropertyRelative("m_parameter").FindPropertyRelative("m_text").stringValue = string.Empty;
                     messageEventProperty.FindPropertyRelative("m_senderID").FindPropertyRelative("m_text").stringValue  = string.Empty;
                     messageEventProperty.FindPropertyRelative("m_targetID").FindPropertyRelative("m_text").stringValue  = string.Empty;
                     messageEventProperty.FindPropertyRelative("m_operation").enumValueIndex = (int)QuestCounterMessageEvent.Operation.ModifyByLiteralValue;
                     messageEventProperty.FindPropertyRelative("m_literalValue").intValue    = 1;
                 }
             }
             EditorGUI.indentLevel--;
         }
     }
     finally
     {
         QuestEditorUtility.EditorGUILayoutEndGroup();
     }
 }
예제 #25
0
        private void DrawMainInfo(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            QuestEditorPrefs.mainInfoFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Quest Info", "Main quest info.", QuestEditorPrefs.mainInfoFoldout);
            if (!QuestEditorPrefs.mainInfoFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                var idProperty                   = serializedObject.FindProperty("m_id");
                var titleProperty                = serializedObject.FindProperty("m_title");
                var iconProperty                 = serializedObject.FindProperty("m_icon");
                var groupProperty                = serializedObject.FindProperty("m_group");
                var labelsProperty               = serializedObject.FindProperty("m_labels");
                var questGiverIDProperty         = serializedObject.FindProperty("m_questGiverID");
                var isTrackableProperty          = serializedObject.FindProperty("m_isTrackable");
                var showInTrackHUDProperty       = serializedObject.FindProperty("m_showInTrackHUD");
                var isAbandonableProperty        = serializedObject.FindProperty("m_isAbandonable");
                var rememberIfAbandonedProperty  = serializedObject.FindProperty("m_rememberIfAbandoned");
                var maxTimesProperty             = serializedObject.FindProperty("m_maxTimes");
                var timesAcceptedProperty        = serializedObject.FindProperty("m_timesAccepted");
                var cooldownSecondsProperty      = serializedObject.FindProperty("m_cooldownSeconds");
                var noRepeatIfSuccessfulProperty = serializedObject.FindProperty("m_noRepeatIfSuccessful");
                var stateProperty                = serializedObject.FindProperty("m_state");
                UnityEngine.Assertions.Assert.IsNotNull(idProperty, "Quest Machine: Internal error - m_id is null.");
                UnityEngine.Assertions.Assert.IsNotNull(titleProperty, "Quest Machine: Internal error - m_title is null.");
                UnityEngine.Assertions.Assert.IsNotNull(iconProperty, "Quest Machine: Internal error - m_icon is null.");
                UnityEngine.Assertions.Assert.IsNotNull(groupProperty, "Quest Machine: Internal error - m_group is null.");
                UnityEngine.Assertions.Assert.IsNotNull(labelsProperty, "Quest Machine: Internal error - m_labels is null.");
                UnityEngine.Assertions.Assert.IsNotNull(questGiverIDProperty, "Quest Machine: Internal error - m_questGiverID is null.");
                UnityEngine.Assertions.Assert.IsNotNull(isTrackableProperty, "Quest Machine: Internal error - m_isTrackable is null.");
                UnityEngine.Assertions.Assert.IsNotNull(showInTrackHUDProperty, "Quest Machine: Internal error - m_showInTrackHUD is null.");
                UnityEngine.Assertions.Assert.IsNotNull(isAbandonableProperty, "Quest Machine: Internal error - m_isAbandonable is null.");
                UnityEngine.Assertions.Assert.IsNotNull(rememberIfAbandonedProperty, "Quest Machine: Internal error - m_rememberIfAbandoned is null.");
                UnityEngine.Assertions.Assert.IsNotNull(maxTimesProperty, "Quest Machine: Internal error - m_maxTimes is null.");
                UnityEngine.Assertions.Assert.IsNotNull(timesAcceptedProperty, "Quest Machine: Internal error - m_timesAccepted is null.");
                UnityEngine.Assertions.Assert.IsNotNull(cooldownSecondsProperty, "Quest Machine: Internal error - m_cooldownSeconds is null.");
                UnityEngine.Assertions.Assert.IsNotNull(noRepeatIfSuccessfulProperty, "Quest Machine: Internal error - m_noRepeatIfSuccessful is null.");
                UnityEngine.Assertions.Assert.IsNotNull(stateProperty, "Quest Machine: Internal error - m_state is null.");
                if (idProperty == null || titleProperty == null || groupProperty == null || labelsProperty == null ||
                    iconProperty == null || questGiverIDProperty == null || isTrackableProperty == null || showInTrackHUDProperty == null ||
                    isAbandonableProperty == null || rememberIfAbandonedProperty == null || maxTimesProperty == null ||
                    timesAcceptedProperty == null || cooldownSecondsProperty == null || noRepeatIfSuccessfulProperty == null ||
                    stateProperty == null)
                {
                    return;
                }

                EditorGUILayout.PropertyField(idProperty, true);
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(titleProperty, true);
                EditorGUILayout.PropertyField(groupProperty, true);
                QuestEditorUtility.EditorGUILayoutBeginIndent();
                EditorGUILayout.PropertyField(labelsProperty, true);
                QuestEditorUtility.EditorGUILayoutEndIndent();
                EditorGUILayout.PropertyField(iconProperty);
                EditorGUILayout.PropertyField(questGiverIDProperty, true);
                EditorGUILayout.PropertyField(isTrackableProperty);
                if (isTrackableProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(showInTrackHUDProperty);
                }
                EditorGUILayout.PropertyField(isAbandonableProperty);
                if (isAbandonableProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(rememberIfAbandonedProperty);
                }
                EditorGUILayout.PropertyField(maxTimesProperty);
                if (maxTimesProperty.intValue > 1)
                {
                    EditorGUILayout.PropertyField(cooldownSecondsProperty);
                    EditorGUILayout.PropertyField(noRepeatIfSuccessfulProperty);
                }
                var prevState = stateProperty.enumValueIndex;
                EditorGUILayout.PropertyField(stateProperty, new GUIContent("Current State", "Current quest state."));
                var newState = stateProperty.enumValueIndex;
                if (Application.isPlaying && newState != prevState)
                {
                    // State changed in editor at runtime. Perform runtime state change with all the associated processing:
                    stateProperty.enumValueIndex = prevState;
                    serializedObject.ApplyModifiedProperties();
                    QuestEditorWindow.selectedQuest.SetState((QuestState)newState);
                    serializedObject.Update();
                }
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }