DahalHurt.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using BehaviorDesigner.Runtime;
  3. using GameWorld;
  4. using UnityEngine;
  5. public class DahalHurt : EnemyBaseHurt
  6. {
  7. protected override void Update()
  8. {
  9. base.Update();
  10. if (this.eAttr.currentHp <= 0 && !this._dAction.DahalDie)
  11. {
  12. EventManager.PostEvent<EnemyAttribute>("EnemyKilled", this.eAttr);
  13. }
  14. Vector2? rollAtkFollowPos = this._rollAtkFollowPos;
  15. if (rollAtkFollowPos == null)
  16. {
  17. return;
  18. }
  19. Vector3 position = base.player.transform.position;
  20. Vector2? rollAtkFollowPos2 = this._rollAtkFollowPos;
  21. Vector3 position2 = position - ((rollAtkFollowPos2 == null) ? default(Vector3) : (Vector3)rollAtkFollowPos2.GetValueOrDefault());
  22. position2.y = Mathf.Clamp(position2.y, LayerManager.YNum.GetGroundHeight(base.gameObject) + 1f, float.PositiveInfinity);
  23. position2.z = LayerManager.ZNum.MMiddleE(this.eAttr.rankType);
  24. base.transform.position = position2;
  25. this._rollFollowTime += Time.unscaledDeltaTime;
  26. if (this._rollFollowTime >= 0.2f)
  27. {
  28. this._rollAtkFollowPos = null;
  29. }
  30. }
  31. protected override void PhysicAndEffect(Vector2 speed, Vector2 airSpeed, string normalAtkType, string airAtkType)
  32. {
  33. if (this.action.stateMachine.currentState == "QTEHit")
  34. {
  35. return;
  36. }
  37. base.PhysicAndEffect(speed, airSpeed, normalAtkType, airAtkType);
  38. }
  39. protected override bool Counterattack(int damage, bool groundOnly)
  40. {
  41. return this.currentPhase != 0 && base.Counterattack(damage, true);
  42. }
  43. public override void SetHitSpeed(Vector2 speed)
  44. {
  45. this.eAttr.timeController.SetGravity(1f);
  46. if (this.playerAtkName == "UpRising" || this.playerAtkName == "AtkUpRising" || this.playerAtkName == "AtkRollEnd")
  47. {
  48. this._dahal.MaxFlyHeight = 4f;
  49. }
  50. else
  51. {
  52. this._dahal.MaxFlyHeight = -1f;
  53. }
  54. base.SetHitSpeed(speed);
  55. }
  56. protected override void PlayHurtAudio()
  57. {
  58. base.PlayHurtAudio();
  59. if (base.PlaySpHurtAudio())
  60. {
  61. R.Audio.PlayEffect(401, new Vector3?(base.transform.position));
  62. }
  63. }
  64. public void HitIntoSecondLevel()
  65. {
  66. base.QTEZPositionRecover();
  67. }
  68. protected override void Init()
  69. {
  70. this._dahal = base.GetComponent<DahalAnimListener>();
  71. this._dAction = (DahalAction)this.action;
  72. this.defaultAnimName = "Hit1";
  73. this.defaultAirAnimName = "Hit1";
  74. this.hurtData = SingletonMono<EnemyDataPreload>.Instance.hurt[EnemyType.达哈尔];
  75. }
  76. protected override void SpAttack()
  77. {
  78. if (this.eAttr.currentActionInterruptPoint < this.eAttr.actionInterruptPoint)
  79. {
  80. return;
  81. }
  82. if (this.playerAtkName == "RollReady" && !this.eAttr.isOnGround)
  83. {
  84. Vector2? rollAtkFollowPos = this._rollAtkFollowPos;
  85. if (rollAtkFollowPos == null)
  86. {
  87. this._rollAtkFollowPos = new Vector2?((base.player.transform.position - base.transform.position) * 0.7f);
  88. }
  89. this._rollFollowTime = 0f;
  90. }
  91. }
  92. protected override void FlashAttackHurt()
  93. {
  94. this.ExecuteDieEffect();
  95. R.Effect.Generate(214, null, default(Vector3), default(Vector3), default(Vector3), true);
  96. SingletonMono<WorldTime>.Instance.TimeSlowByFrameOn60Fps(30, 0.5f);
  97. R.Camera.Controller.CameraShake(0.5f, 0.2f, CameraController.ShakeTypeEnum.Rect, false);
  98. R.Camera.Controller.OpenMotionBlur(0.0833333358f, 1f, base.transform.position);
  99. this.SetHitSpeed(Vector2.zero);
  100. base.GenerateCritHurtNum(base.flashAttackDamage);
  101. DahalAction.StateEnum stateEnum = (!this.eAttr.isOnGround) ? DahalAction.StateEnum.HitToFly3 : DahalAction.StateEnum.Hit1;
  102. this.action.AnimChangeState(stateEnum, 0.5f);
  103. base.FlashAttackHurt();
  104. }
  105. public override void QTEHurt()
  106. {
  107. base.QTEHurt();
  108. R.Player.Action.QTEHPRecover(false);
  109. base.QTEHpMinus();
  110. }
  111. public override void EnemyDie()
  112. {
  113. }
  114. protected override void ExecuteDie()
  115. {
  116. if (this.deadFlag)
  117. {
  118. return;
  119. }
  120. R.Trophy.AwardTrophy(24);
  121. R.Audio.PlayEffect(412, new Vector3?(base.transform.position));
  122. R.Player.Action.QTEHPRecover(this.eAttr.rankType == EnemyAttribute.RankType.BOSS);
  123. R.Effect.Generate(156, base.transform, this.center.localPosition, default(Vector3), default(Vector3), true);
  124. base.GetComponent<BehaviorTree>().enabled = false;
  125. this.action.hurtBox.gameObject.SetActive(false);
  126. this.eAttr.inWeakState = false;
  127. this.SetHitSpeed(Vector2.zero);
  128. SingletonMono<WorldTime>.Instance.TimeSlowByFrameOn60Fps(90, 0.2f);
  129. R.Camera.Controller.CameraShake(0.9166667f, 0.3f, CameraController.ShakeTypeEnum.Rect, false);
  130. R.Enemy.RemoveEnemy(this.eAttr);
  131. }
  132. private DahalAnimListener _dahal;
  133. private DahalAction _dAction;
  134. private Vector2? _rollAtkFollowPos;
  135. private float _rollFollowTime;
  136. }