using CommonAI.Zone.Instance; using CommonAI.Zone.Formula; using System; using System.Collections.Generic; using System.Linq; using System.Text; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator; using CommonAI.Data; using CommonAI.Zone; namespace XmdsCommonSkill.Plugin.Buffs { /// /// 烙印标记,buff创建者攻击buff拥有者,改变拥有者属性 /// public class XmdsBuff_Brand_4 : XmdsBuffBase { public int ChangePropValue = 0; public XmdsVirtual.PropChangeOperation.OperateType isPrecent = XmdsVirtual.PropChangeOperation.OperateType.Value; public XmdsVirtual.UnitAttributeType ChangePropType = XmdsVirtual.UnitAttributeType.None; private int mHandleUUID = 0; private int mOpID = 0; private uint mSenderID = 0; private int mBuffLayer = 0; private int mMaxOverLayer = 0; public override int GetAbilityID() { return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Brand_4; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_Brand_4; ret.ChangePropValue = this.ChangePropValue; ret.isPrecent = this.isPrecent; ret.ChangePropType = this.ChangePropType; base.CopyTo(other); } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state) { //注册监听. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null); this.mSenderID = attacker.mUnit.ID; this.mBuffLayer = -1; this.mMaxOverLayer = Math.Max(1, (int)state.Data.MaxOverlay); } void ResetFun(XmdsVirtual hitter) { if (mOpID > 0) { hitter.RemovePropChangeOperation(mOpID); mOpID = 0; } } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace) { //取消监听. hitter.UnRegistOnHitDamage(mHandleUUID); ResetFun(hitter); } //单位受到攻击 private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { if(attacker.mUnit.ID == this.mSenderID) { this.mBuffLayer = Math.Min(this.mBuffLayer + 1, this.mMaxOverLayer); if(this.mBuffLayer > 0) { ResetFun(hitted); XmdsVirtual.PropChangeOperation pco = hitted.CreatePropChangeOpertation(this); pco.Type = this.ChangePropType; pco.Value = this.ChangePropValue * this.mBuffLayer; pco.OpType = XmdsVirtual.PropChangeOperation.OperateType.Percent; mOpID = hitted.AddPropChangeOperation(pco); } //通知客户端显示 hitted.mUnit.queueEvent(new BuffDataNotify(hitted.mUnit.ID, this.BindBuffID, this.mSenderID, this.mBuffLayer)); } return damage; } protected override void OnDispose() { base.OnDispose(); } } }