// 检测伤害是否有效 // @hurmId:伤害配置id // return:有效返回true;否则false private bool CheckHurmIsValid(int hurmId) { if (!m_dicHurmNum.ContainsKey(hurmId)) { return(false); } if (m_dicHurmNum[hurmId] != 1) { return(false); } for (int i = 0; i < m_skillData.aH.Length; ++i) { SkillHurmData hurmData = m_skillData.aH[i]; if (hurmData.i != hurmId) { continue; } for (int j = 0; j < hurmData.aD.Length; ++j) { int dispId = hurmData.aD[j]; if (!CheckDispIsValid(dispId)) { return(false); } } } return(true); }
// 绘制伤害 private void DrawHurm() { GUI.backgroundColor = Color.blue; GUILayout.BeginVertical(new GUIStyle(EditorStyles.textField), GUILayout.Width(MENU_WIDTH), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); GUI.backgroundColor = m_defaultBgClr; // 标题 GUI.backgroundColor = Color.white; GUILayout.BeginVertical(); GUILayout.Label("伤害", m_styleTittle, GUILayout.Width(MENU_WIDTH), GUILayout.Height(40)); GUILayout.EndVertical(); // 标题 GUI.backgroundColor = m_defaultBgClr; GUI.backgroundColor = Color.white; GUILayout.BeginVertical(GUILayout.Height(630), GUILayout.ExpandHeight(true)); m_hurmScroPos = GUILayout.BeginScrollView(m_hurmScroPos, false, false); for (int i = 0; i < m_skillData.aH.Length; ++i) { SkillHurmData hurmData = m_skillData.aH[i]; DrawHurmItem(hurmData); } GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.backgroundColor = m_defaultBgClr; // +按钮 if (GUILayout.Button("+", GUILayout.Width(MENU_WIDTH), GUILayout.Height(40))) { List <SkillHurmData> listHarm = new List <SkillHurmData>(m_skillData.aH); SkillHurmData harmData = new SkillHurmData(); harmData.aD = new int[0]; harmData.i = GetMaxHarmDataId() + 1; listHarm.Add(harmData); m_skillData.aH = listHarm.ToArray(); } GUILayout.EndVertical(); // 绘制行为 }
// 绘制伤害图标 // @hurmData:伤害数据 private void DrawHurmItem(SkillHurmData hurmData) { if (CheckHurmIsValid(hurmData.i)) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } GUILayout.BeginVertical(new GUIStyle(EditorStyles.textField), GUILayout.Width(MENU_WIDTH - 20)); GUI.backgroundColor = m_defaultBgClr; GUILayout.BeginHorizontal(); GUILayout.Label("伤害id:", GUILayout.Width(55)); hurmData.i = EditorGUILayout.IntField(hurmData.i, GUILayout.Width(100)); //GUILayout.FlexibleSpace(); if (GUILayout.Button("-", GUILayout.Width(20))) { List <SkillHurmData> listHurm = new List <SkillHurmData>(m_skillData.aH); listHurm.Remove(hurmData); m_skillData.aH = listHurm.ToArray(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("触发时间:", GUILayout.Width(55)); hurmData.t = EditorGUILayout.FloatField(hurmData.t, GUILayout.Width(100)); GUILayout.Label("伤害比重:", GUILayout.Width(55)); hurmData.h = EditorGUILayout.FloatField(hurmData.h, GUILayout.Width(100)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); for (int i = 0; i < hurmData.aD.Length; ++i) { GUILayout.BeginHorizontal(); GUILayout.Label("表现id:", GUILayout.Width(55)); hurmData.aD[i] = EditorGUILayout.IntField(hurmData.aD[i], GUILayout.Width(100)); if (GUILayout.Button("-", GUILayout.Width(20))) { List <int> listId = new List <int>(hurmData.aD); listId.RemoveAt(i); hurmData.aD = listId.ToArray(); break; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); // +按钮 if (GUILayout.Button("绑定表现", GUILayout.Width(MENU_WIDTH), GUILayout.Height(20), GUILayout.Width(345))) { List <int> listId = new List <int>(hurmData.aD); listId.Add(0); hurmData.aD = listId.ToArray(); } GUILayout.EndVertical(); }