示例#1
0
        // STATS PAINTER: -------------------------------------------------------------------------

        private void PaintStatHeader(StatAsset statAsset, int index)
        {
            EditorData statEditorData = this.statsEditorData[index];

            Rect rect       = GUILayoutUtility.GetRect(GUIContent.none, CoreGUIStyles.GetToggleButtonOff());
            Rect rectColor  = new Rect(rect.x, rect.y, 5f, rect.height);
            Rect rectButton = new Rect(rect.x + rectColor.width, rect.y, rect.width - rectColor.width, rect.height);

            Color tmpColor = GUI.backgroundColor;

            GUI.backgroundColor = statAsset.stat.color;
            GUI.Button(rectColor, GUIContent.none, CoreGUIStyles.GetToggleButtonLeftOff());
            GUI.backgroundColor = tmpColor;

            string title = statAsset.stat.uniqueName;

            if (Application.isPlaying)
            {
                title = string.Format(
                    "<b>{0}</b>: {1}",
                    title,
                    this.instance.GetStat(title)
                    );
            }

            GUIStyle style = (statEditorData.isExpanded.target
                ? CoreGUIStyles.GetToggleButtonRightOn()
                : CoreGUIStyles.GetToggleButtonRightOff()
                              );

            if (GUI.Button(rectButton, title, style))
            {
                statEditorData.isExpanded.target = !statEditorData.isExpanded.target;
            }
        }
示例#2
0
 public RuntimeAttrData(int index, float value, AttrAsset attrAsset)
 {
     this.index     = index;
     this.value     = value;
     this.attrAsset = attrAsset;
     this.statAsset = attrAsset.attribute.stat;
     this.onChange  = new UnityEvent();
 }
示例#3
0
        // PAINT METHODS: -------------------------------------------------------------------------

        public override void OnInspectorGUI()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            if (STYLE_LABEL == null)
            {
                STYLE_LABEL          = new GUIStyle(EditorStyles.label);
                STYLE_LABEL.richText = true;
            }

            if (this.statsAssetHash != this.statsAsset.GetHashCode() ||
                this.attrsAssetHash != this.attrsAsset.GetHashCode() ||
                this.statsEditorData.Count != this.statsAsset.stats.Length)
            {
                this.OnEnable();
                serializedObject.ApplyModifiedProperties();
            }

            serializedObject.Update();

            this.PaintAttributes();

            int statsSize = this.statsAsset.stats.Length;

            for (int i = 0; i < statsSize; ++i)
            {
                StatAsset statAsset = this.statsAsset.stats[i];
                if (statAsset.isHidden)
                {
                    continue;
                }

                string uname = statAsset.uniqueID;

                this.PaintStatHeader(statAsset, i);

                using (var group = new EditorGUILayout.FadeGroupScope(this.statsEditorData[i].isExpanded.faded))
                {
                    if (group.visible)
                    {
                        EditorGUILayout.BeginVertical(CoreGUIStyles.GetBoxExpanded());
                        EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying);
                        this.PaintStatBody(statAsset, this.spStatsOverrides[uname]);
                        EditorGUI.EndDisabledGroup();
                        EditorGUILayout.EndVertical();
                    }
                }
            }

            this.PaintStatusEffects();

            EditorGUILayout.Space();
            GlobalEditorID.Paint(this.instance);
            serializedObject.ApplyModifiedProperties();
        }
示例#4
0
            public RuntimeStatData(int index, StatAsset statAsset)
            {
                this.index = index;

                this.baseValue = statAsset.stat.baseValue;
                this.formula   = statAsset.stat.formula;

                this.statAsset      = statAsset;
                this.onChange       = new UnityEvent();
                this.statsModifiers = new List <StatModifier>();
            }
        public static StatAsset AddStatsAsset()
        {
            StatAsset statAsset = ScriptableObject.CreateInstance <StatAsset>();

            statAsset.name = GameCreatorUtilities.RandomHash(8);

            string path = Path.Combine(ASSETS_PATH, STATSASSET_FILE);

            AssetDatabase.AddObjectToAsset(statAsset, path);

            return(statAsset);
        }
示例#6
0
        private void PaintStatBody(StatAsset statAsset, StatOverride statOverride)
        {
            this.PaintOverrideStat(
                statOverride.property.FindPropertyRelative("overrideValue"),
                statOverride.property.FindPropertyRelative("baseValue"),
                GC_VALUE,
                statAsset.stat.baseValue.ToString()
                );

            this.PaintOverrideStat(
                statOverride.property.FindPropertyRelative("overrideFormula"),
                statOverride.property.FindPropertyRelative("formula"),
                GC_FORMULA,
                (statAsset.stat.formula == null ? "(none)" : statAsset.stat.formula.name)
                );
        }