Beispiel #1
0
        public void BuildStatAttributeUI(GameObject container, StatsAttribute attr)
        {
            HorizontalLayoutGroup g;

            for (int i = 0; i < attr.enabled.Length; i++)
            {
                if (attr.enabled[i])
                {
                    g = BuildLine(container, 20);
                    CreateText(GetStyle("WeaponStatLabel"), g.gameObject, ((Stats.StatType)i).ToString());
                    string plus = "+";
                    if (attr.stats[i] < 0)
                    {
                        plus = "-";
                    }
                    CreateText(GetStyle("WeaponStatLabelRight"), g.gameObject, plus + attr.stats[i].ToString());
                }
            }
            Canvas.ForceUpdateCanvases();
        }
Beispiel #2
0
        float BonusFromGear(Stats.StatType _t)
        {
            float bonus = 0;

            foreach (NewItem itm in Gear.items)
            {
                if (itm)
                {
                    StatsAttribute attr = itm.GetAttribute <StatsAttribute>();
                    if (attr)
                    {
                        if (attr.enabled[(int)_t])
                        {
                            bonus += attr.stats[(int)_t];
                        }
                    }
                }
            }

            return(bonus);
        }
        public override void OnInspectorGUI()
        {
            StatsAttribute atr = (StatsAttribute)target;

            EditorGUILayout.BeginVertical();

            toggle = EditorGUILayout.Foldout(toggle, "Stat Changes");
            if (toggle)
            {
                EditorGUI.indentLevel++;
                for (int i = 0; i < atr.stats.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    float val = EditorGUILayout.FloatField(((Stats.StatType)i).ToString(), atr.stats[i]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(atr, "Modify attribute");
                        atr.stats[i]   = val;
                        atr.enabled[i] = true;
                        EditorUtility.SetDirty(target);
                    }
                    EditorGUI.BeginChangeCheck();
                    bool enabled = EditorGUILayout.Toggle(atr.enabled[i]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(atr, "Modify attribute");
                        atr.enabled[i] = enabled;
                        EditorUtility.SetDirty(target);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }

            EditorGUILayout.EndVertical();
        }