private static void AddViewedSkill(int skillId, List <SkillRecords.SkillRecord> records) { foreach (var r in records) { if (r.id == skillId) { if (r.impact > 0) { AddViewedSkill(r.impact, records); } return; } } SkillRecords.SkillRecord record = new SkillRecords.SkillRecord(); records.Add(record); record.id = skillId; record.type = (int)SkillOrImpactType.Skill; record.dslFile = string.Empty; TableConfig.Skill skillInfo = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null != skillInfo) { record.CopyFrom(skillInfo); if (skillInfo.impact > 0) { AddViewedSkill(skillInfo.impact, records); } } }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("拷贝到剪贴板")) { InplaceSkillInfo info = target as InplaceSkillInfo; if (null != info) { var props = info.Properties; StringBuilder sb = new StringBuilder(); foreach (var pair in props) { int skillId = pair.Key; var group = pair.Value; sb.AppendFormat("========================dsl:{0}========================", skillId); sb.AppendLine(); if (null != group.PropertyList) { string lastGroup = string.Empty; foreach (var prop in group.PropertyList) { if (!string.IsNullOrEmpty(lastGroup) && lastGroup != prop.Group) { sb.AppendLine(); } if (null != prop.Property && null != prop.Property.Value && !(prop.Property.Value is AnimationCurve)) { sb.AppendFormat("{0}:{1}\t{2}", prop.Group, prop.Key, prop.Property.Value.ToString()); sb.AppendLine(); } else { sb.AppendFormat("{0}:{1}", prop.Group, prop.Key); sb.AppendLine(); } lastGroup = prop.Group; } } sb.AppendLine(); TableConfig.Skill skillCfg = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null != skillCfg) { sb.AppendLine("=====================SkillResources====================="); foreach (var resPair in skillCfg.resources) { sb.AppendFormat("{0}\t{1}\t{2}", skillId, resPair.Key, resPair.Value); sb.AppendLine(); } sb.AppendLine("====================EndSkillResources==================="); } } string text = sb.ToString(); TextEditor editor = new TextEditor(); editor.text = text; //editor.content = new GUIContent(text); editor.OnFocus(); editor.Copy(); } } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (property.isExpanded) { float height = c_FieldHeight; InplaceSkillInfo info = property.serializedObject.targetObject as InplaceSkillInfo; Dictionary <int, InplaceSkillInfo.InplaceSkillPropertyInfoGroup> dict = info.Properties; foreach (var pair in dict) { int skillId = pair.Key; var group = pair.Value; height += c_FieldHeight; if (group.IsFoldOut) { if (null != group.PropertyList) { foreach (var p in group.PropertyList) { height += c_FieldHeight; } } TableConfig.Skill skillCfg = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null != skillCfg) { height += c_FieldHeight * skillCfg.resources.Count + c_FieldHeight; } } } return(height); } else { return(c_FieldHeight); } }
public void CopyFrom(TableConfig.Skill skill) { id = skill.id; desc = skill.desc; type = skill.type; icon = skill.icon; distance = skill.distance; duration = skill.duration; interval = skill.interval; canmove = skill.canmove; impacttoself = skill.impacttoself; impact = skill.impact; interruptPriority = skill.interruptPriority; isInterrupt = skill.isInterrupt; targetType = skill.targetType; aoeType = skill.aoeType; aoeSize = skill.aoeSize; aoeAngleOrLength = skill.aoeAngleOrLength; maxAoeTargetCount = skill.maxAoeTargetCount; dslSkillId = skill.dslSkillId; dslFile = skill.dslFile; startupSkillId = skill.startupSkillId; flybackSkillId = skill.flybackSkillId; startupPositionType = skill.startupPositionType; autoCast = skill.autoCast; needTarget = skill.needTarget; cooldown = skill.cooldown; damage = skill.damage; addhp = skill.addhp; addmp = skill.addmp; addattack = skill.addattack; adddefence = skill.adddefence; addshield = skill.addshield; addspeed = skill.addspeed; addcritical = skill.addcritical; addcriticalpow = skill.addcriticalpow; addrps = skill.addrps; subsequentSkills.Clear(); subsequentSkills.AddRange(skill.subsequentSkills); resources.Clear(); foreach (var pair in skill.resources) { SkillResource res = new SkillResource(); res.Key = pair.Key; res.Resource = pair.Value; resources.Add(res); } }
static public int get_id(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); pushValue(l, true); pushValue(l, self.id); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { TableConfig.Skill o; o = new TableConfig.Skill(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int GetId(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); var ret = self.GetId(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int set_attrValues(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); System.Collections.Generic.Dictionary <System.Int32, System.Int32> v; checkType(l, 2, out v); self.attrValues = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int WriteToBinary(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); GameFramework.BinaryTable a1; checkType(l, 2, out a1); self.WriteToBinary(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_aoeAngleOrLength(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); System.Single v; checkType(l, 2, out v); self.aoeAngleOrLength = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_impactData(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); TableConfig.ImpactData v; checkType(l, 2, out v); self.impactData = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public void CopyTo(TableConfig.Skill skill) { skill.id = id; skill.desc = desc; skill.type = type; skill.icon = icon; skill.distance = distance; skill.duration = duration; skill.interval = interval; skill.canmove = canmove; skill.impacttoself = impacttoself; skill.impact = impact; skill.interruptPriority = interruptPriority; skill.isInterrupt = isInterrupt; skill.targetType = targetType; skill.aoeType = aoeType; skill.aoeSize = aoeSize; skill.aoeAngleOrLength = aoeAngleOrLength; skill.maxAoeTargetCount = maxAoeTargetCount; skill.dslSkillId = dslSkillId; skill.dslFile = dslFile; skill.startupSkillId = startupSkillId; skill.flybackSkillId = flybackSkillId; skill.startupPositionType = startupPositionType; skill.autoCast = autoCast; skill.needTarget = needTarget; skill.cooldown = cooldown; skill.damage = damage; skill.addhp = addhp; skill.addmp = addmp; skill.addattack = addattack; skill.adddefence = adddefence; skill.addshield = addshield; skill.addspeed = addspeed; skill.addcritical = addcritical; skill.addcriticalpow = addcriticalpow; skill.addrps = addrps; skill.subsequentSkills.Clear(); skill.subsequentSkills.AddRange(subsequentSkills); skill.resources.Clear(); foreach (SkillResource res in resources) { skill.resources.Add(res.Key, res.Resource); } }
static public int set_id(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); System.Int32 v; checkType(l, 2, out v); self.id = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
private static void AddDepSkillsRecursively(int skillId, List <int> outList) { TableConfig.Skill cfg = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null != cfg) { if (cfg.impacttoself > 0 && !outList.Contains(cfg.impacttoself)) { outList.Add(cfg.impacttoself); AddDepSkillsRecursively(cfg.impacttoself, outList); } if (cfg.impact > 0 && !outList.Contains(cfg.impact)) { outList.Add(cfg.impact); AddDepSkillsRecursively(cfg.impact, outList); } } }
static public int ReadFromBinary(IntPtr l) { try { TableConfig.Skill self = (TableConfig.Skill)checkSelf(l); GameFramework.BinaryTable a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); var ret = self.ReadFromBinary(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public void CopyTo(TableConfig.Skill skill) { skill.id = id; skill.desc = desc; skill.type = type; skill.icon = icon; skill.impacttoself = impacttoself; skill.impact = impact; skill.targetType = targetType; skill.aoeType = aoeType; skill.aoeSize = aoeSize; skill.aoeAngleOrLength = aoeAngleOrLength; skill.maxAoeTargetCount = maxAoeTargetCount; skill.dslFile = dslFile; skill.resources.Clear(); foreach (SkillResource res in resources) { skill.resources.Add(res.Key, res.Resource); } }
private void AddSkillButton(int actorID, int objID, int skillId) { try { TableConfig.Actor actCfg = TableConfig.ActorProvider.Instance.GetActor(actorID); if (null != actCfg) { TableConfig.Skill skillCfg = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null == skillCfg) { skillCfg = TableConfig.SkillProvider.Instance.GetSkill(actCfg.skill4); } if (null != skillCfg) { SkillBar.SkillInfo skill = skillBar.AddSkill(objID, skillCfg.id, skillCfg.icon, 0); skill.SetMp(PluginFramework.Instance.GetNpcMp(objID)); } } } catch (System.Exception ex) { Debug.LogErrorFormat("exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
public void CopyFrom(TableConfig.Skill skill) { id = skill.id; desc = skill.desc; type = skill.type; icon = skill.icon; impacttoself = skill.impacttoself; impact = skill.impact; targetType = skill.targetType; aoeType = skill.aoeType; aoeSize = skill.aoeSize; aoeAngleOrLength = skill.aoeAngleOrLength; maxAoeTargetCount = skill.maxAoeTargetCount; dslFile = skill.dslFile; resources.Clear(); foreach (var pair in skill.resources) { SkillResource res = new SkillResource(); res.Key = pair.Key; res.Resource = pair.Value; resources.Add(res); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); property.isExpanded = EditorGUI.Foldout(new Rect(position.x, position.y, 80, c_FieldHeight), property.isExpanded, label); if (property.isExpanded) { float w = position.width; position.width = c_LabelWidth; position.height = c_FieldHeight; float x = position.x; float y = position.y; EditorGUI.LabelField(position, label); InplaceSkillInfo info = property.serializedObject.targetObject as InplaceSkillInfo; Dictionary <int, InplaceSkillInfo.InplaceSkillPropertyInfoGroup> dict = info.Properties; foreach (var pair in dict) { int skillId = pair.Key; var group = pair.Value; position.x = x; position.y += c_FieldHeight; group.IsFoldOut = EditorGUI.Foldout(position, group.IsFoldOut, "============<" + skillId + ">============"); if (group.IsFoldOut) { //技能可视编辑特性部分 if (null != group.PropertyList) { string lastGroup = string.Empty; foreach (var p in group.PropertyList) { position.x = x; position.y += c_FieldHeight; position.width = c_LabelWidth; if (lastGroup == p.Group) { EditorGUI.LabelField(position, string.Empty); } else { EditorGUI.LabelField(position, GetIndentLabel(p.Group)); } position.x += c_LabelWidth; position.width = 160; EditorGUI.LabelField(position, null == p.Key ? string.Empty : p.Key); var prop = p.Property; if (null != prop && prop.Value is AnimationCurve) { float tx = position.x; position.x += 160; EditorGUI.BeginChangeCheck(); object v = EditorGUI.CurveField(position, prop.Value as AnimationCurve); if (EditorGUI.EndChangeCheck()) { prop.Value = v; } position.x = tx + 120; position.width = 40; if (GUI.Button(position, "拷贝")) { AnimationCurve curve = v as AnimationCurve; if (null != curve) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < curve.keys.Length; ++i) { Keyframe key = curve.keys[i]; sb.AppendFormat("keyframe({0},{1},{2},{3});", key.time, key.value, key.inTangent, key.outTangent); sb.AppendLine(); } string text = sb.ToString(); TextEditor editor = new TextEditor(); editor.text = text; //editor.content = new GUIContent(text); editor.OnFocus(); editor.Copy(); } } } else { position.x += 160; EditProperty(position, p.Property); } lastGroup = p.Group; } } //技能资源(这里就不允许新加资源了,只能修改) TableConfig.Skill skillCfg = TableConfig.SkillProvider.Instance.GetSkill(skillId); if (null != skillCfg) { position.x = x; position.y += c_FieldHeight; position.width = c_LabelWidth; EditorGUI.LabelField(position, "=================="); position.x += c_LabelWidth; position.width = 160; EditorGUI.LabelField(position, "SkillResources"); position.x += 160; EditorGUI.LabelField(position, "============"); bool first = true; Dictionary <string, string> modifiedResources = new Dictionary <string, string>(); foreach (var resPair in skillCfg.resources) { string key = resPair.Key; string path = resPair.Value; position.x = x; position.y += c_FieldHeight; position.width = c_LabelWidth - 80; if (first) { EditorGUI.LabelField(position, ">>>resource"); } else { EditorGUI.LabelField(position, string.Empty); } first = false; position.width = 80; position.x += c_LabelWidth - 80; EditorGUI.LabelField(position, key); position.width = 160; position.x += 80; string[] guids = AssetDatabase.FindAssets("t:Prefab," + Path.GetFileName(path)); Object v = null; for (int i = 0; i < guids.Length; ++i) { string p = AssetDatabase.GUIDToAssetPath(guids[i]); if (p.Contains("Resources/" + path)) { v = AssetDatabase.LoadAssetAtPath <GameObject>(p); break; } } EditorGUI.BeginChangeCheck(); v = EditorGUI.ObjectField(position, v, typeof(GameObject), false); if (EditorGUI.EndChangeCheck()) { string respath = AssetDatabase.GetAssetPath(v.GetInstanceID()); int startIndex = respath.IndexOf(c_Resources); if (startIndex >= 0) { path = respath.Substring(startIndex + c_Resources.Length, respath.Length - startIndex - c_Resources.Length - c_Ext.Length); } else { path = respath; } modifiedResources.Add(key, path); } position.width = w - c_LabelWidth - 160; position.x += 160; EditorGUI.LabelField(position, path); } foreach (var resPair in modifiedResources) { skillCfg.resources[resPair.Key] = resPair.Value; } } } } } EditorGUI.EndProperty(); }
private void LoadEditedSkills(int targetId) { PlayerPrefs.SetInt("TargetId", targetId); PlayerPrefs.Save(); SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt")); CopyTableAndDslFiles(); ClientModule.LoadTableConfig(); PredefinedSkill.Instance.ReBuild(); GfxSkillSystem.Instance.Reset(); GfxSkillSystem.Instance.ClearSkillInstancePool(); SkillSystem.SkillConfigManager.Instance.Clear(); GameObject actor = GameObject.Find("Editor_ActorRecord"); GameObject skills = GameObject.Find("Editor_SkillRecords"); if (null != actor && null != skills) { ActorRecord actorRecord = actor.GetComponent<ActorRecord>(); SkillRecords skillRecords = skills.GetComponent<SkillRecords>(); if (null != actorRecord && null != skillRecords) { List<int> args = new List<int>(); int actorId = actorRecord.id; if (actorRecord.skill0 > 0) args.Add(actorRecord.skill0); if (actorRecord.skill1 > 0) args.Add(actorRecord.skill1); if (actorRecord.skill2 > 0) args.Add(actorRecord.skill2); if (actorRecord.skill3 > 0) args.Add(actorRecord.skill3); if (actorRecord.skill4 > 0) args.Add(actorRecord.skill4); if (actorRecord.skill5 > 0) args.Add(actorRecord.skill5); if (actorRecord.skill6 > 0) args.Add(actorRecord.skill6); if (actorRecord.skill7 > 0) args.Add(actorRecord.skill7); if (actorRecord.skill8 > 0) args.Add(actorRecord.skill8); RebuildVisualSkillInfo(actorId); bool isValid = true; if (string.IsNullOrEmpty(actorRecord.avatar)) { Debug.LogErrorFormat("actor avatar is empty !!!"); isValid = false; } foreach (int skillId in args) { CheckEditedSkill(skillId, skillRecords.records, ref isValid); } if (isValid) { TableConfig.Actor actorInfo = TableConfig.ActorProvider.Instance.GetActor(actorId); if (null == actorInfo) { actorInfo = new TableConfig.Actor(); actorInfo.id = actorId; TableConfig.ActorProvider.Instance.ActorMgr.GetData().Add(actorId, actorInfo); } actorRecord.CopyTo(actorInfo); foreach (SkillRecords.SkillRecord record in skillRecords.records) { TableConfig.Skill skillInfo = TableConfig.SkillProvider.Instance.GetSkill(record.id); if (null == skillInfo) { skillInfo = new TableConfig.Skill(); skillInfo.id = record.id; TableConfig.SkillProvider.Instance.SkillMgr.GetData().Add(record.id, skillInfo); } record.CopyTo(skillInfo); } if (args.Count > 1) { GfxStorySystem.Instance.SendMessage("reload", actorId, targetId, args); } } } UnityEditor.EditorUtility.DisplayDialog("提示", "编辑英雄与技能加载完毕", "ok"); } }
private void LoadEditedSkills(int targetId) { PlayerPrefs.SetInt("TargetId", targetId); PlayerPrefs.Save(); SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt")); CopyTableAndDslFiles(); PluginFramework.LoadTableConfig(); PredefinedSkill.Instance.ReBuild(); GfxSkillSystem.Instance.Reset(); GfxSkillSystem.Instance.ClearSkillInstancePool(); SkillSystem.SkillConfigManager.Instance.Clear(); GameObject actor = GameObject.Find("Editor_ActorRecord"); GameObject skills = GameObject.Find("Editor_SkillRecords"); if (null != actor && null != skills) { ActorRecord actorRecord = actor.GetComponent <ActorRecord>(); SkillRecords skillRecords = skills.GetComponent <SkillRecords>(); if (null != actorRecord && null != skillRecords) { List <int> args = new List <int>(); int actorId = actorRecord.id; if (actorRecord.skill0 > 0) { args.Add(actorRecord.skill0); } if (actorRecord.skill1 > 0) { args.Add(actorRecord.skill1); } if (actorRecord.skill2 > 0) { args.Add(actorRecord.skill2); } if (actorRecord.skill3 > 0) { args.Add(actorRecord.skill3); } if (actorRecord.skill4 > 0) { args.Add(actorRecord.skill4); } if (actorRecord.skill5 > 0) { args.Add(actorRecord.skill5); } if (actorRecord.skill6 > 0) { args.Add(actorRecord.skill6); } if (actorRecord.skill7 > 0) { args.Add(actorRecord.skill7); } if (actorRecord.skill8 > 0) { args.Add(actorRecord.skill8); } RebuildVisualSkillInfo(actorId); bool isValid = true; if (string.IsNullOrEmpty(actorRecord.avatar)) { Debug.LogErrorFormat("actor avatar is empty !!!"); isValid = false; } foreach (int skillId in args) { CheckEditedSkill(skillId, skillRecords.records, ref isValid); } if (isValid) { TableConfig.Actor actorInfo = TableConfig.ActorProvider.Instance.GetActor(actorId); if (null == actorInfo) { actorInfo = new TableConfig.Actor(); actorInfo.id = actorId; TableConfig.ActorProvider.Instance.ActorMgr.GetData().Add(actorId, actorInfo); } actorRecord.CopyTo(actorInfo); foreach (SkillRecords.SkillRecord record in skillRecords.records) { TableConfig.Skill skillInfo = TableConfig.SkillProvider.Instance.GetSkill(record.id); if (null == skillInfo) { skillInfo = new TableConfig.Skill(); skillInfo.id = record.id; TableConfig.SkillProvider.Instance.SkillMgr.GetData().Add(record.id, skillInfo); } record.CopyTo(skillInfo); } if (args.Count > 1) { GfxStorySystem.Instance.SendMessage("reload", actorId, targetId, BoxedValue.From(args)); } } } UnityEditor.EditorUtility.DisplayDialog("提示", "编辑英雄与技能加载完毕", "ok"); } }