JackHurt.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System;
  2. using GameWorld;
  3. using UnityEngine;
  4. public class JackHurt : 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.2f, 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._anim = base.GetComponent<JackAnimEvent>();
  28. this.defaultAnimName = "Hit1";
  29. this.defaultAirAnimName = "HitToFly2";
  30. this.hurtData = SingletonMono<EnemyDataPreload>.Instance.hurt[EnemyType.杰克];
  31. }
  32. public override void SetHitSpeed(Vector2 speed)
  33. {
  34. if (this.playerAtkName == "UpRising" || this.playerAtkName == "AtkUpRising" || this.playerAtkName == "AtkRollEnd" || this.playerAtkName == "NewExecute2_1")
  35. {
  36. this._anim.maxFlyHeight = 4.5f;
  37. }
  38. else
  39. {
  40. this._anim.maxFlyHeight = -1f;
  41. }
  42. base.SetHitSpeed(speed);
  43. }
  44. protected override void HitIntoWeakState(Vector2 speed, Vector2 airSpeed, string normalAtkType, string airAtkType)
  45. {
  46. normalAtkType = "IdleToWeakMod";
  47. airAtkType = "FlyToFall";
  48. if (this.action.IsInWeakSta())
  49. {
  50. return;
  51. }
  52. if (this.action.stateMachine.currentState == "HitQTE")
  53. {
  54. return;
  55. }
  56. base.HitIntoWeakState(speed, airSpeed, normalAtkType, airAtkType);
  57. }
  58. protected override void SpAttack()
  59. {
  60. if (this.eAttr.currentActionInterruptPoint < this.eAttr.actionInterruptPoint)
  61. {
  62. return;
  63. }
  64. if (this.playerAtkName == "RollEnd")
  65. {
  66. Vector2? atkFollowPos = this._atkFollowPos;
  67. if (atkFollowPos != null)
  68. {
  69. this._atkFollowPos = null;
  70. }
  71. return;
  72. }
  73. if (this.playerAtkName == "RollGround")
  74. {
  75. Vector2? atkFollowPos2 = this._atkFollowPos;
  76. if (atkFollowPos2 == null)
  77. {
  78. Transform transform = base.player.GetComponentInChildren<PlayerAtk>().transform;
  79. this._atkFollowPos = new Vector2?((transform.position - base.transform.position) * 0.9f);
  80. }
  81. this._atkFollowTime = 0f;
  82. this._atkFollowEnd = 0.2f;
  83. return;
  84. }
  85. if (this.playerAtkName == "RollReady")
  86. {
  87. Vector2? atkFollowPos3 = this._atkFollowPos;
  88. if (atkFollowPos3 == null)
  89. {
  90. this._atkFollowPos = new Vector2?((base.player.transform.position - base.transform.position) * 0.7f);
  91. }
  92. this._atkFollowTime = 0f;
  93. this._atkFollowEnd = 0.2f;
  94. return;
  95. }
  96. this._atkFollowTime = 0f;
  97. this._atkFollowEnd = 0f;
  98. }
  99. protected override void FlashAttackHurt()
  100. {
  101. this.ExecuteDieEffect();
  102. R.Effect.Generate(214, null, default(Vector3), default(Vector3), default(Vector3), true);
  103. SingletonMono<WorldTime>.Instance.TimeSlowByFrameOn60Fps(30, 0.5f);
  104. R.Camera.Controller.CameraShake(0.5f, 0.2f, CameraController.ShakeTypeEnum.Rect, false);
  105. R.Camera.Controller.OpenMotionBlur(0.0833333358f, 1f, base.transform.position);
  106. this.SetHitSpeed(Vector2.zero);
  107. base.GenerateCritHurtNum(base.flashAttackDamage);
  108. this.action.AnimChangeState(HammerAction.StateEnum.Hit1, 0.5f);
  109. base.FlashAttackHurt();
  110. }
  111. public override void QTEHurt()
  112. {
  113. base.QTEHurt();
  114. R.Player.Action.QTEHPRecover(false);
  115. base.QTEZPositionRecover();
  116. base.QTEHpMinus();
  117. }
  118. public override void EnemyDie()
  119. {
  120. }
  121. protected override void ExecuteDie()
  122. {
  123. if (this.deadFlag)
  124. {
  125. return;
  126. }
  127. if (this.eAttr.rankType == EnemyAttribute.RankType.BOSS)
  128. {
  129. R.Trophy.AwardTrophy(29);
  130. }
  131. R.Audio.PlayEffect(412, new Vector3?(base.transform.position));
  132. R.Player.Action.QTEHPRecover(this.eAttr.rankType == EnemyAttribute.RankType.BOSS);
  133. R.Audio.PlayEffect(UnityEngine.Random.Range(105, 108), new Vector3?(base.transform.position));
  134. this.deadFlag = true;
  135. this.eAttr.currentHp = 0;
  136. this.eAttr.inWeakState = false;
  137. this.eAttr.isFlyingUp = false;
  138. this.eAttr.checkHitGround = false;
  139. this.eAttr.stiffTime = 0f;
  140. this.eAttr.timeController.SetGravity(1f);
  141. base.QTEZPositionRecover();
  142. EventManager.PostEvent<EnemyAttribute>("EnemyKilled", this.eAttr);
  143. this.action.WeakEffectDisappear("Null");
  144. R.Effect.Generate(91, null, base.transform.position + new Vector3(0f, 1.2f, LayerManager.ZNum.Fx), Vector3.zero, default(Vector3), true);
  145. R.Effect.Generate(49, base.transform, default(Vector3), default(Vector3), default(Vector3), true);
  146. R.Effect.Generate(14, null, base.transform.position + new Vector3(0f, 1.2f, LayerManager.ZNum.Fx), default(Vector3), default(Vector3), true);
  147. base.AddCoinAndExp();
  148. R.Effect.Generate(213, null, default(Vector3), default(Vector3), default(Vector3), true);
  149. R.Effect.Generate(214, null, default(Vector3), default(Vector3), default(Vector3), true);
  150. SingletonMono<WorldTime>.Instance.TimeSlowByFrameOn60Fps(45, 0.2f);
  151. R.Camera.Controller.CameraShake(0.9166667f, 0.3f, CameraController.ShakeTypeEnum.Rect, false);
  152. this.action.hurtBox.gameObject.SetActive(false);
  153. this.eAttr.inWeakState = false;
  154. }
  155. private JackAnimEvent _anim;
  156. private Vector2? _atkFollowPos;
  157. private float _atkFollowTime;
  158. private float _atkFollowEnd;
  159. [SerializeField]
  160. private SkeletonAnimation closeToPlayer;
  161. }