S3401.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using System.Collections.Generic;
  2. using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
  3. using Common.Combat.FxAILogic;
  4. using Core.Triiger;
  5. using Fort23.Core;
  6. using GameLogic.Combat.CombatTool;
  7. using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
  8. using UnityEngine;
  9. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  10. namespace GameLogic.Combat.Skill.MagicSkill
  11. {
  12. public class S3401FxMove : CObject
  13. {
  14. public Vector3 endPos;
  15. public FxAILogicBasic fxAILogicBasic;
  16. public float moveSpeed = 8;
  17. private System.Action finishCallBack;
  18. private bool isUpdate;
  19. private float moveTime;
  20. public void InitActive(Vector3 endPos, System.Action finishCallBack)
  21. {
  22. this.endPos = endPos;
  23. moveTime = 0;
  24. this.finishCallBack = finishCallBack;
  25. isUpdate = true;
  26. }
  27. public override void ActiveObj()
  28. {
  29. }
  30. public override void DormancyObj()
  31. {
  32. fxAILogicBasic = null;
  33. isUpdate = false;
  34. }
  35. public bool Update(float t)
  36. {
  37. if (!isUpdate)
  38. {
  39. return false;
  40. }
  41. Vector3 pos = fxAILogicBasic.gameObject.transform.position;
  42. Vector3 dir = endPos - pos;
  43. float distance = dir.magnitude;
  44. float addT = 1.0f / (distance / moveSpeed);
  45. moveTime += t * addT;
  46. Vector3 d = Vector3.Lerp(pos, endPos, moveTime);
  47. fxAILogicBasic.gameObject.transform.position = d;
  48. Quaternion quaternion = Quaternion.LookRotation(dir);
  49. fxAILogicBasic.gameObject.transform.rotation = quaternion;
  50. if (moveTime >= 1)
  51. {
  52. fxAILogicBasic.Dispose();
  53. finishCallBack?.Invoke();
  54. isUpdate = false;
  55. CObjectPool.Instance.Recycle(this);
  56. return false;
  57. }
  58. return true;
  59. }
  60. }
  61. /// <summary>
  62. /// 宝塔在英雄的头顶前往位置旋转,形成一个扇形区域,敌人的功法如果进入这个扇形区域有很大的概率被法宝吸收
  63. ///(飞到玩家头顶持续施法)
  64. /// 100%吸收,切吸收后临时增加玩家对于吸收功法的灵根
  65. /// </summary>
  66. public class S3401 : MagicSkillBasic, ITriggerEntity
  67. {
  68. private List<S3401FxMove> _currTriggerFx = new List<S3401FxMove>();
  69. private float _currTime;
  70. private bool _isUpdae;
  71. private IUnRegister _unRegister;
  72. private TimeLineEventLogicGroupBasic _timeLineEventLogicGroupBasic;
  73. protected override void ProMagicUseSkill()
  74. {
  75. _currTime = 0;
  76. _isUpdae = false;
  77. TimeLineEventLogicGroupBasic timeLineEventLogicGroupBasic = ActivationTimeLineData("sk1_xiaoshi");
  78. timeLineEventLogicGroupBasic.TimeLineUpdateEnd = delegate()
  79. {
  80. Vector3 targetPos = CombatMagicWeaponEntity.RootMagicWeaponControl.combatHeroEntity
  81. .GetSpecialDotInfo("toupos2").GetWorlPos();
  82. Transform root = CombatMagicWeaponEntity.RootMagicWeaponControl.combatHeroEntity.GameObject.transform;
  83. // Vector3 pos = root.TransformPoint(new Vector3(0, 4, 4));
  84. Quaternion quaternion = Quaternion.Euler(110, 0, 0);
  85. CombatHeroEntity.GameObject.transform.rotation = root.rotation * quaternion;
  86. // Vector3 d = root.rotation * _dir;
  87. CombatHeroEntity.GameObject.transform.position = targetPos;
  88. TimeLineEventLogicGroupBasic sk1_show = ActivationTimeLineData("sk1_show");
  89. sk1_show.TimeLineUpdateEnd = ShowFinish;
  90. };
  91. }
  92. protected void ShowFinish()
  93. {
  94. _timeLineEventLogicGroupBasic = ActivationTimeLineData("sk1");
  95. SpecialDotInfo specialDotInfo =
  96. CombatMagicWeaponEntity.GetSpecialDotInfo("sk1");
  97. _unRegister = specialDotInfo.targetTran.gameObject.OnTriggerEnterEvent(this, OnTriggerExitEvent);
  98. _isUpdae = true;
  99. }
  100. protected override void MagicSkillUpdate(float time)
  101. {
  102. for (int i = 0; i < _currTriggerFx.Count; i++)
  103. {
  104. S3401FxMove fxMove = _currTriggerFx[i];
  105. bool isUpdate = fxMove.Update(time);
  106. if (!isUpdate)
  107. {
  108. ActivationTimeLineData("sk1_hit");
  109. _currTriggerFx.RemoveAt(i);
  110. i--;
  111. }
  112. }
  113. if (!_isUpdae)
  114. {
  115. return;
  116. }
  117. _currTime += time;
  118. if (_currTime > effectValue[1])
  119. {
  120. _isUpdae = false;
  121. if (_timeLineEventLogicGroupBasic != null)
  122. {
  123. _timeLineEventLogicGroupBasic.CloseLoopFx();
  124. }
  125. ActivationTimeLineData("sk1_xiaoshi");
  126. SkillPlayFinish();
  127. }
  128. }
  129. protected override void ProSkillPlayFinish()
  130. {
  131. _isUpdae = false;
  132. _currTime = 0;
  133. _unRegister.UnRegister();
  134. CombatHeroEntity.CloseLoopFx();
  135. }
  136. protected override void ProBreakMagicSkill()
  137. {
  138. _isUpdae = false;
  139. SkillPlayFinish();
  140. }
  141. private void OnTriggerExitEvent(Collider collider, ITriggerEntity triggerEntity)
  142. {
  143. if (triggerEntity == null)
  144. {
  145. return;
  146. }
  147. FxAILogicBasic fxAILogicBasic = triggerEntity as FxAILogicBasic;
  148. if (fxAILogicBasic != null && fxAILogicBasic.CombatHeroEntity.IsEnemy != CombatHeroEntity.IsEnemy)
  149. {
  150. if (!fxAILogicBasic.isInit)
  151. {
  152. return;
  153. }
  154. int odds = CombatCalculateTool.Instance.GetOdd(0, 100);
  155. if (odds < effectValue[0])
  156. {
  157. fxAILogicBasic.isNotMove = true;
  158. S3401FxMove fxMove = CObjectPool.Instance.Fetch<S3401FxMove>();
  159. fxMove.fxAILogicBasic = fxAILogicBasic;
  160. fxMove.InitActive(CombatHeroEntity.dotPos, null);
  161. _currTriggerFx.Add(fxMove);
  162. }
  163. }
  164. }
  165. public string tag { get; }
  166. }
  167. }