using CommonAI.Zone; using CommonAI.ZoneClient; using CommonLang; using ET; using ET.Client; using ET.EventType; using ProtoBuf; using System.ComponentModel; using XmdsCommon.Plugin; [Event(SceneType.None)] public class LaunchSkillEventHandler : BEvent { public override void OnEvent(LaunchSkillEvent a) { var actor = UnitMgr.Instance.Actor; if(actor != null ) { var skillinfo = actor.GetSkill(a.index); if (skillinfo != null) { SkillMgr.Instance.LanchSkill(skillinfo.baseSkillId); } else { Log.Error($"skill info not exist @index: {a.index}"); } } else { Log.Warning("actor not exist"); } } } public class BattleActor : BattlePlayer { private bool isSkillInited = false; public bool IsSkillOk { get { return isSkillInited; } } private HashMap SkillLisst = new(); public SkillKeyStruct GetSkill(int index) { return SkillLisst[index]; } public override void OnAwake(ZoneObject zo) { base.OnAwake(zo); ZoneActor za = zo as ZoneActor; za.IsFollow = false; za.OnStartPickObject += OnStartPickObject; za.OnStopPickObject += OnStopPickObject; za.OnSkillChanged += OnSkillChanged; za.OnClickSkillSimulationEvent += OnClickSkillSimulationEvent; var uProp = za.Info.Properties as XmdsUnitProperties; Log.Debug($"pkMode: {uProp.ServerData.UnitPKInfo.CurPKMode}"); } private void OnSkillChanged(ZoneUnit.SkillOption op, ZoneUnit unit, int baseSkillID, params int[] skills) { //Log.Debug("OnSkillChanged> {0}, base:{1},skills:{2}", op, baseSkillID, skills != null ? skills.Length : 0); //SkillOption.Init的不用管,SkillBar.InitSkill直接从UserData读 //SkillOpetion.Active不明意义,未处理 if (op == ZoneUnit.SkillOption.Reset) { if(baseSkillID != 0) { if(skills.Length > 0) { skills[0] = baseSkillID; } else { skills = new int[] { baseSkillID }; } } InitSkill(skills); } else if (op == ZoneUnit.SkillOption.Add || op == ZoneUnit.SkillOption.Remove) { Log.Error($"not implements skill option: {op}"); } } public void InitSkill(params int[] skills) { isSkillInited = true; SkillLisst.Clear(); var CFG = UnitMgr.Instance.Actor.ZUnit.Templates; for (int i = 0; i < skills.Length; i++) { int skid = skills[i]; if (skid != 0) { SkillTemplate skt = CFG.getSkill(skid); SkillLisst[i] = new SkillKeyStruct() { keyPos = i, baseSkillId = skid, icon = skt.IconName }; } } EventSystem.Instance.Publish(); } private void OnStopPickObject(ZoneUnit unit, CommonAI.Zone.UnitStopPickObjectEvent stop) { Log.Error("unhande event: OnStopPickObject"); } private void OnStartPickObject(ZoneUnit unit, CommonLang.TimeExpire start) { Log.Error("unhande event: OnStartPickObject"); } private void OnClickSkillSimulationEvent(ZoneUnit unit, CommonAI.Zone.Helper.SimulationSkillEnum type) { Log.Error("unhande event: OnClickSkillSimulationEvent"); } }