S3401.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. if (moveTime >= 1)
  49. {
  50. fxAILogicBasic.Dispose();
  51. finishCallBack?.Invoke();
  52. isUpdate = false;
  53. CObjectPool.Instance.Recycle(this);
  54. return false;
  55. }
  56. return true;
  57. }
  58. }
  59. /// <summary>
  60. /// 宝塔在英雄的头顶前往位置旋转,形成一个扇形区域,敌人的功法如果进入这个扇形区域有很大的概率被法宝吸收
  61. ///(飞到玩家头顶持续施法)
  62. /// 100%吸收,切吸收后临时增加玩家对于吸收功法的灵根
  63. /// </summary>
  64. public class S3401 : MagicSkillBasic, ITriggerEntity
  65. {
  66. private List<S3401FxMove> _currTriggerFx = new List<S3401FxMove>();
  67. private float _currTime;
  68. private bool _isUpdae;
  69. private IUnRegister _unRegister;
  70. protected override void ProMagicUseSkill()
  71. {
  72. TimeLineEventLogicGroupBasic timeLineEventLogicGroupBasic = ActivationTimeLineData("sk1_xiaoshi");
  73. timeLineEventLogicGroupBasic.TimeLineUpdateEnd = delegate()
  74. {
  75. Transform root = CombatMagicWeaponEntity.RootMagicWeaponControl.combatHeroEntity.GameObject.transform;
  76. Vector3 pos = root.TransformPoint(new Vector3(0, 4, 4));
  77. Quaternion quaternion = Quaternion.Euler(120, 0, 0);
  78. CombatHeroEntity.GameObject.transform.rotation = root.rotation * quaternion;
  79. // Vector3 d = root.rotation * _dir;
  80. CombatHeroEntity.GameObject.transform.position = pos;
  81. TimeLineEventLogicGroupBasic sk1_show = ActivationTimeLineData("sk1_show");
  82. sk1_show.TimeLineUpdateEnd = ShowFinish;
  83. };
  84. }
  85. protected void ShowFinish()
  86. {
  87. ActivationTimeLineData("sk1");
  88. SpecialDotInfo specialDotInfo =
  89. CombatMagicWeaponEntity.GetSpecialDotInfo("sk1");
  90. _unRegister = specialDotInfo.targetTran.gameObject.OnTriggerEnterEvent(this, OnTriggerExitEvent);
  91. _isUpdae = true;
  92. }
  93. protected override void MagicSkillUpdate(float time)
  94. {
  95. for (int i = 0; i < _currTriggerFx.Count; i++)
  96. {
  97. S3401FxMove fxMove = _currTriggerFx[i];
  98. bool isUpdate = fxMove.Update(time);
  99. if (!isUpdate)
  100. {
  101. _currTriggerFx.RemoveAt(i);
  102. i--;
  103. }
  104. }
  105. if (!_isUpdae)
  106. {
  107. return;
  108. }
  109. _currTime += time;
  110. if (_currTime > effectValue[1])
  111. {
  112. _isUpdae = false;
  113. SkillPlayFinish();
  114. }
  115. }
  116. protected override void ProSkillPlayFinish()
  117. {
  118. _isUpdae = false;
  119. _unRegister.UnRegister();
  120. CombatHeroEntity.CloseLoopFx();
  121. }
  122. protected override void ProBreakMagicSkill()
  123. {
  124. _isUpdae = false;
  125. SkillPlayFinish();
  126. }
  127. private void OnTriggerExitEvent(Collider collider, ITriggerEntity triggerEntity)
  128. {
  129. if (triggerEntity == null)
  130. {
  131. return;
  132. }
  133. FxAILogicBasic fxAILogicBasic = triggerEntity as FxAILogicBasic;
  134. if (fxAILogicBasic != null && fxAILogicBasic.CombatHeroEntity.IsEnemy != CombatHeroEntity.IsEnemy)
  135. {
  136. if (!fxAILogicBasic.isInit)
  137. {
  138. return;
  139. }
  140. int odds = CombatCalculateTool.Instance.GetOdd(0, 100);
  141. if (odds < effectValue[0])
  142. {
  143. fxAILogicBasic.isNotMove = true;
  144. S3401FxMove fxMove = CObjectPool.Instance.Fetch<S3401FxMove>();
  145. fxMove.fxAILogicBasic = fxAILogicBasic;
  146. fxMove.InitActive(CombatHeroEntity.dotPos, null);
  147. _currTriggerFx.Add(fxMove);
  148. }
  149. }
  150. }
  151. public string tag { get; }
  152. }
  153. }