123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
-
- using CommonAI.Data;
- using CommonAI.Zone.Formula;
- using CommonAI.Zone.Instance;
- using System;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
- namespace XmdsCommonSkill.Plugin.Buffs
- {
- /// <summary>
- /// 护盾BUFF.限制单位每次最多受到的伤害.
- /// </summary>
- public class XmdsBuff_Shield_LimitingDamage : XmdsBuffBase
- {
- /// <summary>
- /// 吸收伤害总量.
- /// </summary>
- public int AbsorbDamageSum = 0;
- /// <summary>
- /// 是否吸收过量伤害.
- /// </summary>
- public bool AbsorbOverFlowDamage = true;
- private int mLimitingDamage = 1;
- /// <summary>
- /// 单次攻击最多可受的伤害.
- /// </summary>
- public int LimitingDamage
- {
- get { return mLimitingDamage; }
- set { mLimitingDamage = Math.Max(1, value); }
- }
- private int mHandleUUID = 0;
- public override int GetAbilityID()
- {
- return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.SHIELD_LimitingDamage;
- }
- public override void CopyTo(UnitBuff other)
- {
- var ret = other as XmdsBuff_Shield_LimitingDamage;
- ret.AbsorbDamageSum = this.AbsorbDamageSum;
- ret.AbsorbOverFlowDamage = this.AbsorbOverFlowDamage;
- ret.LimitingDamage = this.LimitingDamage;
- base.CopyTo(other);
- }
- protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
- {
- //注册监听.
- mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
- XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】增加限制伤害护盾.", 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}】失去限制伤害护盾.", 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)
- {
- int ret = (int)damage;
- //damage > 0是伤害,damage < 0是加血机制.
- if (damage > 0 && AbsorbDamageSum > 0)
- {
- //if (ret > LimitingDamage)
- //{
- ret = LimitingDamage;
- //}
- hitted.SendBattleHintNumberB2C(ret, XmdsVirtual.UnitHitEventState.Normal);
- AbsorbDamageSum -= ret;
- AbsorbDamageSum = Math.Max(0, AbsorbDamageSum);
- if (AbsorbDamageSum <= 0)
- {
- //破盾.
- hitted.mUnit.removeBuff(BindBuffID);
- }
- }
- return 0;
- }
- }
- }
|