BuffBasic.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. public int buffCount
  17. {
  18. get { return _count; }
  19. }
  20. protected int _count;
  21. public void Init(CombatHeroEntity combatHeroEntity, CombatHeroEntity source, BuffInfo buffInfo)
  22. {
  23. this.combatHeroEntity = combatHeroEntity;
  24. this.buffInf = buffInfo;
  25. this.source = source;
  26. ProInit();
  27. AddBuffCount(source, buffInfo);
  28. }
  29. public void AddBuffCount(CombatHeroEntity source, BuffInfo buffInfo)
  30. {
  31. _currTime = 0;
  32. int c = buffCount + buffInfo.count;
  33. if (c > buffInfo.BuffConfig.overlayCount)
  34. {
  35. c = buffInfo.BuffConfig.overlayCount - buffCount;
  36. }
  37. else
  38. {
  39. c = buffInfo.count;
  40. }
  41. if (c <= 0)
  42. {
  43. return;
  44. }
  45. _count += c;
  46. UpdateEffect();
  47. }
  48. protected virtual void ProInit()
  49. {
  50. }
  51. public override void ActiveObj()
  52. {
  53. }
  54. public void UpdateEffect()
  55. {
  56. ProUpdateEffect();
  57. }
  58. protected virtual void ProUpdateEffect()
  59. {
  60. }
  61. public void ReduceCount(int count)
  62. {
  63. _count -= count;
  64. if (_count <= 0)
  65. {
  66. combatHeroEntity.BuffControl.RemoveBuff(this);
  67. return;
  68. }
  69. UpdateEffect();
  70. }
  71. public TimeLineEventLogicGroupBasic ActivationTimeLineData(string groupName,
  72. BetterList<ILifetCycleHitPoint> currTarget = null,
  73. Vector3[] customizePos = null, System.Action finishCallBack = null, float startTime = default,
  74. object extraData = null, int indexCount = 0)
  75. {
  76. TimeLineEventLogicGroupBasic timeLineEventLogicGroup =
  77. source.combatHeroTimeLineControl
  78. .GetTimeLineEventLogicGroup<TimeLineEventLogicGroupBasic>(groupName, null);
  79. try
  80. {
  81. if (timeLineEventLogicGroup != null)
  82. {
  83. timeLineEventLogicGroup.extraData = extraData;
  84. timeLineEventLogicGroup.SetCombatInfo(combatHeroEntity, null, currTarget, _triggerData,
  85. customizePos, indexCount);
  86. timeLineEventLogicGroup.TimeLineUpdateEnd = finishCallBack;
  87. timeLineEventLogicGroup.timeLineTime = startTime;
  88. combatHeroEntity.combatHeroTimeLineControl.AddEventLogicGroup(timeLineEventLogicGroup);
  89. // currUseAllTimeLineLogic.Add(timeLineEventLogicGroup);
  90. }
  91. }
  92. catch (Exception e)
  93. {
  94. LogTool.Error(e);
  95. }
  96. return timeLineEventLogicGroup;
  97. }
  98. public override void DormancyObj()
  99. {
  100. _currTime = 0;
  101. ProDormancyObj();
  102. CObjectPool.Instance.Recycle(buffInf);
  103. buffInf = null;
  104. combatHeroEntity = null;
  105. }
  106. protected virtual void ProDormancyObj()
  107. {
  108. }
  109. public void Update(float t)
  110. {
  111. _currTime += t;
  112. if (buffInf.buffTime > 0 && _currTime > buffInf.buffTime)
  113. {
  114. combatHeroEntity.BuffControl.RemoveBuff(this);
  115. return;
  116. }
  117. ProUpdate(t);
  118. }
  119. protected virtual void ProUpdate(float t)
  120. {
  121. }
  122. }
  123. }