XmdsBuff_PropChange.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using CommonAI.Zone.Instance;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using XmdsCommon.Message;
  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. /// FileName: XmdsBuff_PropChange.cs
  14. /// Author: Alex.Yu
  15. /// Corporation:...
  16. /// Description:
  17. /// DateTime: 2015/6/10 20:07:30
  18. /// </summary>
  19. public class XmdsBuff_PropChange : XmdsBuffBase
  20. {
  21. /// <summary>
  22. /// 当前变更类型.
  23. /// </summary>
  24. public XmdsVirtual.UnitAttributeType CurentChangeType = 0;
  25. public int CurrentValue = 0;
  26. public bool IsPercent = true;
  27. private List<int> mOpList = new List<int>();
  28. public override int GetAbilityID()
  29. {
  30. return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.PropChange | (int)CurentChangeType;
  31. }
  32. public override void CopyTo(UnitBuff other)
  33. {
  34. var ret = other as XmdsBuff_PropChange;
  35. ret.CurentChangeType = this.CurentChangeType;
  36. ret.CurrentValue = this.CurrentValue;
  37. ret.IsPercent = this.IsPercent;
  38. base.CopyTo(other);
  39. }
  40. protected override void OnBindTemplate(ref CommonAI.Zone.BuffTemplate buffTemplate)
  41. {
  42. base.OnBindTemplate(ref buffTemplate);
  43. }
  44. protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
  45. {
  46. int v = (state.OverlayLevel + 1) * CurrentValue;
  47. ChangeProp(hitter, CurentChangeType, v);
  48. int valueMax = hitter.mUnit.IsPlayer ? 10000 : 25000;
  49. if(state.OverlayLevel > 10 || v > valueMax)
  50. {
  51. log.Warn("XmdsBuff_PropChange信息输出:" + this.BindBuffID + ", 层:" + state.OverlayLevel + ", " + CurentChangeType + ", 值:" + v +
  52. ", hitter:" + hitter.mInfo.ID + ", attacker: " + attacker.mInfo.ID + ", 场景:" + hitter.mUnit.Parent.GetSceneID() + ", 百分比:" + this.IsPercent);
  53. }
  54. }
  55. protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
  56. {
  57. //指令集操作.
  58. for (int i = 0; i < mOpList.Count; i++)
  59. {
  60. hitter.RemovePropChangeOperation(mOpList[i]);
  61. }
  62. mOpList.Clear();
  63. }
  64. private void ChangeProp(XmdsVirtual hitter, XmdsVirtual.UnitAttributeType type, int effectValue)
  65. {
  66. if(type == XmdsVirtual.UnitAttributeType.None)
  67. {
  68. XmdsVirtual.FormatLog("单位【{0}】,属性变更BUFF未指定更改能力类型", hitter.mProp.ServerData.BaseInfo.name);
  69. return;
  70. }
  71. switch (type)
  72. {
  73. case XmdsVirtual.UnitAttributeType.Attack:
  74. SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.GONG_JI_SHANG_SHENG, effectValue);
  75. break;
  76. case XmdsVirtual.UnitAttributeType.Defence:
  77. SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.FANG_YU_SHANG_SHENG, effectValue);
  78. break;
  79. case XmdsVirtual.UnitAttributeType.HealEffect:
  80. SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.ZHI_LIAO_SHANG_SHENG, effectValue);
  81. break;
  82. case XmdsVirtual.UnitAttributeType.HealedEffect:
  83. SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.ZHI_LIAO_SHANG_SHENG, effectValue);
  84. break;
  85. case XmdsVirtual.UnitAttributeType.CritRate:
  86. SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.BAO_JI_SHANG_SHENG, effectValue);
  87. break;
  88. default:
  89. break;
  90. }
  91. XmdsVirtual.PropChangeOperation pco;
  92. pco = hitter.CreatePropChangeOpertation(this);
  93. pco.Type = type;
  94. pco.Value = effectValue;
  95. pco.OpType = GetOptType();
  96. mOpList.Add(hitter.AddPropChangeOperation(pco));
  97. }
  98. private float GetValue(float changeValue, float UnitProp)
  99. {
  100. float ret = 0;
  101. if (IsPercent == true)
  102. {
  103. ret = UnitProp * (changeValue / XmdsDamageCalculator.PERER);
  104. }
  105. else
  106. {
  107. ret = changeValue;
  108. }
  109. return ret;
  110. }
  111. private XmdsVirtual.PropChangeOperation.OperateType GetOptType()
  112. {
  113. if (IsPercent)
  114. {
  115. return XmdsVirtual.PropChangeOperation.OperateType.Percent;
  116. }
  117. else
  118. {
  119. return XmdsVirtual.PropChangeOperation.OperateType.Value;
  120. }
  121. }
  122. private void SendMsg(XmdsVirtual target, CommonAI.XmdsConstConfig.BattleFloatTipsType type, float effectvalue)
  123. {
  124. if (ShowBuffTips == false) { return; }
  125. if (effectvalue > 0)
  126. {
  127. BattleFloatTipsEventB2C evt = new BattleFloatTipsEventB2C();
  128. evt.Type = type;
  129. target.SendBattleFloatTipsEventB2C(evt);
  130. }
  131. }
  132. }
  133. }