XmdsBuff_AddBuff.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using CommonAI.Zone;
  2. using CommonAI.Zone.Formula;
  3. using CommonAI.Zone.Instance;
  4. using CommonLang;
  5. using System;
  6. using XmdsCommon.Plugin;
  7. using XmdsCommonServer.Plugin;
  8. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  9. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  10. namespace XmdsCommonSkill.Plugin.Buffs
  11. {
  12. /// <summary>
  13. ///BUFF:buff每秒触发,附近队友附加相应buff
  14. /// </summary>
  15. public class XmdsBuff_AddBuff : XmdsBuffBase
  16. {
  17. //增加buffID
  18. public int addBuffId = 0;
  19. //附近队友范围
  20. public int addBuffRange = 5;
  21. public override int GetAbilityID()
  22. {
  23. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.AddBuff;
  24. }
  25. public override void CopyTo(UnitBuff other)
  26. {
  27. var ret = other as XmdsBuff_AddBuff;
  28. ret.addBuffId = this.addBuffId;
  29. ret.addBuffRange = this.addBuffRange;
  30. base.CopyTo(other);
  31. }
  32. protected override void OnBindTemplate(ref BuffTemplate buffTemplate)
  33. {
  34. //DOT类技能首帧无效.
  35. buffTemplate.FirstTimeEnable = false;
  36. base.OnBindTemplate(ref buffTemplate);
  37. }
  38. protected override int OnBuffHit(XmdsVirtual hitter,
  39. XmdsVirtual attacker, CommonAI.Zone.Formula.AttackSource source,
  40. ref XmdsVirtual.AtkResult result)
  41. {
  42. //血量平分
  43. //治疗自己和队友
  44. using (var list = ListObjectPool<InstanceUnit>.AllocAutoRelease())
  45. {
  46. attacker.mUnit.Parent.getObjectsRoundRange<InstanceUnit>(
  47. (obj, dx, dy, dr) =>
  48. {
  49. var u = obj as InstanceUnit;
  50. //己方单位.
  51. if (attacker.IsAllies(u.Virtual as XmdsVirtual, false, true))
  52. {
  53. return CMath.includeRoundPoint(dx, dy, dr, u.X, u.Y);
  54. }
  55. return false;
  56. },
  57. attacker.mUnit.X,
  58. attacker.mUnit.Y,
  59. addBuffRange,
  60. list, attacker.mUnit.AoiStatus);
  61. //加血 & 加速
  62. for (int i = 0; i < list.Count; i++)
  63. {
  64. list[i].AddBuff(this.addBuffId, attacker.mUnit);
  65. }
  66. }
  67. return base.OnBuffHit(hitter, attacker, source, ref result); ;
  68. }
  69. }
  70. }