123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517 |
- using CommonAI.Zone;
- using CommonAI.Zone.Instance;
- using CommonAI.Zone.Formula;
- using CommonAI.Zone.UnitTriggers;
- using CommonLang;
- using CommonLang.Log;
- using CommonLang.Property;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
- using CommonAI.Data;
- using XmdsCommonServer.XLS.Data;
- using XmdsCommonSkill.Plugin.CardSkill;
- using XmdsCommon.JSGModule.Interface;
- using XmdsCommonServer.Plugin.Base;
- using CommonAI.Zone.Helper;
- namespace XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills
- {
- #region Skill.
- public enum AbstractSkillType
- {
- Value1 = 0, //
- Value2 = 1, //
- Value3 = 2, //
- Value4 = 3, //
- }
- //技能老祖.
- public abstract class AbstractSkill : IComparable<AbstractSkill>
- {
- public AbstractSkill()
- {
- }
- public abstract int SkillID { get; }
- public int CompareTo(AbstractSkill obj)
- {
- SkillTypeAttribute desc_a = PropertyUtil.GetAttribute<SkillTypeAttribute>(this.GetType());
- SkillTypeAttribute desc_b = PropertyUtil.GetAttribute<SkillTypeAttribute>(obj.GetType());
- int r0 = desc_a.Category.CompareTo(desc_b.Category);
- if (r0 != 0)
- {
- return r0;
- }
- return this.SkillID - obj.SkillID;
- }
- public abstract void SkillDataChange(GameSkill gs, XmdsVirtual unit);
- public abstract int GetSkillValue(AbstractSkillType type);
- /// <summary>
- /// 初始化完所有技能回调
- /// </summary>
- public virtual void InitOver(XmdsVirtual unit, GameSkill info) { OnInitOver(unit, info); }
- protected virtual void OnInitOver(XmdsVirtual unit, GameSkill info) { }
- protected void InitData(XmdsSkillData data, out XmdsSkillValue v, XmdsSkillData.XmdsSkillDataKey key)
- {
- try
- {
- v = data.GetParamValue(key);
- }
- catch (Exception error)
- {
- XmdsBattleHelper.LogError(string.Format("Skill【{0}】InitSkillParam【{1}】 \r\nError:{2}", this.SkillID, key, error.ToString()));
- v = XmdsSkillValue.Default;
- }
- }
- //接口之前相互手动调用
- public virtual void DoSkillDispose(int skillID) { }
- }
- //技能基类.
- public abstract class UnitSkill : AbstractSkill {
- protected static Logger log = LoggerFactory.GetLogger("XmdsBattleSkill");
- //技能是否激活
- private bool mIsActive = true;
- public bool IsActive{get{return this.mIsActive;} set{this.mIsActive = value;}
- }
- /// <summary>
- /// 初始化主动技能
- /// </summary>
- public void Init(GameSkill info, XmdsVirtual unit, ref SkillTemplate template)
- {
- OnRegistEvent();
- OnBaseInit(info, unit, ref template);
- //伤害监听.
- if (unit != null)
- {
- unit.RegistCalDamage(OnCallDamageProcess, info, false, this.SkillID);
- //技能MP消耗预判.
- unit.RegistTryLaunchSkillEvent(OnUnitLaunchSkillEvent, info, false);
- //技能MP消耗.
- unit.RegistLaunchSkillOver(OnUnitLaunchSkillOver, info, false);
- }
- }
- //只调用一次的初始化
- public void InitSkillParam(XmdsSkillData skillData)
- {
- OnBaseDataInit(skillData);
- OnInitSkillParam();
- }
- public override void SkillDataChange(GameSkill gs, XmdsVirtual unit)
- {
- OnSkillDataChange(gs, unit);
- }
- protected virtual void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
- {
- }
- protected virtual void OnBaseDataInit(XmdsSkillData skillData) { }
- protected virtual void OnInitSkillParam()
- {
- }
- // 每次加载技能都会调用。初始化配置,针对于人物技能多重继承
- protected virtual void OnInitConfig()
- {
- }
- protected virtual void OnRegistEvent()
- {
- }
- protected virtual void OnBaseInit(GameSkill info, XmdsVirtual unit, ref SkillTemplate template)
- {
- }
- private int OnHitProcess(XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, GameSkill gs, ref XmdsCommonServer.Plugin.XmdsVirtual.AtkResult result)
- {
- int ret = 0;
- //技能逻辑.
- return ret;
- }
- /// <summary>
- /// 计算伤害事件结果.
- /// </summary>
- /// <param name="attacker"></param>
- /// <param name="hitter"></param>
- /// <param name="source"></param>
- /// <param name="gs"></param>
- /// <param name="result"></param>
- /// <returns></returns>
- public virtual bool OnCallDamageProcess(XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, GameSkill gs, ref XmdsCommonServer.Plugin.XmdsVirtual.AtkResult result, ref int damage)
- {
- return true;
- }
- /// <summary>
- /// 技能施放预判断.
- /// </summary>
- /// <param name="skill"></param>
- /// <param name="launcher"></param>
- /// <returns></returns>
- protected virtual bool OnUnitLaunchSkillEvent(GameSkill info, ref InstanceUnit.SkillState skill, XmdsVirtual launcher, ref InstanceUnit.LaunchSkillParam param)
- {
- return true;
- }
- /// <summary>
- /// 技能施放完成监听.
- /// </summary>
- /// <param name="costEnergy"></param>
- /// <param name="attacker"></param>
- /// <param name="state"></param>
- /// <returns></returns>
- protected virtual int OnUnitLaunchSkillOver(GameSkill info, XmdsCommonServer.Plugin.XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.SkillState state)
- {
- return 0;
- }
- /// <summary>
- /// 输出错误日志.
- /// </summary>
- /// <param name="text"></param>
- protected virtual void LogError(string text = null)
- {
- if (text != null)
- {
- log.Error(string.Format("技能【{0}】配置错误:{1}", SkillID, text));
- }
- else
- {
- log.Error(string.Format("技能【{0}】配置错误", SkillID));
- }
- }
- public virtual bool SkillAutoLaunchTest(InstanceUnit.SkillState ss, XmdsVirtual launcher) { return true; }
- public void Update(int intervalMS, bool slowRefresh) { OnUpdate(intervalMS, slowRefresh); }
- protected virtual void OnUpdate(int intervalMS, bool slowRefresh) { }
- /// <summary>
- /// 技能被销毁.
- /// </summary>
- public virtual void Dispose() { }
- }
- #endregion
- #region PassiveSkills
- public abstract class UnitPassiveSkill : AbstractSkill
- {
- protected static Logger log = LoggerFactory.GetLogger("XmdsBattleSkill");
- public void Init(GameSkill skillInfo, XmdsVirtual owner)
- {
- this.OnInitConfig(skillInfo);
- OnInit(skillInfo, owner);
- }
- //只调用一次的初始化
- public void InitSkillParam()
- {
- OnInitSkillParam();
- }
- protected virtual void OnInitSkillParam()
- {
- }
- // 每次加载技能都会调用。初始化配置,针对于人物技能多重继承
- protected virtual void OnInitConfig(GameSkill skillInfo)
- {
- }
- public void Update(int intervalMS, bool slowRefresh) { OnUpdate(intervalMS, slowRefresh); }
- public void Dispose(XmdsVirtual owner) { OnDispose(owner); }
- protected virtual void OnDispose(XmdsVirtual owner) { }
- protected virtual void OnInit(GameSkill skillInfo, XmdsVirtual owner) { }
- protected virtual void OnUpdate(int intervalMS, bool slowRefresh) { }
- protected virtual void LogError(string text = null)
- {
- if (text != null) { log.Error(string.Format("被动技能【{0}】配置错误:{1}", SkillID, text)); }
- else { log.Error(string.Format("被动技能【{0}】配置错误", SkillID)); }
- }
- public virtual bool ValidParameter(int lv, float[] formula)
- {
- bool ret = false;
- if (lv > formula.Length || lv <= 0) { ret = false; LogError(); }
- else { ret = true; }
- return ret;
- }
- public virtual int GetCDTotalTime() { return 0; }
- public virtual int GetCDPassTime() { return 0; }
- public virtual void SetCDPassTime(int timeMS) { }
- public virtual int GetDecreaseTotalTimeMS() { return 0; }
- public virtual void SetDecreaseTotalTimeMS(int timeMS) { }
- public override void SkillDataChange(GameSkill gs, XmdsVirtual unit)
- {
- OnSkillDataChange(gs, unit);
- }
- protected virtual void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
- {
- }
- }
- #endregion
- #region BUFF.
- /// <summary>
- /// BUFF基类.
- /// </summary>
- public abstract class UnitBuff : XmdsBuffVirtual
- {
- //buff等级.
- private int mBuffLv = 0;
- //绑定编辑器BUFF.
- protected int BindBuffID = 0;
- /// <summary>
- /// 是否无效.
- /// </summary>
- protected bool mInvalid = false;
- /// <summary>
- /// 能力ID(决定buff作用.)
- /// </summary>
- public abstract int GetAbilityID();
- /// <summary>
- /// BUFF等级.
- /// </summary>
- public virtual int BuffLV
- {
- set
- {
- mBuffLv = value;
- }
- get
- {
- return mBuffLv;
- }
- }
- public int GetBindBuffID()
- {
- return this.BindBuffID;
- }
- protected virtual void OnBindTemplate(ref BuffTemplate buffTemplate)
- {
- }
- //重载BUFF模板,修改属性.
- public void OverrideTemplate(ref BuffTemplate buffTemplate)
- {
- BindBuffID = buffTemplate.ID;
- (buffTemplate.Properties as XmdsBuffProperties).addBuffVirtual(this);
- OnBindTemplate(ref buffTemplate);
- }
- public virtual void BuffBegin(XmdsVirtual hitter, XmdsVirtual attacker, InstanceUnit.BuffState state)
- {
- }
- public virtual void BuffEnd(XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
- {
- }
- public virtual int BuffHit(XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result)
- {
- return 0;
- }
- /// <summary>
- /// 是否有
- /// </summary>
- /// <returns></returns>
- public bool IsInvaild() { return mInvalid; }
- public virtual void CopyTo(UnitBuff other)
- {
- other.BindBuffID = this.BindBuffID;
- other.mBuffLv = this.mBuffLv;
- }
- public virtual void BuffUpdate(XmdsVirtual unit, InstanceUnit.BuffState state) { }
- }
- #endregion
- #region 事件监听.
- //监听事件.
- /// <summary>
- /// 产生伤害监听.
- /// </summary>
- public delegate float IOnHit(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch);
- /// <summary>
- /// 被动触发监听
- /// </summary>
- public delegate void IOnTriggerStart(XmdsVirtual unit, XmdsVirtual target, UnitTriggerTemplate trigger, GameSkill sk);
- /// <summary>
- /// 测试Buff监听.
- /// </summary>
- public delegate void IOnBuffEvent(XmdsVirtual unit, InstanceUnit.BuffState buff, string result, GameSkill sk);
- /// <summary>
- /// 测试技能监听.
- /// </summary>
- public delegate bool ITestLaunchSkill(XmdsVirtual unit, InstanceUnit.SkillState skill, GameSkill sk);
- /// <summary>
- ///伤害计算监听.
- /// </summary>
- /// <param name="attacker"></param>
- /// <param name="hitter"></param>
- /// <param name="source"></param>
- /// <returns></returns>
- public delegate bool ICalDamage(XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, GameSkill gs, ref XmdsCommonServer.Plugin.XmdsVirtual.AtkResult result, ref int damage);
- /// <summary>
- ///仇恨计算监听.
- /// </summary>
- /// <param name="attacker"></param>
- /// <param name="hitter"></param>
- /// <param name="source"></param>
- /// <returns></returns>
- public delegate void ICalThreadValue(XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, GameSkill gs, ref XmdsCommonServer.Plugin.XmdsVirtual.AtkResult result);
- /// <summary>
- /// 技能释放完毕.
- /// </summary>
- /// <param name="attacker"></param>
- /// <param name="state"></param>
- /// <returns></returns>
- public delegate int ILaunchSkillOver(GameSkill info, XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.SkillState state);
- /// <summary>
- /// 测试攻击目标监听.
- /// </summary>
- /// <param name="target"></param>
- /// <param name="sk"></param>
- /// <returns></returns>
- public delegate XmdsVirtual IGetAtkTarget(XmdsVirtual target, GameSkill sk);
- public delegate void IGetSkillDamageInfo(XmdsVirtual attacker, XmdsVirtual hitter,
- ref AttackSource source, GameSkill gs);
- /// <summary>
- /// 技能结束监听.
- /// </summary>
- /// <param name="owner"></param>
- /// <param name="state"></param>
- public delegate void IStateSkillEnd(XmdsVirtual owner, InstanceUnit.StateSkill state, GameSkill gs);
- /// <summary>
- /// 添加buff监听.
- /// </summary>
- /// <param name="buff"></param>
- /// <param name="attacker"></param>
- /// <param name="hitter"></param>
- public delegate bool ITryAddBuffEvent(ref BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter, GameSkill skill);
- public delegate bool IRemoveBuffEvent(ref BuffTemplate buff, XmdsVirtual player, BuffRemoveType type);
- /** 给其他玩家添加buff监听. */
- public delegate void ISendBuffEvent(BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter);
- /// <summary>
- /// 重定向Spell监听.
- /// </summary>
- /// <param name="spell"></param>
- /// <param name="launcher"></param>
- public delegate void ITrySendSpellEvent(GameSkill skill, XmdsVirtual launcher, LaunchSpell launch, ref SpellTemplate spell, ref JSGCreateSpellData createData, ref float startX, ref float startY);
- //法术释放完毕
- public delegate void ISendSpellOverEvent(LaunchSpell launch, XmdsVirtual launcher, SpellTemplate spell, GameSkill skill, float startX, float startY);
- /// <summary>
- /// 监听施放技能.
- /// </summary>
- /// <param name="skill"></param>
- /// <param name="launcher"></param>
- public delegate bool ITryLaunchSkillEvent(GameSkill skillInfo, ref InstanceUnit.SkillState skill, XmdsVirtual launcher, ref InstanceUnit.LaunchSkillParam param);
- /// <summary>
- /// 触发宠物提供给人物的技能能力
- /// 返回true,结束下层传递
- /// </summary>
- /// <param name="skill"></param>
- /// <param name="launcher"></param>
- public delegate bool ITriggerPetSkillEvent(GameSkill skillInfo, ref InstanceUnit.SkillState skill, XmdsVirtual launcher, ref InstanceUnit.LaunchSkillParam param);
- /// <summary>
- /// 技能被打断事件通知
- ///
- /// </summary>
- /// <param name="skill"></param>
- /// <param name="launcher"></param>
- public delegate bool ISkillBlockEvent(XmdsVirtual launcher, InstanceUnit.StateSkill skill, InstanceUnit.State newState);
- /**
- * hp < 0加血事件, sender: 发送者,hitter:被加血的人
- * hp > =0扣血, sender:攻击者,hitter: 要扣血的
- * */
- public delegate bool IAddOtherHPEvent(int hp, InstanceUnit sender, InstanceUnit hitter, AttackSource source, out int finalHP);
- //宠物承担主人伤害事件
- public delegate int IShareMasterDmgEvent(int hp, InstanceUnit sender, InstanceUnit unit, GameSkill info, ref bool isEndDispatch);
- //扣定力
- public delegate bool IReduceOtherMpEvent(int mp, InstanceUnit sender, InstanceUnit hitter, out int finalMP, AttackSource source);
- //得卡牌球
- public delegate bool ITryAddCardBallEvent(XmdsVirtual player, CreateCardBallSource type, CardType cardType);
- //释放卡牌技能
- public delegate bool ITriggerCardSkillEvent(XmdsVirtual player, XmdsVirtual hitter, GameSkill info, CardType cardType, int sameNums);
- public delegate bool IOnKillOtherUnitEvent(XmdsVirtual attacker, XmdsVirtual deader, GameSkill info);
- #endregion
- #region 战斗特殊事件.
- #endregion
- }
|