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();
     }
 }
Esempio n. 2
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();
     }
 }
        protected override void Draw()
        {
            if (serializedObject == null)
            {
                return;
            }
            var counterIndexProperty         = serializedObject.FindProperty("m_counterIndex");
            var counterValueModeProperty     = serializedObject.FindProperty("m_counterValueMode");
            var requiredCounterValueProperty = serializedObject.FindProperty("m_requiredCounterValue");

            UnityEngine.Assertions.Assert.IsNotNull(counterIndexProperty, "Quest Machine: Internal error - m_counterIndex is null.");
            UnityEngine.Assertions.Assert.IsNotNull(counterValueModeProperty, "Quest Machine: Internal error - m_counterValueMode is null.");
            UnityEngine.Assertions.Assert.IsNotNull(requiredCounterValueProperty, "Quest Machine: Internal error - m_requiredCounterValue is null.");
            if (counterIndexProperty == null || counterValueModeProperty == null || requiredCounterValueProperty == null)
            {
                Debug.LogError("Quest Machine: Internal error in CounterQuestConditionEditor. Please contact the developer.");
                return;
            }
            EditorGUILayout.HelpBox("This condition requires that the value of a counter defined in your quest meets a criteria such as being at least a specific amount.", MessageType.None);
            QuestEditorUtility.EditorGUILayoutCounterNamePopup(counterIndexProperty, m_nameList);
            EditorGUILayout.PropertyField(counterValueModeProperty);
            EditorGUILayout.PropertyField(requiredCounterValueProperty, true);
            if (GUILayout.Button("Refresh Counter Names"))
            {
                m_nameList = QuestEditorUtility.GetCounterNames();
            }
        }
Esempio n. 4
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();
            }
        }
Esempio n. 5
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();
            }
        }
        private void DrawImagesList()
        {
            QuestEditorPrefs.databaseImagesFoldout = QuestEditorUtility.EditorGUILayoutFoldout("EntityType Images", "Images used by procedural entity types. If you're not procedurally generating quests, you can ignore this section.", QuestEditorPrefs.databaseImagesFoldout);
            if (!QuestEditorPrefs.databaseImagesFoldout)
            {
                return;
            }

            serializedObject.Update();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_images"), true);
            serializedObject.ApplyModifiedProperties();
            try
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(new GUIContent("Scan EntityTypes...", "Adds images used by EntityTypes in a specified folder."), GUILayout.Width(128)))
                {
                    if (string.IsNullOrEmpty(entityTypeFolderPath))
                    {
                        entityTypeFolderPath = Application.dataPath;
                    }
                    entityTypeFolderPath = EditorUtility.OpenFolderPanel("Scan EntityTypes In", entityTypeFolderPath, string.Empty);
                    if (!string.IsNullOrEmpty(entityTypeFolderPath) && Directory.Exists(entityTypeFolderPath))
                    {
                        Undo.RecordObject(target, "Add EntityType Images");
                        ScanEntityTypesInFolder(entityTypeFolderPath);
                    }
                }
            }
            finally
            {
                EditorGUILayout.EndHorizontal();
            }
        }
Esempio n. 7
0
        public static Quest CreateNewQuestAssetFromDialog()
        {
            var filePath = EditorUtility.SaveFilePanel("Save Quest As", s_lastDirectory, string.Empty, "asset");

            if (string.IsNullOrEmpty(filePath))
            {
                return(null);
            }
            s_lastDirectory = System.IO.Path.GetDirectoryName(filePath);
            var questWrapperType = QuestEditorUtility.GetWrapperType(typeof(Quest));

            if (questWrapperType == null)
            {
                Debug.LogError("Quest Machine: Internal error. Can't access Quest type!");
                return(null);
            }
            var quest = ScriptableObjectUtility.CreateScriptableObject(questWrapperType) as Quest;

            if (quest == null)
            {
                Debug.LogError("Quest Machine: Internal error. Can't create Quest object!");
                return(null);
            }
            var filename = System.IO.Path.GetFileNameWithoutExtension(filePath);

            quest.id.value    = filename.Replace(" ", string.Empty);
            quest.title.value = filename;
            return(SaveQuestAsAsset(quest, filePath, false));
        }
 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"));
 }
Esempio n. 9
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();
     }
 }
 protected override void OnEnable()
 {
     base.OnEnable();
     if (target == null || serializedObject == null)
     {
         return;
     }
     m_nameList = QuestEditorUtility.GetCounterNames();
 }
Esempio n. 11
0
 private void ConfirmAndArrangeNodes()
 {
     if (!EditorUtility.DisplayDialog("Arrange Nodes", "Auto-layout nodes?", "OK", "Cancel"))
     {
         return;
     }
     QuestEditorUtility.ArrangeNodes(m_questSerializedObject.targetObject as Quest);
     QuestEditorWindow.RepaintNow();
 }
Esempio n. 12
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();
            }
        }
Esempio n. 13
0
        protected override void Draw()
        {
            if (serializedObject == null)
            {
                return;
            }
            serializedObject.Update();

            EditorGUILayout.HelpBox("This action sends a message to the Message System.", MessageType.None);

            var senderSpecifierProperty = serializedObject.FindProperty("m_senderSpecifier");
            var senderIDProperty        = serializedObject.FindProperty("m_senderID");
            var targetSpecifierProperty = serializedObject.FindProperty("m_targetSpecifier");
            var targetIDProperty        = serializedObject.FindProperty("m_targetID");
            var messageProperty         = serializedObject.FindProperty("m_message");
            var parameterProperty       = serializedObject.FindProperty("m_parameter");
            var valueProperty           = serializedObject.FindProperty("m_value");

            if (senderSpecifierProperty == null || senderIDProperty == null || targetSpecifierProperty == null || targetIDProperty == null ||
                messageProperty == null || parameterProperty == null || valueProperty == null)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(senderSpecifierProperty, new GUIContent("Sender", "Required message sender."), true);
            if (EditorGUI.EndChangeCheck())
            {
                QuestEditorUtility.SetMessageParticipantID(senderSpecifierProperty, senderIDProperty);
            }

            if (senderSpecifierProperty.enumValueIndex == (int)QuestMessageParticipant.Other)
            {
                EditorGUILayout.PropertyField(senderIDProperty,
                                              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);
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(targetSpecifierProperty, new GUIContent("Target", "Required message target."), true);
            if (EditorGUI.EndChangeCheck())
            {
                QuestEditorUtility.SetMessageParticipantID(targetSpecifierProperty, targetIDProperty);
            }

            if (targetSpecifierProperty.enumValueIndex == (int)QuestMessageParticipant.Other)
            {
                EditorGUILayout.PropertyField(targetIDProperty,
                                              new GUIContent("Target ID", "Required message target ID, or any sender if blank. Can also be {QUESTERID} or {QUESTGIVERID}. Target must have a Quest Giver or Entity component."), true);
            }

            EditorGUILayout.PropertyField(messageProperty, true);
            EditorGUILayout.PropertyField(parameterProperty, true);
            EditorGUILayout.PropertyField(valueProperty, true);

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 14
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();
            }
        }
Esempio n. 15
0
 public void Draw(SerializedObject serializedObject, SerializedProperty nodeProperty, int nodeIndex)
 {
     if (serializedObject == null || nodeProperty == null)
     {
         return;
     }
     DrawMainInfo(serializedObject, nodeProperty);
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawStateInfo(serializedObject, nodeProperty, nodeIndex);
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawConnectionInfo(serializedObject, nodeProperty);
 }
        private void OnAddDropdown(Rect buttonRect, ReorderableList list)
        {
            var subtypes = QuestEditorUtility.GetSubtypes <QuestAction>();
            var menu     = new GenericMenu();

            for (int i = 0; i < subtypes.Count; i++)
            {
                var subtype = subtypes[i];
                menu.AddItem(new GUIContent(ObjectNames.NicifyVariableName(subtype.Name)), false, OnAddQuestActionType, subtype);
            }
            menu.ShowAsContext();
        }
 private void DrawSelectedAction()
 {
     if (m_selectedAction == null)
     {
         return;
     }
     if (m_actionEditor == null)
     {
         m_actionEditor = Editor.CreateEditor(m_selectedAction);
     }
     QuestEditorUtility.EditorGUILayoutBeginIndent();
     m_actionEditor.OnInspectorGUI();
     QuestEditorUtility.EditorGUILayoutEndIndent();
 }
Esempio n. 18
0
 private void DrawSelectedContent()
 {
     if (m_selectedQuestContent == null)
     {
         return;
     }
     if (m_contentEditor == null)
     {
         m_contentEditor = Editor.CreateEditor(m_selectedQuestContent);
     }
     QuestEditorUtility.EditorGUILayoutBeginIndent();
     m_contentEditor.OnInspectorGUI();
     QuestEditorUtility.EditorGUILayoutEndIndent();
 }
 public override void OnInspectorGUI()
 {
     serializedObject.Update();
     DrawTopInfo();
     DrawParentList();
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawUrgencyFunctionList();
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawActionList();
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawDriveValueList();
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawRewardMultipliers();
     serializedObject.ApplyModifiedProperties();
 }
Esempio n. 20
0
        private void OnRewardSystemListAddDropdown(Rect buttonRect, ReorderableList list)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Refresh From Components"), false, OnRefreshRewardSystemList);
            menu.AddSeparator(string.Empty);
            var subtypes = QuestEditorUtility.GetSubtypes <RewardSystem>();

            for (int i = 0; i < subtypes.Count; i++)
            {
                var subtype = subtypes[i];
                menu.AddItem(new GUIContent(ObjectNames.NicifyVariableName(subtype.Name)), false, OnAddRewardSystemType, subtype);
            }
            menu.ShowAsContext();
        }
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);
            rect = EditorGUI.PrefixLabel(rect, GUIUtility.GetControlID(FocusType.Passive), label);
            try
            {
                var valueTypeProperty = property.FindPropertyRelative("m_valueType");
                UnityEngine.Assertions.Assert.IsNotNull(valueTypeProperty, "Quest Machine: Internal error - m_valueType is null.");
                if (valueTypeProperty == null)
                {
                    return;
                }
                EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight),
                                        valueTypeProperty, GUIContent.none);
                var valueType = (QuestNumber.ValueType)valueTypeProperty.enumValueIndex;
                var valueRect = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width, EditorGUIUtility.singleLineHeight);
                switch (valueType)
                {
                case QuestNumber.ValueType.Literal:
                    var literalValueProperty = property.FindPropertyRelative("m_literalValue");
                    UnityEngine.Assertions.Assert.IsNotNull(literalValueProperty, "Quest Machine: Internal error - m_literalValue is null.");
                    if (literalValueProperty == null)
                    {
                        return;
                    }
                    EditorGUI.PropertyField(valueRect, literalValueProperty, GUIContent.none);
                    break;

                case QuestNumber.ValueType.CounterValue:
                case QuestNumber.ValueType.CounterMinValue:
                case QuestNumber.ValueType.CounterMaxValue:
                    var counterIndexProperty = property.FindPropertyRelative("m_counterIndex");
                    if (m_counterNameList == null)
                    {
                        m_counterNameList = QuestEditorUtility.GetCounterNames();
                    }
                    if (counterIndexProperty != null)
                    {
                        QuestEditorUtility.EditorGUICounterNamePopup(valueRect, counterIndexProperty, m_counterNameList);
                    }
                    break;
                }
            }
            finally
            {
                EditorGUI.EndProperty();
            }
        }
Esempio n. 22
0
        private void OnRemoveElement(ReorderableList list)
        {
            var isIndexValid = (0 <= list.index && list.index < list.count);

            if (!isIndexValid)
            {
                return;
            }
            QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
            var condition = list.serializedProperty.GetArrayElementAtIndex(list.index).objectReferenceValue as QuestCondition;

            QuestEditorUtility.RemoveReorderableListElementWithoutLeavingNull(list);
            QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
            AssetUtility.DeleteFromAsset(condition, QuestEditorWindow.selectedQuest);
            OnSelectElement(list);
        }
        public override void OnInspectorGUI()
        {
            DrawDebugFoldout();

            serializedObject.Update();
            DrawID("Quest giver identity.");
            QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
            DrawSaveSettings();
            QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
            DrawOtherSettings();
            QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
            DrawDialogueContent();
            QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
            DrawQuestList();
            serializedObject.ApplyModifiedProperties();
            DrawSelectedQuestInspector();
        }
 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();
     }
 }
Esempio n. 25
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();
            }
        }
Esempio n. 26
0
 public void Draw(SerializedObject serializedObject)
 {
     if (serializedObject == null)
     {
         return;
     }
     DrawMainInfo(serializedObject);
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawAutostartConditions(serializedObject);
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawOfferConditions(serializedObject);
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawStateInfo(serializedObject);
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawCounters(serializedObject);
     QuestEditorUtility.EditorGUILayoutVerticalSpace(2);
     DrawNodes(serializedObject);
 }
Esempio n. 27
0
        protected override void Draw()
        {
            if (serializedObject == null)
            {
                return;
            }
            if (m_nameList == null)
            {
                m_nameList = QuestEditorUtility.GetCounterNames();
            }
            serializedObject.Update();
            var counterIndexProperty   = serializedObject.FindProperty("m_counterIndex");
            var operationProperty      = serializedObject.FindProperty("m_operation");
            var operationValueProperty = serializedObject.FindProperty("m_operationValue");
            var maxValueProperty       = serializedObject.FindProperty("m_maxValue");

            UnityEngine.Assertions.Assert.IsNotNull(counterIndexProperty, "Quest Machine: Internal error - m_counterIndex is null.");
            UnityEngine.Assertions.Assert.IsNotNull(operationProperty, "Quest Machine: Internal error - m_operation is null.");
            UnityEngine.Assertions.Assert.IsNotNull(operationValueProperty, "Quest Machine: Internal error - m_operationValue is null.");
            UnityEngine.Assertions.Assert.IsNotNull(maxValueProperty, "Quest Machine: Internal error - m_maxValue is null.");
            if (counterIndexProperty == null || operationProperty == null || operationValueProperty == null || maxValueProperty == null)
            {
                return;
            }
            QuestEditorUtility.EditorGUILayoutCounterNamePopup(counterIndexProperty, m_nameList);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(operationProperty);
            if (EditorGUI.EndChangeCheck())
            {
                m_operationValueTooltip = null;
            }
            var operation = (SetCounterValueQuestAction.Operation)operationProperty.enumValueIndex;

            if (m_operationValueTooltip == null)
            {
                m_operationValueTooltip = GetOperationValueTooltip(operation);
            }
            EditorGUILayout.PropertyField(operationValueProperty, m_operationValueTooltip);
            if (operation == SetCounterValueQuestAction.Operation.Randomize)
            {
                EditorGUILayout.PropertyField(maxValueProperty);
            }
            serializedObject.ApplyModifiedProperties();
        }
        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();
            }
        }
        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();
            }
        }
        protected override void CreateNewAsset(List <AssetInfo> assetInfoList)
        {
            // Create a list of all urgency function types, excluding abstract types and
            // types that have wrappers:
            var list       = new List <System.Type>();
            var assemblies = RuntimeTypeUtility.GetAssemblies();

            foreach (var assembly in assemblies)
            {
                try
                {
                    var assemblyList = (from assemblyType in assembly.GetExportedTypes()
                                        where typeof(UrgencyFunction).IsAssignableFrom(assemblyType)
                                        select assemblyType).ToArray();
                    list.AddRange(assemblyList);
                }
                catch (System.Exception)
                {
                    // Ignore exceptions and move on to next assembly.
                }
            }
            var menu = new GenericMenu();

            for (int i = 0; i < list.Count; i++)
            {
                var type = list[i];
                if (type == null)
                {
                    continue;
                }
                if (type.IsAbstract)
                {
                    continue;
                }
                if (QuestEditorUtility.HasWrapperType(type))
                {
                    continue;
                }
                menu.AddItem(new GUIContent(type.Name), false, OnClickNewUrgencyFunction, type);
            }
            menu.ShowAsContext();
        }