private void OnGUI_EditorBuffItem(int index) { Buff b = buffList[index]; //bool isRepeat = buffList.GroupBy(x => x.Id).Where(x => x.Count() > 1).Where(x => x.Key == b.Id).ToList().Count() > 1; bool isRepeat = Editor_TableTool.IsRepeatHeroId((int)b.Id, buffList); if (isRepeat) { GUIStyle titleStyle2 = new GUIStyle(); titleStyle2.normal.textColor = new Color(1, 0, 0, 1); GUILayout.Label("id重复", titleStyle2); } GUILayout.BeginHorizontal(); if (GUILayout.Button("add", GUILayout.Width(50))) { Buff newBuff = new Buff(); newBuff.Params_StrValue = new List <string>(); newBuff.Params_NumValue = new List <double>(); newBuff.Params_Formula = new List <string>(); buffList.Insert(index + 1, newBuff); } bool isdel = false; if (GUILayout.Button("del", GUILayout.Width(50))) { isdel = true; buffList.Remove(b); } GUILayout.EndHorizontal(); if (!isdel) { buffList[index] = (Buff)DrawTableType.DrawWindow(b); } }
private void OnGUI_EditorSkillItem(List <Skill> list, int index, int k) { Skill s = list[index]; GUILayout.BeginVertical(); bool isRepeat = Editor_TableTool.IsRepeatSkillId((int)s.Id, skillList); if (isRepeat) { GUIStyle titleStyle2 = new GUIStyle(); titleStyle2.normal.textColor = new Color(1, 0, 0, 1); GUILayout.Label("id重复", titleStyle2); } GUILayout.BeginHorizontal(GUILayout.Width(200)); if (GUILayout.Button("add", GUILayout.Width(50))) { Skill newSkill = new Skill(); //TODO by xiaofan // newSkill.Buffs = new List<double>(); // newSkill.AttackRatio = new List<double>(); list.Insert(index + 1, newSkill); } bool isdel = false; if (GUILayout.Button("del", GUILayout.Width(50))) { isdel = true; list.Remove(s); if (list.Count == 0) { skillList.Remove(k); } } GUILayout.EndHorizontal(); if (!isdel) { list[index] = (Skill)DrawTableType.DrawWindow(s); } GUILayout.EndVertical(); }
private void OnGUI_EditorHeroItem(List <Hero> list, int index, int k) { Hero h = list[index]; GUILayout.BeginVertical(); bool isRepeat = Editor_TableTool.IsRepeatHeroId((int)h.Id, heroList); if (isRepeat) { GUIStyle titleStyle2 = new GUIStyle(); titleStyle2.normal.textColor = new Color(1, 0, 0, 1); GUILayout.Label("id重复", titleStyle2); } GUILayout.BeginHorizontal(GUILayout.Width(200)); if (GUILayout.Button("add", GUILayout.Width(50))) { Hero newHero = new Hero(); newHero.AttributeName = new List <string>(); newHero.AttributeValue = new List <double>(); newHero.Skills = new List <double>(); list.Insert(index + 1, newHero); } bool isdel = false; if (GUILayout.Button("del", GUILayout.Width(50))) { list.Remove(h); if (list.Count == 0) { heroList.Remove(k); } isdel = true; } GUILayout.EndHorizontal(); if (!isdel) { list[index] = (Hero)DrawTableType.DrawWindow(h); } GUILayout.EndVertical(); }
//展示一份数据窗口 public static void OnGUI_EditorItem(List <object> list, int index, string sortField, int maxId) { object o = list[index]; GUILayout.BeginVertical(); // bool isRepeat = Editor_TableTool.IsRepeatHeroId((int)h.Id, heroList); // if (isRepeat) // { // GUIStyle titleStyle2 = new GUIStyle(); // titleStyle2.normal.textColor = new Color(1, 0, 0, 1); // GUILayout.Label("id重复", titleStyle2); // } GUILayout.BeginHorizontal(GUILayout.Width(200)); if (GUILayout.Button("add", GUILayout.Width(50))) { object obj = Editor_TableTool.CreateInstance(o.GetType()); list.Insert(index + 1, obj); PropertyInfo idProp = obj.GetType().GetProperty("Id"); idProp.SetValue(obj, maxId + 1); PropertyInfo sortProp = obj.GetType().GetProperty(sortField); sortProp.SetValue(obj, sortProp.GetValue(o)); sortProp.SetValue(o, maxId + 1); } bool isdel = false; if (GUILayout.Button("del", GUILayout.Width(50))) { list.Remove(o); isdel = true; } GUILayout.EndHorizontal(); if (!isdel) { list[index] = DrawTableType.DrawWindow(o); } GUILayout.EndVertical(); }