DetectFunctionPoint.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using UnityEngine;
  2. using System.Collections;
  3. public class DetectFunctionPoint : TickFunctionEvent
  4. {
  5. public static DetectFunctionPoint Creator(BuffFunctionData data)
  6. {
  7. return new DetectFunctionPoint(data);
  8. }
  9. public DetectFunctionPoint(BuffFunctionData data) : base(data)
  10. {
  11. }
  12. public override void Enter(Fighter fighter)
  13. {
  14. base.Enter(fighter);
  15. int pointBuffId = (int)Data.BaseValue;
  16. int point = 0;
  17. if (Data.TargetType == 1)
  18. {
  19. point = Caster.GetFunctionPoint(pointBuffId);
  20. }else if(Data.TargetType == 2)
  21. {
  22. point = fighter.GetFunctionPoint(pointBuffId);
  23. }
  24. int newBuffId = 0;
  25. int costPoint = 0;
  26. BattleBuff buff = Caster.BuffMgr.GetBuff(BuffId);
  27. if (buff != null && buff.Data.extendBuffs!=null)
  28. {
  29. for (int idx = buff.Data.extendBuffs.Count - 1; idx>=0 ; idx--)
  30. {
  31. ValType val = buff.Data.extendBuffs[idx];
  32. if(val.val <= point)
  33. {
  34. costPoint = val.val;
  35. newBuffId = val.id;
  36. break;
  37. }
  38. }
  39. }
  40. //DebugHelper.LogError("BuffId:"+ BuffId+" extendStr:"+ buff.Data.extendFunStr+" point: "+point+ " pointBuffId: "+ pointBuffId + " targetType:" +Data.TargetType+" newBuffId:"+newBuffId+" costPoint:"+costPoint);
  41. if(newBuffId > 0)
  42. {
  43. if(Data.TargetType == 1)
  44. {
  45. Caster.DetuctFunctionPoint(pointBuffId, costPoint);
  46. }
  47. else if(Data.TargetType == 2)
  48. {
  49. fighter.DetuctFunctionPoint(pointBuffId, costPoint);
  50. }
  51. int buffLevel = buff.Data.BuffLevel;
  52. buff.Stop();
  53. BattleBuff castBuff = Caster.CastBuff(null, newBuffId, buffLevel);
  54. if(castBuff!=null)
  55. {
  56. castBuff.IsEnhance = true;
  57. }
  58. }
  59. }
  60. }