public GameObject onMaxValueEventPrefab; // called when the value reached the max value // ---------------------------------------------------------------------------------------------------------------- public RPGAttributeData Copy(float maxLevel) { RPGAttributeData a = new RPGAttributeData(); a.attribId.Value = this.attribId.Value; a.baseVal = this.baseVal; a.baseMin = this.baseMin; a.baseMax = this.baseMax; a.canRegen = this.canRegen; a.regenRate = this.regenRate; a.levelAffectVal = this.levelAffectVal; a.levelAffectMax = this.levelAffectMax; a.regenAfterTimeout = this.regenAfterTimeout; a.valAffectMax = this.valAffectMax; a.maxAffectMax = this.maxAffectMax; if (this.valAffectCurve != null) a.valAffectCurve = AnimationCurve.Linear(1, 1, maxLevel, a.valAffectMax); if (this.maxAffectCurve != null) a.maxAffectCurve = AnimationCurve.Linear(1, 1, maxLevel, a.maxAffectMax); a.onValChangeEventPrefab = this.onValChangeEventPrefab; a.onMinValueEventPrefab = this.onMinValueEventPrefab; a.onMaxValueEventPrefab = this.onMaxValueEventPrefab; return a; }
private void LeftPanel() { EditorGUILayout.BeginVertical(GUILayout.Width(DatabaseEditor.LeftPanelWidth)); GUILayout.Space(5); // ------------------------------------------------------------- // the add button EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Add Class", UniRPGEdGui.Icon_Plus), EditorStyles.miniButtonLeft)) { GUI.FocusControl(""); curr = ScriptableObject.CreateInstance<RPGActorClass>(); UniRPGEdUtil.AddObjectToAssetFile(curr, UniRPGEditorGlobal.DB_DEF_CLASSES_FILE); curr.screenName = "ActorClass"; ed.db.classes.Add(curr); EditorUtility.SetDirty(curr); EditorUtility.SetDirty(ed.db); selAttrib = null; } if (curr == null) GUI.enabled = false; if (GUILayout.Button(new GUIContent(UniRPGEdGui.Icon_Copy, "Copy"), EditorStyles.miniButtonMid)) { GUI.FocusControl(""); RPGActorClass newAC = ScriptableObject.CreateInstance<RPGActorClass>(); curr.CopyTo(newAC); curr = newAC; UniRPGEdUtil.AddObjectToAssetFile(curr, UniRPGEditorGlobal.DB_DEF_CLASSES_FILE); ed.db.classes.Add(curr); EditorUtility.SetDirty(curr); EditorUtility.SetDirty(ed.db); selAttrib = null; } GUI.enabled = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); scroll[0] = UniRPGEdGui.BeginScrollView(scroll[0], GUILayout.Width(DatabaseEditor.LeftPanelWidth)); { if (ed.db.classes.Count > 0) { foreach (RPGActorClass charaClass in ed.db.classes) { Rect r = EditorGUILayout.BeginHorizontal(GUILayout.Width(DatabaseEditor.LeftPanelWidth - 20), GUILayout.ExpandWidth(false)); { r.x = 3; r.width = 19; r.height = 19; GUI.DrawTexture(r, (charaClass.icon[0] != null ? charaClass.icon[0] : UniRPGEdGui.Texture_NoPreview)); GUILayout.Space(21); if (UniRPGEdGui.ToggleButton(curr == charaClass, charaClass.screenName, UniRPGEdGui.ButtonMidStyle, GUILayout.Width(140), GUILayout.ExpandWidth(false))) { selAttrib = null; curr = charaClass; GUI.FocusControl(""); CheckXPAttrib(); } if (ed.db.classes.Count == 1) GUI.enabled = false; // can't allow deleting the class if there is only one left since runtime depends on at least one being present if (GUILayout.Button("X", UniRPGEdGui.ButtonRightStyle, GUILayout.Width(20))) { del = charaClass; } GUI.enabled = true; } EditorGUILayout.EndHorizontal(); } } else { GUILayout.Label("No Classes are defined", UniRPGEdGui.WarningLabelStyle); } } UniRPGEdGui.EndScrollView(); // ------------------------------------------------------------- GUILayout.Space(3); EditorGUILayout.EndVertical(); // ------------------------------------------------------------- if (del != null) { if (curr == del) { curr = null; selAttrib = null; } ed.db.classes.Remove(del); Object.DestroyImmediate(del, true); del = null; EditorUtility.SetDirty(ed.db); AssetDatabase.SaveAssets(); } }
private void OnAttributeSelected(object sender, object[] args) { AttributeSelectWiz wiz = sender as AttributeSelectWiz; if (!ContainAttribType(curr.attribDataFabs, wiz.selectedAttrib.id)) { //selAttrib = wiz.selectedAttrib.data.Copy(); //curr.attribDataFabs.Add(selAttrib); selAttrib = new RPGAttributeData(); selAttrib.attribId = wiz.selectedAttrib.id; curr.attribDataFabs.Add(selAttrib); EditorUtility.SetDirty(curr); CheckXPAttrib(); ResetLevelGraph(curr.maxLevel, curr.maxXP); } wiz.Close(); ed.Repaint(); }
private void AttributesList() { if (curr.attribDataFabs.Count > 0) { GUIStyle back = UniRPGEdGui.ListItemBackDarkStyle; foreach (RPGAttributeData attrib in curr.attribDataFabs) { EditorGUILayout.BeginHorizontal(); { RPGAttribute att = null; if (attrib != null) att = RPGAttribute.GetAttribByGuid(UniRPGEditorGlobal.DB.attributes, attrib.attribId); if (att == null) { GUILayout.Label("Error: NULL", back, GUILayout.ExpandWidth(true)); if (GUILayout.Button("X", UniRPGEdGui.ButtonRightStyle, GUILayout.Width(25))) delAttrib = attrib; GUILayout.Space(5); } else { if (UniRPGEdGui.ToggleButton(attrib == selAttrib, att.screenName, UniRPGEdGui.ButtonLeftStyle, GUILayout.Width(110), GUILayout.ExpandWidth(false))) { selAttrib = attrib; GUI.FocusControl(""); } if (GUILayout.Button("X", UniRPGEdGui.ButtonRightStyle, GUILayout.Width(20))) { delAttrib = attrib; } } GUILayout.Space(10); } EditorGUILayout.EndHorizontal(); back = (back == UniRPGEdGui.ListItemBackDarkStyle ? UniRPGEdGui.ListItemBackLightStyle : UniRPGEdGui.ListItemBackDarkStyle); } if (delAttrib != null) { if (selAttrib == delAttrib) selAttrib = null; curr.attribDataFabs.Remove(delAttrib); delAttrib = null; EditorUtility.SetDirty(curr); CheckXPAttrib(); } } }
private void Attributes() { EditorGUILayout.BeginVertical(UniRPGEdGui.BoxStyle, GUILayout.Width(650)); { EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Attributes", UniRPGEdGui.Head3Style); GUILayout.Space(20); if (UniRPGEdGui.IconButton("Add", UniRPGEdGui.Icon_Plus, EditorStyles.miniButtonLeft, GUILayout.Width(80))) { AttributeSelectWiz.Show(OnAttributeSelected, null); } if (UniRPGEdGui.IconButton("All", UniRPGEdGui.Icon_Refresh, EditorStyles.miniButtonRight, GUILayout.Width(80))) { foreach (RPGAttribute a in UniRPGEditorGlobal.DB.attributes) { if (!ContainAttribType(curr.attribDataFabs, a.id)) { //curr.attribDataFabs.Add(a.data.Copy()); RPGAttributeData data = new RPGAttributeData(); data.attribId = a.id; curr.attribDataFabs.Add(data); } } EditorUtility.SetDirty(curr); EditorUtility.SetDirty(ed.db); CheckXPAttrib(); ResetLevelGraph(curr.maxLevel, curr.maxXP); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); { // attrib list scroll[2] = UniRPGEdGui.BeginScrollView(scroll[2], UniRPGEdGui.ScrollViewNoTLMarginStyle, GUILayout.Width(160), GUILayout.Height(230)); AttributesList(); UniRPGEdGui.EndScrollView(); EditorGUILayout.Space(); // details of selected attrib EditorGUILayout.BeginVertical(); AttributeValues(); EditorGUILayout.EndVertical(); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndHorizontal(); }