HealHPPercent.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEngine;
  2. using System.Collections;
  3. public class HealHPPercent : TickFunctionEvent
  4. {
  5. public static HealHPPercent Creator(BuffFunctionData data)
  6. {
  7. return new HealHPPercent(data);
  8. }
  9. public HealHPPercent(BuffFunctionData data):base(data)
  10. {
  11. }
  12. public override void Enter(Fighter fighter)
  13. {
  14. base.Enter(fighter);
  15. if (null == fighter) return;
  16. if (fighter.IsAlive)
  17. {
  18. float hp = (fighter.GetAttrByType(Data.fromAttr) * fighter.GetBuffPercentValue(Buff_Function_Type.Heal_Change_Percent_From_Target));
  19. int addHp = (int)(hp * (1 + fighter.GetBuffPercentValue(Buff_Function_Type.Heal_Change_Percent)));
  20. fighter.Life += addHp;
  21. if (Caster != null)
  22. {
  23. EventMgr.DispatchEvent<Fighter>(new CoreEvent<Fighter>(ECoreEventType.EID_Fighter_Treatment, mCaster));
  24. if (Caster.Statistics!=null)
  25. Caster.Statistics.StatHealInfo(Caster, addHp);
  26. if (addHp > 0)
  27. Caster.Battle.Output(OutputType.Heal, Caster, fighter, SkillName, (int)addHp);
  28. }
  29. if (addHp > 0)
  30. EventMgr.DispatchEvent<object[]>(new CoreEvent<object[]>(ECoreEventType.EID_FIGHTER_HEAL, new object[] { fighter, addHp }));
  31. }
  32. }
  33. }