12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using CommonAI.Data;
- using CommonAI.Zone;
- using CommonAI.Zone.Formula;
- using CommonAI.Zone.Instance;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
- namespace XmdsCommonSkill.Plugin.Buffs
- {
- /// <summary>
- /// 单位收到伤害回调.
- /// </summary>
- public class XmdsBuff_Event_OnHitDamage : XmdsBuffBase
- {
- private int mHandleUUID = 0;
- //绑定的技能信息
- public GameSkill bindSkill = null;
- public XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills.IOnHit OnHitDamageEvent;
- public override int GetAbilityID()
- {
- return (int)XmdsBuffProperties.XmdsBuffAbility.Event_OnHitDamageEvent;
- }
- public override void CopyTo(UnitBuff other)
- {
- var ret = other as XmdsBuff_Event_OnHitDamage;
- ret.bindSkill = this.bindSkill;
- ret.OnHitDamageEvent = this.OnHitDamageEvent;
- base.CopyTo(other);
- }
- protected override void OnBindTemplate(ref BuffTemplate buffTemplate)
- {
- //关联性BUFF必须在施放者死亡后清除.
- buffTemplate.IsRemoveOnSenderRemoved = true;
- base.OnBindTemplate(ref buffTemplate);
- }
- protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
- {
- //注册监听.
- mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
- XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】增加OnHandleHitDmage事件监听.", hitter.mProp.ServerData.BaseInfo.name);
- }
- protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
- {
- //取消监听.
- hitter.UnRegistOnHitDamage(mHandleUUID);
- XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】去除OnHandleHitDmage事件监听.", hitter.mProp.ServerData.BaseInfo.name);
- }
- private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
- {
- if (OnHitDamageEvent != null)
- {
- OnHitDamageEvent.Invoke(damage, hitted, attacker, source, ref result,
- damageType, bindSkill, ref isEndDispatch);
- }
- return damage;
- }
- protected override void OnDispose()
- {
- //OnHitDamageEvent = null;
- base.OnDispose();
- }
- }
- }
|