HealHPFromCaster.cs 1.4 KB

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