123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- 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<LaunchSkillEvent>
- {
- 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<int, SkillKeyStruct> 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<SkillChangeEvent>();
- }
- private void OnStopPickObject(ZoneUnit unit, CommonAI.Zone.UnitStopPickObjectEvent stop)
- {
- Log.Error("unhande event: OnStopPickObject");
- }
- private void OnStartPickObject(ZoneUnit unit, CommonLang.TimeExpire<CommonAI.Zone.UnitStartPickObjectEvent> start)
- {
- Log.Error("unhande event: OnStartPickObject");
- }
- private void OnClickSkillSimulationEvent(ZoneUnit unit, CommonAI.Zone.Helper.SimulationSkillEnum type)
- {
- Log.Error("unhande event: OnClickSkillSimulationEvent");
- }
- }
|