ChangeAttrPercentFunEvent.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using System.Collections;
  3. public class ChangeAttrPercentFunEvent : DurationFunctionEvent
  4. {
  5. public static ChangeAttrPercentFunEvent Creator(BuffFunctionData data)
  6. {
  7. return new ChangeAttrPercentFunEvent(data);
  8. }
  9. public ChangeAttrPercentFunEvent(BuffFunctionData data):base(data)
  10. {
  11. mType = data.functionType;
  12. }
  13. public override float GetValue()
  14. {
  15. float fCostHp;
  16. float fCostPrecent;
  17. int MaxPrecent = 0;
  18. int.TryParse(Data.extendParam, out MaxPrecent);
  19. switch (mType)
  20. {
  21. case Buff_Function_Type.Attack_Change_ByTargetCostHpPercent:
  22. case Buff_Function_Type.MagicAttack_Change_ByTargetCostHpPercent:
  23. fCostHp = HitInfo.Target.MaxLife - HitInfo.Target.Life;
  24. fCostPrecent = (float)fCostHp / (float)HitInfo.Target.MaxLife;
  25. return Mathf.Min( fCostPrecent * base.GetValue() * 0.01f, MaxPrecent);
  26. case Buff_Function_Type.Attack_Change_BySourceCostHpPercent:
  27. case Buff_Function_Type.MagicAttack_Change_BySourceCostHpPercent:
  28. fCostHp = HitInfo.Caster.MaxLife - HitInfo.Caster.Life;
  29. fCostPrecent = (float)fCostHp / (float)HitInfo.Target.MaxLife;
  30. return Mathf.Min(fCostPrecent * base.GetValue() * 0.01f,MaxPrecent);
  31. case Buff_Function_Type.Attack_Change_ByTargetCurHpPercent:
  32. case Buff_Function_Type.MagicAttack_Change_ByTargetCurHpPercent:
  33. fCostPrecent = (float)HitInfo.Target.Life / (float)HitInfo.Target.MaxLife;
  34. return Mathf.Min(fCostPrecent * base.GetValue() * 0.01f,MaxPrecent);
  35. case Buff_Function_Type.Attack_Change_BySourceCurHpPercent:
  36. case Buff_Function_Type.MagicAttack_Change_BySourceCurHpPercent:
  37. fCostPrecent = (float)HitInfo.Caster.Life / (float)HitInfo.Caster.MaxLife;
  38. return Mathf.Min(fCostPrecent * base.GetValue() * 0.01f,MaxPrecent);
  39. default:
  40. return base.GetValue();
  41. }
  42. }
  43. }