SpiderBossHurt.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using GameWorld;
  3. using UnityEngine;
  4. public class SpiderBossHurt : EnemyBaseHurt
  5. {
  6. protected override void Init()
  7. {
  8. this.defaultAnimName = "Hit1";
  9. this.defaultAirAnimName = "NoStiff";
  10. this.hurtData = SingletonMono<EnemyDataPreload>.Instance.hurt[EnemyType.愚笨蜘蛛];
  11. }
  12. protected override void PlayHurtAudio()
  13. {
  14. R.Audio.PlayEffect(255, new Vector3?(base.transform.position));
  15. if (base.PlaySpHurtAudio())
  16. {
  17. R.Audio.PlayEffect(401, new Vector3?(base.transform.position));
  18. }
  19. }
  20. protected override void PhysicAndEffect(Vector2 speed, Vector2 airSpeed, string normalAtkType, string airAtkType)
  21. {
  22. if (this.action.IsInWeakSta())
  23. {
  24. return;
  25. }
  26. if (this.action.stateMachine.currentState == "Hit2")
  27. {
  28. return;
  29. }
  30. if (this.action.stateMachine.currentState == "HitQTE")
  31. {
  32. return;
  33. }
  34. base.PhysicAndEffect(speed, airSpeed, normalAtkType, airAtkType);
  35. }
  36. protected override void HitIntoWeakState(Vector2 speed, Vector2 airSpeed, string normalAtkType, string airAtkType)
  37. {
  38. normalAtkType = "IdleToWeakMod";
  39. airAtkType = "IdleToWeakMod";
  40. base.HitIntoWeakState(speed, airSpeed, normalAtkType, airAtkType);
  41. }
  42. protected override void FlashAttackHurt()
  43. {
  44. this.ExecuteDieEffect();
  45. R.Effect.Generate(214, null, default(Vector3), default(Vector3), default(Vector3), true);
  46. SingletonMono<WorldTime>.Instance.TimeSlowByFrameOn60Fps(30, 0.5f);
  47. R.Camera.Controller.CameraShake(0.5f, 0.2f, CameraController.ShakeTypeEnum.Rect, false);
  48. R.Camera.Controller.OpenMotionBlur(0.0833333358f, 1f, base.transform.position);
  49. R.Audio.PlayEffect(255, new Vector3?(base.transform.position));
  50. this.SetHitSpeed(Vector2.zero);
  51. base.GenerateCritHurtNum(base.flashAttackDamage);
  52. this.action.AnimChangeState(HammerAction.StateEnum.Hit1, 0.5f);
  53. base.FlashAttackHurt();
  54. }
  55. public override void QTEHurt()
  56. {
  57. base.QTEHurt();
  58. R.Player.Action.QTEHPRecover(false);
  59. base.QTEZPositionRecover();
  60. base.QTEHpMinus();
  61. }
  62. public override void EnemyDie()
  63. {
  64. }
  65. protected override void ExecuteDie()
  66. {
  67. if (this.deadFlag)
  68. {
  69. return;
  70. }
  71. if (this.eAttr.rankType == EnemyAttribute.RankType.BOSS)
  72. {
  73. R.Trophy.AwardTrophy(27);
  74. }
  75. R.Player.Action.QTEHPRecover(this.eAttr.rankType == EnemyAttribute.RankType.BOSS);
  76. R.Audio.PlayEffect(412, new Vector3?(base.transform.position));
  77. R.Audio.PlayEffect(UnityEngine.Random.Range(105, 108), new Vector3?(base.transform.position));
  78. this.deadFlag = true;
  79. this.eAttr.currentHp = 0;
  80. this.eAttr.inWeakState = false;
  81. this.eAttr.isFlyingUp = false;
  82. this.eAttr.checkHitGround = false;
  83. this.eAttr.stiffTime = 0f;
  84. this.eAttr.timeController.SetGravity(1f);
  85. R.Audio.PlayEffect(255, new Vector3?(base.transform.position));
  86. EventManager.PostEvent<EnemyAttribute>("EnemyKilled", this.eAttr);
  87. this.action.WeakEffectDisappear("Null");
  88. R.Effect.Generate(91, null, base.transform.position + new Vector3(0f, 1.2f, LayerManager.ZNum.Fx), Vector3.zero, default(Vector3), true);
  89. R.Effect.Generate(49, base.transform, default(Vector3), default(Vector3), default(Vector3), true);
  90. R.Effect.Generate(14, null, base.transform.position + new Vector3(0f, 1.2f, LayerManager.ZNum.Fx), default(Vector3), default(Vector3), true);
  91. base.AddCoinAndExp();
  92. R.Effect.Generate(213, null, default(Vector3), default(Vector3), default(Vector3), true);
  93. R.Effect.Generate(214, null, default(Vector3), default(Vector3), default(Vector3), true);
  94. SingletonMono<WorldTime>.Instance.TimeSlowByFrameOn60Fps(45, 0.2f);
  95. R.Camera.Controller.CameraShake(0.9166667f, 0.3f, CameraController.ShakeTypeEnum.Rect, false);
  96. this.action.hurtBox.gameObject.SetActive(false);
  97. this.eAttr.inWeakState = false;
  98. this.DieEffect();
  99. for (int i = 0; i < R.Enemy.EnemyAttributes.Count; i++)
  100. {
  101. R.Enemy.EnemyAttributes[i].GetComponent<EnemyBaseAction>().KillSelf();
  102. }
  103. }
  104. private void DieEffect()
  105. {
  106. Transform transform = UnityEngine.Object.Instantiate<Transform>(this.corePrefab, this.center.position, Quaternion.identity);
  107. transform.GetComponent<Rigidbody2D>().velocity = new Vector2((float)(-2 * this.eAttr.faceDir), 10f);
  108. transform.GetComponent<EnemyArm>().SetAngularSpeed((float)(100 * this.eAttr.faceDir));
  109. Transform transform2 = UnityEngine.Object.Instantiate<Transform>(this.headPrefab, this.headPos.position, Quaternion.identity);
  110. transform2.GetComponent<Rigidbody2D>().velocity = new Vector2((float)(2 * this.eAttr.faceDir), 10f);
  111. transform2.GetComponent<EnemyArm>().SetAngularSpeed((float)(100 * -(float)this.eAttr.faceDir));
  112. }
  113. [SerializeField]
  114. private Transform headPos;
  115. [SerializeField]
  116. private Transform headPrefab;
  117. [SerializeField]
  118. private Transform corePrefab;
  119. }