BombKillerHurt.cs 6.5 KB

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