JumperHurt.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. public class JumperHurt : EnemyBaseHurt
  5. {
  6. protected override void Update()
  7. {
  8. base.Update();
  9. Vector2? atkFollowPos = this._atkFollowPos;
  10. if (atkFollowPos != null)
  11. {
  12. Vector3 position = base.player.transform.position;
  13. Vector2? atkFollowPos2 = this._atkFollowPos;
  14. Vector3 position2 = position - ((atkFollowPos2 == null) ? default(Vector3) : (Vector3)atkFollowPos2.GetValueOrDefault());
  15. position2.y = Mathf.Clamp(position2.y, LayerManager.YNum.GetGroundHeight(base.gameObject) + 0.1f, float.PositiveInfinity);
  16. position2.z = LayerManager.ZNum.MMiddleE(this.eAttr.rankType);
  17. base.transform.position = position2;
  18. this._atkFollowTime += Time.unscaledDeltaTime;
  19. if (this._atkFollowTime >= this._atkFollowEnd)
  20. {
  21. this._atkFollowPos = null;
  22. }
  23. }
  24. }
  25. protected override void Init()
  26. {
  27. this._jumper = base.GetComponent<JumperAnimListener>();
  28. this.defaultAnimName = "Hit1";
  29. this.defaultAirAnimName = "HitToFly2";
  30. this.airDieAnimName = "Fall";
  31. this.airDieHitGroundAnimName = "AirDie";
  32. this.flyToFallAnimName = "AirDiePre";
  33. this.hurtData = SingletonMono<EnemyDataPreload>.Instance.hurt[EnemyType.跳跃者];
  34. }
  35. public override void SetHitSpeed(Vector2 speed)
  36. {
  37. if (this.playerAtkName == "UpRising" || this.playerAtkName == "AtkUpRising" || this.playerAtkName == "AtkRollEnd" || this.playerAtkName == "NewExecute2_1")
  38. {
  39. this._jumper.MaxFlyHeight = 4.5f;
  40. }
  41. else
  42. {
  43. this._jumper.MaxFlyHeight = -1f;
  44. }
  45. base.SetHitSpeed(speed);
  46. }
  47. protected override void ExecuteFollow()
  48. {
  49. this.action.AnimChangeState(JumperAction.StateEnum.Execute, 1f);
  50. base.ExecuteFollow();
  51. }
  52. protected override void PlayHurtAudio()
  53. {
  54. base.PlayHurtAudio();
  55. if (base.PlaySpHurtAudio())
  56. {
  57. R.Audio.PlayEffect(397, new Vector3?(base.transform.position));
  58. }
  59. }
  60. protected override void SpAttack()
  61. {
  62. if (this.eAttr.currentActionInterruptPoint < this.eAttr.actionInterruptPoint)
  63. {
  64. return;
  65. }
  66. base.SpAttack();
  67. if (this.playerAtkName == "RollEnd")
  68. {
  69. Vector2? atkFollowPos = this._atkFollowPos;
  70. if (atkFollowPos != null)
  71. {
  72. this._atkFollowPos = null;
  73. }
  74. return;
  75. }
  76. if (this.playerAtkName == "RollGround")
  77. {
  78. Vector2? atkFollowPos2 = this._atkFollowPos;
  79. if (atkFollowPos2 == null)
  80. {
  81. Transform transform = base.player.GetComponentInChildren<PlayerAtk>().transform;
  82. this._atkFollowPos = new Vector2?((transform.position - base.transform.position) * 0.9f);
  83. }
  84. this._atkFollowTime = 0f;
  85. this._atkFollowEnd = 0.2f;
  86. return;
  87. }
  88. if (this.playerAtkName == "RollReady" || this.playerAtkName == "BladeStormReady")
  89. {
  90. Vector2? atkFollowPos3 = this._atkFollowPos;
  91. if (atkFollowPos3 == null)
  92. {
  93. Vector2 a = base.player.transform.position - base.transform.position;
  94. this._atkFollowPos = new Vector2?(a * 0.7f);
  95. }
  96. this._atkFollowTime = 0f;
  97. this._atkFollowEnd = 0.2f;
  98. return;
  99. }
  100. if (this.playerAtkName == "Atk4")
  101. {
  102. base.StartCoroutine(this.CloseToPlayer());
  103. }
  104. }
  105. private IEnumerator CloseToPlayer()
  106. {
  107. this.closeToPlayer.state.SetAnimation(0, "Show", false);
  108. this.closeToPlayer.skeleton.SetToSetupPose();
  109. Vector3 endPos = base.player.transform.position + Vector3.right * (float)base.pAttr.faceDir * UnityEngine.Random.Range(0.8f, 1.5f);
  110. endPos.z = LayerManager.ZNum.MMiddleE(this.eAttr.rankType);
  111. Vector3 startPos = base.transform.position;
  112. for (int i = 0; i < 5; i++)
  113. {
  114. yield return new WaitForFixedUpdate();
  115. }
  116. for (int j = 0; j < 6; j++)
  117. {
  118. base.transform.position = Vector3.Lerp(startPos, endPos, (float)j / 5f);
  119. yield return new WaitForFixedUpdate();
  120. }
  121. yield break;
  122. }
  123. protected override void ExecuteDie()
  124. {
  125. base.ExecuteDie();
  126. R.Audio.PlayEffect(484, new Vector3?(base.transform.position));
  127. this.eAttr.timeController.SetGravity(1f);
  128. this.SetHitSpeed(Vector2.zero);
  129. this.SpDieEffect(this.eAttr.isOnGround);
  130. }
  131. public override void EnemyDie()
  132. {
  133. if (this.deadFlag)
  134. {
  135. return;
  136. }
  137. base.EnemyDie();
  138. R.Audio.PlayEffect(484, new Vector3?(base.transform.position));
  139. if (this.eAttr.isOnGround)
  140. {
  141. base.NormalKill();
  142. this.SetHitSpeed(Vector2.zero);
  143. if (this.playerAtkName == "Charge1EndLevel1" || this.playerAtkName == "Charge1EndLevel2" || this.playerAtkName == "Charge1EndLevel3")
  144. {
  145. this.action.AnimChangeState(JumperAction.StateEnum.Die2, 1f);
  146. }
  147. else
  148. {
  149. this.action.AnimChangeState(JumperAction.StateEnum.Die, 1f);
  150. }
  151. base.Invoke("DieTimeControl", 0.12f);
  152. }
  153. else
  154. {
  155. Vector2 speed = this.eAttr.timeController.GetCurrentSpeed() + new Vector2(Mathf.Sign(base.transform.position.x - base.player.transform.position.x) * 1f, 4f);
  156. base.NormalKill();
  157. base.DieTimeControl();
  158. this.eAttr.timeController.SetSpeed(speed);
  159. base.StartCoroutine(this.DeathIEnumerator());
  160. }
  161. }
  162. private void SpDieEffect(bool isGround)
  163. {
  164. Transform transform = R.Effect.Generate(227, null, this.center.position, Vector3.zero, default(Vector3), true);
  165. transform.localScale = base.transform.localScale;
  166. Transform transform2 = R.Effect.Generate(228, null, this.center.position, Vector3.zero, default(Vector3), true);
  167. transform2.localScale = base.transform.localScale;
  168. this.action.AnimChangeState(JumperAction.StateEnum.Die3, 1f);
  169. string playerAtkName = this.playerAtkName;
  170. if (playerAtkName != null)
  171. {
  172. if (!(playerAtkName == "NewExecute1_2") && !(playerAtkName == "NewExecute2_2") && !(playerAtkName == "NewExecuteAir2_2"))
  173. {
  174. if (playerAtkName == "NewExecuteAir1_2")
  175. {
  176. Vector2 speed = new Vector2(Mathf.Sign(base.transform.localScale.x) * 2f, 15f);
  177. Vector2 speed2 = new Vector2(Mathf.Sign(base.transform.localScale.x) * -2f, 15f);
  178. transform.GetComponent<JumperPart>().Init(isGround, speed);
  179. transform2.GetComponent<JumperPart>().Init(isGround, speed2);
  180. }
  181. }
  182. else
  183. {
  184. Vector2 speed = new Vector2(Mathf.Sign(base.transform.localScale.x) * 2f, 15f);
  185. Vector2 speed2 = new Vector2(Mathf.Sign(base.transform.localScale.x) * -2f, -5f);
  186. transform.GetComponent<JumperPart>().Init(isGround, speed);
  187. transform2.GetComponent<JumperPart>().Init(isGround, speed2);
  188. }
  189. }
  190. }
  191. protected override IEnumerator DeathIEnumerator()
  192. {
  193. bool deadFly = true;
  194. bool deadFall = false;
  195. while (this.eAttr.isDead)
  196. {
  197. if (deadFly && this.eAttr.timeController.GetCurrentSpeed().y <= 0f)
  198. {
  199. deadFly = false;
  200. deadFall = true;
  201. this.action.AnimChangeState(this.flyToFallAnimName, 1f);
  202. }
  203. if (deadFall && this.eAttr.isOnGround)
  204. {
  205. deadFall = false;
  206. this.action.AnimChangeState(this.airDieHitGroundAnimName, 1f);
  207. base.Invoke("RealDie", 0.5f);
  208. }
  209. yield return null;
  210. }
  211. yield break;
  212. }
  213. private void RealDie()
  214. {
  215. base.GetComponent<JumperAnimListener>().GetUp();
  216. }
  217. private JumperAnimListener _jumper;
  218. private Vector2? _atkFollowPos;
  219. private float _atkFollowTime;
  220. private float _atkFollowEnd;
  221. [SerializeField]
  222. private SkeletonAnimation closeToPlayer;
  223. }