FooterHurt.cs 6.9 KB

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