Beispiel #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.BeginVertical(MalbersEditor.StyleBlue);
            EditorGUILayout.HelpBox("Stats Manager", MessageType.None);
            EditorGUILayout.EndVertical();


            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginVertical(MalbersEditor.StyleGray);
            {
                EditorGUI.BeginDisabledGroup(true);
                script = (MonoScript)EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
                EditorGUI.EndDisabledGroup();


                list.DoLayoutList();

                if (list.index != -1)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    var element    = statList.GetArrayElementAtIndex(list.index);
                    var id         = element.FindPropertyRelative("ID");
                    var name       = element.FindPropertyRelative("name").stringValue;
                    var ShowEvents = element.FindPropertyRelative("ShowEvents");
                    var BelowValue = element.FindPropertyRelative("Below");
                    var AboveValue = element.FindPropertyRelative("Above");

                    var Value    = element.FindPropertyRelative("value");
                    var MaxValue = element.FindPropertyRelative("maxValue");
                    var MinValue = element.FindPropertyRelative("minValue");
                    // var useConstant = Value.FindPropertyRelative("UseConstant");
                    //  var variable = Value.FindPropertyRelative("Variable");

                    EditorGUILayout.PropertyField(id, new GUIContent("ID", "ID to identify the Stat"));

                    EditorGUI.BeginChangeCheck();

                    EditorGUILayout.PropertyField(Value, new GUIContent("Value", "Current Value of the Stat"));

                    //float newValue = Value.floatValue;
                    //if (M.stats[list.index].Value != newValue) M.stats[list.index].Value != newValue;


                    if (EditorGUI.EndChangeCheck())
                    {
                        MaxValue.FindPropertyRelative("ConstantValue").floatValue = Value.FindPropertyRelative("ConstantValue").floatValue;
                    }

                    EditorGUILayout.PropertyField(MaxValue, new GUIContent("Max Value", "Default/Reset value of the Stat"));
                    EditorGUILayout.PropertyField(MinValue, new GUIContent("Min Value", "Minimun value of the Stat"));

                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    var Regenerate = element.FindPropertyRelative("regenerate");
                    EditorGUILayout.PropertyField(Regenerate, new GUIContent("Regenerate", "Can the Stat Regenerate over time?"));

                    bool regen = Regenerate.boolValue;
                    if (M.stats[list.index].Regenerate != regen)
                    {
                        M.stats[list.index].Regenerate = regen;
                        serializedObject.ApplyModifiedProperties();
                    }

                    // if (Regenerate.boolValue)
                    {
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("RegenRate"), new GUIContent("Rate", "Regeneration Rate, how fast/Slow the Stat will regenerate"));
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("RegenWaitTime"), new GUIContent("Wait Time", "After the Stat is modified, the time to wait to start regenerating"));
                    }
                    EditorGUILayout.EndVertical();


                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    var Degenerate = element.FindPropertyRelative("degenerate");
                    EditorGUILayout.PropertyField(Degenerate, new GUIContent("Degenerate", "Can the Stat Degenerate over time?"));
                    bool degen = Degenerate.boolValue;


                    Degenerate.boolValue           = degen;
                    M.stats[list.index].Degenerate = degen;
                    serializedObject.ApplyModifiedProperties();

                    EditorGUILayout.PropertyField(element.FindPropertyRelative("DegenRate"), new GUIContent("Rate", "Degeneration Rate, how fast/Slow the Stat will Degenerate"));

                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    EditorGUI.indentLevel++;
                    ShowEvents.boolValue = EditorGUILayout.Foldout(ShowEvents.boolValue, "Events");
                    EditorGUI.indentLevel--;

                    if (ShowEvents.boolValue)
                    {
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("OnValueChange"));
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("OnValueChangeNormalized"));
                        MalbersEditor.DrawSplitter();
                        EditorGUILayout.Space();
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("OnStatFull"), new GUIContent("On " + name + " Full "));
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("OnStatEmpty"), new GUIContent("On " + name + " Empty "));
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("OnDegenereate"), new GUIContent("On " + name + " Degenerate "));

                        MalbersEditor.DrawSplitter();
                        EditorGUILayout.Space();
                        EditorGUILayout.BeginHorizontal(/*EditorStyles.helpBox*/);
                        EditorGUIUtility.labelWidth = 55;
                        EditorGUILayout.PropertyField(BelowValue, new GUIContent("Below", "Used to Check when the Stat is below this value"));
                        EditorGUILayout.PropertyField(AboveValue, new GUIContent("Above", "Used to Check when the Stat is Above this value"));
                        EditorGUIUtility.labelWidth = 0;
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("OnStatBelow"), new GUIContent("On " + name + " Below " + BelowValue.floatValue.ToString("F1")));
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("OnStatAbove"), new GUIContent("On " + name + " Above " + AboveValue.floatValue.ToString("F1")));
                    }

                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndVertical();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(M, "Stats Modified");
                EditorUtility.SetDirty(target);
                serializedObject.ApplyModifiedProperties();
            }
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            MalbersEditor.DrawDescription("Stats Manager");

            EditorGUILayout.BeginVertical(MalbersEditor.StyleGray);
            {
                if (Application.isPlaying)
                {
                    EditorGUI.BeginDisabledGroup(true);
                    {
                        if (M.PinnedStat != null)
                        {
                            EditorGUILayout.ObjectField("Pin Stat: ", (StatID)M.PinnedStat.ID, typeof(StatID), false);
                        }
                        else
                        {
                            EditorGUILayout.LabelField("Pin Stat: NULL ");
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }

                list.DoLayoutList();

                if (list.index != -1)
                {
                    var element    = statList.GetArrayElementAtIndex(list.index);
                    var id         = element.FindPropertyRelative("ID");
                    var ShowEvents = element.FindPropertyRelative("ShowEvents");
                    var BelowValue = element.FindPropertyRelative("Below");
                    var AboveValue = element.FindPropertyRelative("Above");

                    var Value    = element.FindPropertyRelative("value");
                    var MaxValue = element.FindPropertyRelative("maxValue");
                    var MinValue = element.FindPropertyRelative("minValue");

                    var resetTo    = element.FindPropertyRelative("resetTo");
                    var InmuneTime = element.FindPropertyRelative("InmuneTime");

                    var Regenerate    = element.FindPropertyRelative("regenerate");
                    var RegenRate     = element.FindPropertyRelative("RegenRate");
                    var RegenWaitTime = element.FindPropertyRelative("RegenWaitTime");

                    var Degenerate    = element.FindPropertyRelative("degenerate");
                    var DegenRate     = element.FindPropertyRelative("DegenRate");
                    var DegenWaitTime = element.FindPropertyRelative("DegenWaitTime");
                    var multiplier    = element.FindPropertyRelative("multiplier");


                    var OnValueChange           = element.FindPropertyRelative("OnValueChange");
                    var OnValueChangeNormalized = element.FindPropertyRelative("OnValueChangeNormalized");
                    var OnStatFull   = element.FindPropertyRelative("OnStatFull");
                    var OnStatEmpty  = element.FindPropertyRelative("OnStatEmpty");
                    var OnRegenerate = element.FindPropertyRelative("OnRegenerate");
                    var OnDegenerate = element.FindPropertyRelative("OnDegenerate");
                    var OnStatBelow  = element.FindPropertyRelative("OnStatBelow");
                    var OnStatAbove  = element.FindPropertyRelative("OnStatAbove");



                    EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                    {
                        EditorGUIUtility.labelWidth = 60;
                        EditorGUILayout.PropertyField(Value, new GUIContent("Value", "Current Value of the Stat"));
                        EditorGUILayout.PropertyField(multiplier, new GUIContent("Mult", "Stat Multiplier to be used when the value is modified"));
                        EditorGUIUtility.labelWidth = 0;
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                    {
                        EditorGUIUtility.labelWidth = 55;
                        EditorGUILayout.PropertyField(MinValue, new GUIContent("Min", "Minimun value of the Stat"));
                        EditorGUILayout.PropertyField(MaxValue, new GUIContent("Max", "Maximum value of the Stat"));
                        EditorGUIUtility.labelWidth = 0;
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    {
                        EditorGUILayout.PropertyField(Regenerate, new GUIContent("Regenerate", "Can the Stat Regenerate over time?"));
                        EditorGUILayout.PropertyField(RegenRate, new GUIContent("Rate", "Regeneration Rate, how fast/Slow the Stat will regenerate"));
                        EditorGUILayout.PropertyField(RegenWaitTime, new GUIContent("Wait Time", "After the Stat is modified, the time to wait to start regenerating"));
                    }
                    EditorGUILayout.EndVertical();


                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    {
                        EditorGUILayout.PropertyField(Degenerate, new GUIContent("Degenerate", "Can the Stat Degenerate over time?"));
                        EditorGUILayout.PropertyField(DegenRate, new GUIContent("Rate", "Degeneration Rate, how fast/Slow the Stat will Degenerate"));
                        EditorGUILayout.PropertyField(DegenWaitTime, new GUIContent("Wait Time", "After the Stat is modified, the time to wait to start degenerating"));
                    }
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    {
                        EditorGUILayout.PropertyField(resetTo, new GUIContent("Reset To", "When called the Funtion RESET()  it will reset to the Min Value or the Max Value"));
                        EditorGUILayout.PropertyField(InmuneTime, new GUIContent("Inmune Time", "If greater than zero, the Stat cannot be modify until the inmune time have passed"));

                        if (Application.isPlaying)
                        {
                            EditorGUI.BeginDisabledGroup(true);
                            EditorGUILayout.Toggle("Is Inmune", M.stats[list.index].IsInmune);
                            EditorGUI.EndDisabledGroup();
                        }
                    }
                    EditorGUILayout.EndVertical();


                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    {
                        if (MalbersEditor.Foldout(ShowEvents, "Events"))
                        {
                            string name = "Stat";

                            if (id.objectReferenceValue != null)
                            {
                                name = id.objectReferenceValue.name;
                            }

                            EditorGUILayout.PropertyField(OnValueChange, new GUIContent("On " + name + " change"));
                            EditorGUILayout.PropertyField(OnValueChangeNormalized, new GUIContent("On " + name + " change normalized"));
                            MalbersEditor.DrawSplitter();
                            EditorGUILayout.Space();
                            EditorGUILayout.PropertyField(OnStatFull, new GUIContent("On " + name + " full "));
                            EditorGUILayout.PropertyField(OnStatEmpty, new GUIContent("On " + name + " empty "));
                            EditorGUILayout.PropertyField(OnRegenerate, new GUIContent("On " + name + " Regenerate "));
                            EditorGUILayout.PropertyField(OnDegenerate, new GUIContent("On " + name + " Degenerate "));

                            MalbersEditor.DrawSplitter();
                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUIUtility.labelWidth = 55;
                                EditorGUILayout.PropertyField(BelowValue, new GUIContent("Below", "Used to Check when the Stat is below this value"));
                                EditorGUILayout.PropertyField(AboveValue, new GUIContent("Above", "Used to Check when the Stat is Above this value"));
                                EditorGUIUtility.labelWidth = 0;
                            }
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.PropertyField(OnStatBelow, new GUIContent("On " + name + " Below " + BelowValue.floatValue.ToString("F1")));
                            EditorGUILayout.PropertyField(OnStatAbove, new GUIContent("On " + name + " Above " + AboveValue.floatValue.ToString("F1")));
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }