ChangeSkillFunEvent.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using UnityEngine;
  2. using System.Collections;
  3. public class ChangeSkillFunEvent : DurationFunctionEvent
  4. {
  5. public static ChangeSkillFunEvent Creator(BuffFunctionData data)
  6. {
  7. return new ChangeSkillFunEvent(data);
  8. }
  9. public ChangeSkillFunEvent(BuffFunctionData data):base(data)
  10. {
  11. mType = Buff_Function_Type.ChangeSkill;
  12. }
  13. bool skillChanged = false;
  14. int[] fromSkills = null;
  15. int[] toSkills = null;
  16. bool bProcessSlowing = false;
  17. public override void Enter(Fighter fighter)
  18. {
  19. base.Enter(fighter);
  20. fromSkills = StringUtil.split2Int(HitInfo.AttackInfo.fromSkills, ';');
  21. toSkills = StringUtil.split2Int(HitInfo.AttackInfo.toSkills, ';');
  22. if (fromSkills == null || toSkills == null) return;
  23. if (HitInfo!=null && HitInfo.AttackInfo!=null && fromSkills.Length > 0 && toSkills.Length > 0 && fromSkills.Length == toSkills.Length)
  24. {
  25. for(int idx =0; idx < fromSkills.Length;idx++)
  26. {
  27. bool bOk = fighter.ChangeSkill(fromSkills[idx], toSkills[idx]);
  28. skillChanged |= bOk;
  29. }
  30. if (skillChanged && Data.buffType == BattleBuffType.Negative)
  31. {
  32. bProcessSlowing = true;
  33. fighter.ProcessSlow(true);
  34. }
  35. }
  36. }
  37. public override void Exit(Fighter fighter)
  38. {
  39. if(skillChanged)
  40. {
  41. for (int idx = 0; idx < fromSkills.Length; idx++)
  42. {
  43. skillChanged = fighter.ChangeSkill(toSkills[idx], fromSkills[idx]);
  44. }
  45. }
  46. if(bProcessSlowing)
  47. {
  48. fighter.ProcessSlow(false);
  49. }
  50. base.Exit(fighter);
  51. }
  52. }