XmdsBuff_Brand_4.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using CommonAI.Zone.Instance;
  2. using CommonAI.Zone.Formula;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using XmdsCommon.Plugin;
  8. using XmdsCommonServer.Plugin;
  9. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  10. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  11. using CommonAI.Data;
  12. using CommonAI.Zone;
  13. namespace XmdsCommonSkill.Plugin.Buffs
  14. {
  15. /// <summary>
  16. /// 烙印标记,buff创建者攻击buff拥有者,改变拥有者属性
  17. /// </summary>
  18. public class XmdsBuff_Brand_4 : XmdsBuffBase
  19. {
  20. public int ChangePropValue = 0;
  21. public XmdsVirtual.PropChangeOperation.OperateType isPrecent = XmdsVirtual.PropChangeOperation.OperateType.Value;
  22. public XmdsVirtual.UnitAttributeType ChangePropType = XmdsVirtual.UnitAttributeType.None;
  23. private int mHandleUUID = 0;
  24. private int mOpID = 0;
  25. private uint mSenderID = 0;
  26. private int mBuffLayer = 0;
  27. private int mMaxOverLayer = 0;
  28. public override int GetAbilityID()
  29. {
  30. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.Brand_4;
  31. }
  32. public override void CopyTo(UnitBuff other)
  33. {
  34. var ret = other as XmdsBuff_Brand_4;
  35. ret.ChangePropValue = this.ChangePropValue;
  36. ret.isPrecent = this.isPrecent;
  37. ret.ChangePropType = this.ChangePropType;
  38. base.CopyTo(other);
  39. }
  40. protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
  41. {
  42. //注册监听.
  43. mHandleUUID = hitter.RegistOnHitDamage(OnHandleHitDmage, null);
  44. this.mSenderID = attacker.mUnit.ID;
  45. this.mBuffLayer = -1;
  46. this.mMaxOverLayer = Math.Max(1, (int)state.Data.MaxOverlay);
  47. }
  48. void ResetFun(XmdsVirtual hitter)
  49. {
  50. if (mOpID > 0)
  51. {
  52. hitter.RemovePropChangeOperation(mOpID);
  53. mOpID = 0;
  54. }
  55. }
  56. protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  57. {
  58. //取消监听.
  59. hitter.UnRegistOnHitDamage(mHandleUUID);
  60. ResetFun(hitter);
  61. }
  62. //单位受到攻击
  63. private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  64. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  65. {
  66. if(attacker.mUnit.ID == this.mSenderID)
  67. {
  68. this.mBuffLayer = Math.Min(this.mBuffLayer + 1, this.mMaxOverLayer);
  69. if(this.mBuffLayer > 0)
  70. {
  71. ResetFun(hitted);
  72. XmdsVirtual.PropChangeOperation pco = hitted.CreatePropChangeOpertation(this);
  73. pco.Type = this.ChangePropType;
  74. pco.Value = this.ChangePropValue * this.mBuffLayer;
  75. pco.OpType = XmdsVirtual.PropChangeOperation.OperateType.Percent;
  76. mOpID = hitted.AddPropChangeOperation(pco);
  77. }
  78. //通知客户端显示
  79. hitted.mUnit.queueEvent(new BuffDataNotify(hitted.mUnit.ID, this.BindBuffID, this.mSenderID, this.mBuffLayer));
  80. }
  81. return damage;
  82. }
  83. protected override void OnDispose()
  84. {
  85. base.OnDispose();
  86. }
  87. }
  88. }