PlayerFlashAttackAbility.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using ExtensionMethods;
  3. using UnityEngine;
  4. public class PlayerFlashAttackAbility : CharacterState
  5. {
  6. public override void Update()
  7. {
  8. if (this._target != null)
  9. {
  10. this._clearRate += Time.unscaledDeltaTime;
  11. if (this._clearRate >= 0.75f)
  12. {
  13. this._target = null;
  14. }
  15. }
  16. if (this._flashAtkStart)
  17. {
  18. this._recoverRate += Time.unscaledDeltaTime;
  19. if (this._recoverRate >= 1.5f)
  20. {
  21. this.PlayerRecover();
  22. this._flashAtkStart = false;
  23. }
  24. }
  25. if (this._recoverInvincible)
  26. {
  27. this.pab.hurt.Invincible = true;
  28. this._invincibleTime += Time.unscaledDeltaTime;
  29. if (this._invincibleTime > 0.6f)
  30. {
  31. this._invincibleTime = 0f;
  32. this.pab.hurt.Invincible = false;
  33. this._recoverInvincible = false;
  34. }
  35. }
  36. }
  37. public void FlashAttack(GameObject enemy)
  38. {
  39. if (this._target != null)
  40. {
  41. return;
  42. }
  43. if (enemy == null)
  44. {
  45. return;
  46. }
  47. this._clearRate = 0f;
  48. this._target = enemy.gameObject;
  49. this.StartQTE();
  50. R.Audio.PlayEffect(172, new Vector3?(this.pac.transform.position));
  51. this.AttackEnemy(this._target);
  52. }
  53. private void StartQTE()
  54. {
  55. SingletonMono<WorldTime>.Instance.TimeSlowByFrameOn60Fps(45, 0.15f);
  56. }
  57. public bool PressFlashAttack()
  58. {
  59. if (this._target == null)
  60. {
  61. return false;
  62. }
  63. if (this.stateMachine.currentState.IsInArray(PlayerAction.FlashAttackSta))
  64. {
  65. this.AttackEnemy(this._target);
  66. return true;
  67. }
  68. return false;
  69. }
  70. public bool CheckEnemy(GameObject enemy)
  71. {
  72. return enemy == this._target;
  73. }
  74. private void AttackEnemy(GameObject enemy)
  75. {
  76. this._recoverRate = 0f;
  77. this._flashAtkStart = true;
  78. this.listener.StopIEnumerator("FlashPositionSet");
  79. this.pac.ChangeState(PlayerAction.StateEnum.Disappear, 1f);
  80. SingletonMono<WorldTime>.Instance.TimeFrozenByFixedFrame(14, enemy);
  81. R.Audio.PlayEffect(200, new Vector3?(this.pac.transform.position));
  82. Transform transform = R.Effect.Generate(165, null, enemy.transform.position, default(Vector3), default(Vector3), true);
  83. transform.GetComponent<ShadeAttack>().Init(enemy);
  84. transform.localScale = new Vector3((float)(-(float)this.pAttr.faceDir), 1f, 1f);
  85. Vector3 pos = new Vector3(enemy.transform.position.x, enemy.transform.position.y + 2f, Camera.main.transform.parent.position.z + 3f);
  86. SingletonMono<CameraController>.Instance.CameraZoom(pos, 0.2f, 3f);
  87. }
  88. private void PlayerRecover()
  89. {
  90. this.pac.ChangeState(PlayerAction.StateEnum.EndAtk, 1f);
  91. SingletonMono<CameraController>.Instance.CameraZoomFinished();
  92. this._recoverInvincible = true;
  93. }
  94. private GameObject _target;
  95. private float _clearRate;
  96. private float _recoverRate;
  97. private bool _flashAtkStart;
  98. private bool _recoverInvincible;
  99. private float _invincibleTime;
  100. }