Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            var trigger = target as LuaTrigger;

            if (trigger == null || luaScriptWizard == null)
            {
                return;
            }

            trigger.trigger = (DialogueTriggerEvent)EditorGUILayout.EnumPopup(new GUIContent("Trigger", "The event that triggers the Lua code"), trigger.trigger);

            var newDatabase = EditorGUILayout.ObjectField("Reference Database", luaScriptWizard.database, typeof(DialogueDatabase), false) as DialogueDatabase;

            if (newDatabase != luaScriptWizard.database)
            {
                EditorTools.selectedDatabase = newDatabase;
                luaScriptWizard.database     = newDatabase;
                luaScriptWizard.RefreshWizardResources();
            }

            // Lua code / wizard:
            trigger.luaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run"), trigger.luaCode);

            trigger.once = EditorGUILayout.Toggle(new GUIContent("Only Once", "Only trigger once, then destroy this component"), trigger.once);
            EditorTools.DrawSerializedProperty(serializedObject, "condition");
        }
 protected virtual void DrawLuaAction()
 {
     foldouts.luaFoldout = EditorWindowTools.EditorGUILayoutFoldout("Run Lua Code", "Run Lua code.", foldouts.luaFoldout, false);
     if (foldouts.luaFoldout)
     {
         try
         {
             EditorWindowTools.EditorGUILayoutBeginGroup();
             if (EditorTools.selectedDatabase != luaScriptWizard.database)
             {
                 luaScriptWizard.database = EditorTools.selectedDatabase;
                 luaScriptWizard.RefreshWizardResources();
             }
             serializedObject.ApplyModifiedProperties();
             EditorGUI.BeginChangeCheck();
             var newLuaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run when the condition is true."), trigger.luaCode);
             var changed    = EditorGUI.EndChangeCheck();
             serializedObject.Update();
             if (changed)
             {
                 serializedObject.FindProperty("luaCode").stringValue = newLuaCode;
             }
         }
         finally
         {
             EditorWindowTools.EditorGUILayoutEndGroup();
         }
     }
 }
        public override void OnInspectorGUI()
        {
            var trigger = target as ConditionObserver;

            if (trigger == null)
            {
                return;
            }

            // Reference database:
            EditorTools.selectedDatabase = EditorGUILayout.ObjectField("Reference Database", EditorTools.selectedDatabase, typeof(DialogueDatabase), false) as DialogueDatabase;

            // Frequency, once, observeGameObject:
            trigger.frequency         = EditorGUILayout.FloatField(new GUIContent("Frequency", "Frequency in seconds between checks"), trigger.frequency);
            trigger.once              = EditorGUILayout.Toggle(new GUIContent("Only Once", "Destroy after the condition is true"), trigger.once);
            trigger.observeGameObject = EditorGUILayout.ObjectField(new GUIContent("Observe GameObject", "Refer to this GameObject when evaluating the Condition"), trigger.observeGameObject, typeof(GameObject), false) as GameObject;

            // Condition:
            EditorTools.DrawSerializedProperty(serializedObject, "condition");

            actionFoldout = EditorGUILayout.Foldout(actionFoldout, "Action");
            if (!actionFoldout)
            {
                return;
            }

            EditorWindowTools.StartIndentedSection();

            // Lua code / wizard:
            if (EditorTools.selectedDatabase != luaScriptWizard.database)
            {
                luaScriptWizard.database = EditorTools.selectedDatabase;
                luaScriptWizard.RefreshWizardResources();
            }
            trigger.luaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run when the condition is true"), trigger.luaCode);

            // Quest:
            if (EditorTools.selectedDatabase != questPicker.database)
            {
                questPicker.database = EditorTools.selectedDatabase;
                questPicker.UpdateTitles();
            }
            questPicker.Draw();
            trigger.questName          = questPicker.currentQuest;
            trigger.useQuestNamePicker = questPicker.usePicker;
            trigger.questState         = (QuestState)EditorGUILayout.EnumPopup(new GUIContent("Quest State", "The new quest state"), trigger.questState);

            // Alert message:
            trigger.alertMessage       = EditorGUILayout.TextField(new GUIContent("Alert Message", "Optional alert message to display when triggered"), trigger.alertMessage);
            trigger.localizedTextTable = EditorGUILayout.ObjectField(new GUIContent("Localized Text Table", "The localized text table to use for the alert message text"), trigger.localizedTextTable, typeof(LocalizedTextTable), true) as LocalizedTextTable;

            // Send Messages list:
            EditorTools.DrawSerializedProperty(serializedObject, "sendMessages");

            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            var trigger = target as QuestTrigger;

            if (trigger == null)
            {
                return;
            }

            trigger.trigger = (DialogueTriggerEvent)EditorGUILayout.EnumPopup(new GUIContent("Trigger", "The event that triggers the quest change"), trigger.trigger);
            if (questPicker != null)
            {
                questPicker.Draw();
                trigger.questName          = questPicker.currentQuest;
                trigger.useQuestNamePicker = questPicker.usePicker;
                trigger.selectedDatabase   = questPicker.database;
                if (EditorTools.selectedDatabase == null)
                {
                    EditorTools.selectedDatabase = trigger.selectedDatabase;
                }
            }
            trigger.questState = (QuestState)EditorGUILayout.EnumPopup(new GUIContent("Quest State", "The new quest state"), trigger.questState);

            EditorWindowTools.StartIndentedSection();

            // Lua code / wizard:
            if (EditorTools.selectedDatabase != luaScriptWizard.database)
            {
                luaScriptWizard.database = EditorTools.selectedDatabase;
                luaScriptWizard.RefreshWizardResources();
            }
            trigger.luaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run when the condition is true"), trigger.luaCode);

            trigger.alertMessage       = EditorGUILayout.TextField(new GUIContent("Alert Message", "Optional alert message to display when triggered"), trigger.alertMessage);
            trigger.localizedTextTable = EditorGUILayout.ObjectField(new GUIContent("Localized Text Table", "The localized text table to use for the alert message text"), trigger.localizedTextTable, typeof(LocalizedTextTable), true) as LocalizedTextTable;

            // Send Messages list:
            EditorTools.DrawSerializedProperty(serializedObject, "sendMessages");

            trigger.once = EditorGUILayout.Toggle(new GUIContent("Only Once", "Only trigger once, then destroy this component"), trigger.once);

            EditorWindowTools.EndIndentedSection();

            EditorTools.DrawSerializedProperty(serializedObject, "condition");
        }
Ejemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorWindowTools.DrawDeprecatedTriggerHelpBox();
            var trigger = target as LuaTrigger;

            if (trigger == null || luaScriptWizard == null)
            {
                return;
            }
            EditorGUILayout.PropertyField(serializedObject.FindProperty("trigger"), true);

            var newDatabase = EditorGUILayout.ObjectField("Reference Database", luaScriptWizard.database, typeof(DialogueDatabase), false) as DialogueDatabase;

            if (newDatabase != luaScriptWizard.database)
            {
                EditorTools.selectedDatabase = newDatabase;
                luaScriptWizard.database     = newDatabase;
                luaScriptWizard.RefreshWizardResources();
            }

            // Lua code / wizard:
            serializedObject.ApplyModifiedProperties();
            EditorGUI.BeginChangeCheck();
            var newLuaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run."), trigger.luaCode);
            var changed    = EditorGUI.EndChangeCheck();

            serializedObject.Update();
            if (changed)
            {
                serializedObject.FindProperty("luaCode").stringValue = newLuaCode;
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("once"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("condition"), true);
            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 6
0
        public override void OnInspectorGUI()
        {
            var trigger = target as QuestTrigger;

            if (trigger == null)
            {
                return;
            }

            serializedObject.Update();
            EditorWindowTools.DrawDeprecatedTriggerHelpBox();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("trigger"), true);

            // Quest picker:
            if (questPicker != null)
            {
                serializedObject.ApplyModifiedProperties();
                questPicker.Draw();
                trigger.questName          = questPicker.currentQuest;
                trigger.useQuestNamePicker = questPicker.usePicker;
                trigger.selectedDatabase   = questPicker.database;
                serializedObject.Update();
            }

            if (trigger.selectedDatabase != null)
            {
                EditorTools.selectedDatabase = trigger.selectedDatabase;
            }
            if (EditorTools.selectedDatabase == null)
            {
                EditorTools.selectedDatabase = EditorTools.FindInitialDatabase();
            }

            // Quest state
            var setQuestStateProperty = serializedObject.FindProperty("setQuestState");

            EditorGUILayout.PropertyField(setQuestStateProperty, true);
            if (setQuestStateProperty.boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("questState"), true);
            }

            // Quest entry state:
            var setQuestEntryStateProperty = serializedObject.FindProperty("setQuestEntryState");

            EditorGUILayout.PropertyField(setQuestEntryStateProperty, true);
            if (setQuestEntryStateProperty.boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("questEntryNumber"), true);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("questEntryState"), true);
            }

            // Lua code / wizard:
            if (EditorTools.selectedDatabase != luaScriptWizard.database)
            {
                luaScriptWizard.database = EditorTools.selectedDatabase;
                luaScriptWizard.RefreshWizardResources();
            }
            serializedObject.ApplyModifiedProperties();
            trigger.luaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run when the condition is true"), trigger.luaCode);

            serializedObject.Update();

            // Alert:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("alertMessage"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("localizedTextTable"), true);

            // Send Messages list:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("sendMessages"), true);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("once"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("condition"), true);
            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 7
0
        public override void OnInspectorGUI()
        {
            var trigger = target as ConditionObserver;

            if (trigger == null)
            {
                return;
            }

            serializedObject.Update();

            // Reference database:
            EditorTools.selectedDatabase = EditorGUILayout.ObjectField(new GUIContent("Reference Database", "Database to use for pop-up menus. Assumes this database will be in memory at runtime."), EditorTools.selectedDatabase, typeof(DialogueDatabase), false) as DialogueDatabase;

            // Frequency, once, observeGameObject:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("frequency"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("once"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("observeGameObject"), true);

            // Condition:
            foldouts.conditionFoldout = EditorWindowTools.EditorGUILayoutFoldout("Conditions", "Conditions that must be true for trigger to fire.", foldouts.conditionFoldout);
            if (foldouts.conditionFoldout)
            {
                try
                {
                    EditorWindowTools.EditorGUILayoutBeginGroup();
                    ConditionPropertyDrawer.hideMainFoldout = true;
                    var conditionProperty = serializedObject.FindProperty("condition");
                    conditionProperty.isExpanded = true;
                    EditorGUILayout.PropertyField(conditionProperty, true);
                    ConditionPropertyDrawer.hideMainFoldout = false;
                }
                finally
                {
                    EditorWindowTools.EditorGUILayoutEndGroup();
                }
            }

            // Action:
            foldouts.actionFoldout = EditorWindowTools.EditorGUILayoutFoldout("Actions", "Actions to run when the observed condition becomes true.", foldouts.actionFoldout);
            if (foldouts.actionFoldout)
            {
                try
                {
                    EditorWindowTools.EditorGUILayoutBeginGroup();
                    serializedObject.ApplyModifiedProperties();

                    // Lua code / wizard:
                    if (EditorTools.selectedDatabase != luaScriptWizard.database)
                    {
                        luaScriptWizard.database = EditorTools.selectedDatabase;
                        luaScriptWizard.RefreshWizardResources();
                    }

                    EditorGUI.BeginChangeCheck();

                    var newLuaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run when the condition is true"), trigger.luaCode);

                    // Sequence:
                    var newSequence = SequenceEditorTools.DrawLayout(new GUIContent("Sequence"), trigger.sequence, ref sequenceRect, ref sequenceSyntaxState);

                    // Quest:
                    if (EditorTools.selectedDatabase != questPicker.database)
                    {
                        questPicker.database = EditorTools.selectedDatabase;
                        questPicker.UpdateTitles();
                    }
                    questPicker.Draw();
                    var newQuestName          = questPicker.currentQuest;
                    var newUseQuestNamePicker = questPicker.usePicker;

                    var changed = EditorGUI.EndChangeCheck();

                    serializedObject.Update();

                    if (changed)
                    {
                        serializedObject.FindProperty("luaCode").stringValue          = newLuaCode;
                        serializedObject.FindProperty("sequence").stringValue         = newSequence;
                        serializedObject.FindProperty("questName").stringValue        = newQuestName;
                        serializedObject.FindProperty("useQuestNamePicker").boolValue = newUseQuestNamePicker;
                    }

                    EditorGUILayout.PropertyField(serializedObject.FindProperty("questState"), true);

                    // Alert message:
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("alertMessage"), true);
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("textTable"), true);

                    // Send Messages list:
                    DrawSendMessageAction();
                }
                finally
                {
                    EditorWindowTools.EditorGUILayoutEndGroup();
                }
            }
            serializedObject.ApplyModifiedProperties();
        }