BuffBasic.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
  3. using Fort23.Core;
  4. using Fort23.UTool;
  5. using UnityEngine;
  6. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  7. namespace GameLogic.Combat.Buff
  8. {
  9. public class BuffBasic : CObject
  10. {
  11. protected CombatHeroEntity combatHeroEntity;
  12. public BuffInfo buffInf;
  13. protected CombatHeroEntity source;
  14. protected TriggerData _triggerData;
  15. public float _currTime;
  16. protected float _jianGe;
  17. public System.Action buffFinish;
  18. public int buffCount
  19. {
  20. get { return _count; }
  21. }
  22. protected int _count;
  23. private float _time;
  24. public void Init(CombatHeroEntity combatHeroEntity, CombatHeroEntity source, BuffInfo buffInfo)
  25. {
  26. _triggerData.Source = this;
  27. this.combatHeroEntity = combatHeroEntity;
  28. this.buffInf = buffInfo;
  29. this.source = source;
  30. ProInit();
  31. AddBuffCount(source, buffInfo);
  32. }
  33. public void AddBuffCount(CombatHeroEntity source, BuffInfo buffInfo)
  34. {
  35. _currTime = 0;
  36. int c = buffCount + buffInfo.count;
  37. if (c > buffInfo.BuffConfig.overlayCount)
  38. {
  39. c = buffInfo.BuffConfig.overlayCount - buffCount;
  40. }
  41. else
  42. {
  43. c = buffInfo.count;
  44. }
  45. if (c <= 0)
  46. {
  47. return;
  48. }
  49. _count += c;
  50. UpdateEffect();
  51. }
  52. protected virtual void ProInit()
  53. {
  54. }
  55. public override void ActiveObj()
  56. {
  57. }
  58. public void UpdateEffect()
  59. {
  60. ProUpdateEffect();
  61. }
  62. protected virtual void ProUpdateEffect()
  63. {
  64. }
  65. public void ReduceCount(int count)
  66. {
  67. _count -= count;
  68. if (_count <= 0)
  69. {
  70. combatHeroEntity.BuffControl.RemoveBuff(this);
  71. return;
  72. }
  73. UpdateEffect();
  74. }
  75. public TimeLineEventLogicGroupBasic ActivationTimeLineData(string groupName,
  76. BetterList<ILifetCycleHitPoint> currTarget = null,
  77. Vector3[] customizePos = null, System.Action finishCallBack = null, float startTime = default,
  78. object extraData = null, int indexCount = 0)
  79. {
  80. TimeLineEventLogicGroupBasic timeLineEventLogicGroup =
  81. source.combatHeroTimeLineControl
  82. .GetTimeLineEventLogicGroup<TimeLineEventLogicGroupBasic>(groupName, null);
  83. try
  84. {
  85. if (timeLineEventLogicGroup != null)
  86. {
  87. timeLineEventLogicGroup.extraData = extraData;
  88. timeLineEventLogicGroup.SetCombatInfo(combatHeroEntity, null, currTarget, _triggerData,
  89. customizePos, indexCount);
  90. timeLineEventLogicGroup.TimeLineUpdateEnd = finishCallBack;
  91. timeLineEventLogicGroup.timeLineTime = startTime;
  92. combatHeroEntity.combatHeroTimeLineControl.AddEventLogicGroup(timeLineEventLogicGroup);
  93. // currUseAllTimeLineLogic.Add(timeLineEventLogicGroup);
  94. }
  95. }
  96. catch (Exception e)
  97. {
  98. LogTool.Error(e);
  99. }
  100. return timeLineEventLogicGroup;
  101. }
  102. public override void DormancyObj()
  103. {
  104. buffFinish?.Invoke();
  105. buffFinish = null;
  106. _currTime = 0;
  107. ProDormancyObj();
  108. CObjectPool.Instance.Recycle(buffInf);
  109. buffInf = null;
  110. combatHeroEntity = null;
  111. }
  112. protected virtual void ProDormancyObj()
  113. {
  114. }
  115. public void Update(float t)
  116. {
  117. _currTime += t;
  118. if (buffInf.buffTime > 0 && _currTime > buffInf.buffTime)
  119. {
  120. combatHeroEntity.BuffControl.RemoveBuff(this);
  121. return;
  122. }
  123. if (_jianGe > 0)
  124. {
  125. _time += t;
  126. if (_time >= _jianGe)
  127. {
  128. _time -= _jianGe;
  129. UpdateJumping();
  130. }
  131. }
  132. ProUpdate(t);
  133. }
  134. protected virtual void UpdateJumping()
  135. {
  136. }
  137. protected virtual void ProUpdate(float t)
  138. {
  139. }
  140. }
  141. }