XmdsBuff_SpeedUpAndIngoreCtrl.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using CommonAI.Zone;
  2. using CommonAI.Zone.Instance;
  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.Units;
  10. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  11. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  12. namespace XmdsCommonSkill.Plugin.Buffs
  13. {
  14. public class XmdsBuff_SpeedUpAndIngoreCtr : XmdsBuffBase
  15. {
  16. /// <summary>
  17. /// 传负值减速度,传正值加速度.
  18. /// </summary>
  19. public int ChangePercent = 0;
  20. private int mOpID = 0;
  21. private int uuid = 0;
  22. public override int GetAbilityID()
  23. {
  24. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.SpeedUpAndIngoreCtrl;
  25. }
  26. public override void CopyTo(UnitBuff other)
  27. {
  28. var ret = other as XmdsBuff_SpeedUpAndIngoreCtr;
  29. ret.ChangePercent = this.ChangePercent;
  30. base.CopyTo(other);
  31. }
  32. protected override void OnBuffBegin(XmdsVirtual hitter, XmdsVirtual attacker, InstanceUnit.BuffState state)
  33. {
  34. //float v = ChangePercent / XmdsDamageCalculator.PERER;
  35. //float cv = (hitter.mProp.ServerData.Prop.MoveSpeed * v);
  36. //移动速度变更.
  37. //hitter.AddMoveSpeed(cv);
  38. XmdsVirtual.PropChangeOperation pco = hitter.CreatePropChangeOpertation(this);
  39. pco.Type = XmdsVirtual.UnitAttributeType.MoveSpeed;
  40. pco.Value = ChangePercent;
  41. pco.OpType = XmdsVirtual.PropChangeOperation.OperateType.Percent;
  42. mOpID = hitter.AddPropChangeOperation(pco);
  43. XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】,移动速度变更{1}", hitter.mProp.ServerData.BaseInfo.name, ChangePercent);
  44. uuid = hitter.RegistTryAddBuffEvent(OnTryAddBuffEvent, null);
  45. XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】进入免控状态.", hitter.mProp.ServerData.BaseInfo.name);
  46. }
  47. protected override void OnBuffEnd(XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  48. {
  49. //移动速度变更.
  50. //hitter.AddMoveSpeed(-cv);
  51. hitter.RemovePropChangeOperation(mOpID);
  52. XmdsVirtual.FormatLog("BuffEnd : 单位【{0}】,移动速度变更{1}", hitter.mProp.ServerData.BaseInfo.name, ChangePercent);
  53. hitter.UnRegistTryAddBuffEvent(uuid);
  54. XmdsVirtual.FormatLog("BuffEnd : 单位【{0}】脱离免控状态", hitter.mProp.ServerData.BaseInfo.name);
  55. }
  56. private bool OnTryAddBuffEvent(ref BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter, GameSkill skill)
  57. {
  58. if (!IsInvaild() && XmdsInstanceUtils.IsControlBuff(buff))
  59. {
  60. hitter.SendBattleHintNumberB2C(0, XmdsVirtual.UnitHitEventState.Immunity);
  61. //每次生效自动检查.
  62. if (BuffInvaildCheck())
  63. {
  64. hitter.mUnit.removeBuff(BindBuffID);
  65. }
  66. return false;
  67. }
  68. return true;
  69. }
  70. }
  71. }