PlayerHitGroundAbility.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using System.Collections;
  3. using ExtensionMethods;
  4. using UnityEngine;
  5. public class PlayerHitGroundAbility : CharacterState
  6. {
  7. public override void Start()
  8. {
  9. this._atkBox = this.pac.GetComponentInChildren<PlayerAtk>().transform;
  10. this._platform = R.Player.GetComponent<PlatformMovement>();
  11. }
  12. public override void Update()
  13. {
  14. if (this.pAttr.isDead)
  15. {
  16. return;
  17. }
  18. if (R.Player.TimeController.isPause)
  19. {
  20. return;
  21. }
  22. if (this.listener.checkHitGround && this.pAttr.isOnGround)
  23. {
  24. R.Player.TimeController.SetSpeed(Vector2.zero);
  25. this.listener.PhysicReset();
  26. this.listener.checkHitGround = false;
  27. Vector3 position = new Vector3(0f, this._platform.GetDistanceToGround(), 0f);
  28. R.Effect.Generate(22, this.pac.transform, position, Vector3.zero, default(Vector3), true);
  29. string currentState = this.stateMachine.currentState;
  30. switch (currentState)
  31. {
  32. case "Roll":
  33. case "DahalRoll":
  34. this._atkBox.localScale = Vector2.zero;
  35. this.pac.ChangeState(PlayerAction.StateEnum.RollEnd, 1f);
  36. break;
  37. case "HitGround":
  38. this.pac.ChangeState(PlayerAction.StateEnum.HitGround2, 1f);
  39. break;
  40. case "RollEndFrame":
  41. this.pac.ChangeState(PlayerAction.StateEnum.RollFrameEnd, 1f);
  42. break;
  43. case "QTEHitGround":
  44. this.pac.ChangeState(PlayerAction.StateEnum.QTEHitGround2, 1f);
  45. break;
  46. case "NewExecuteAir1_2":
  47. SingletonMono<CameraController>.Instance.KillTweening();
  48. SingletonMono<CameraController>.Instance.CloseMotionBlur();
  49. base.StartCoroutine(this.ExecuteHitGround());
  50. break;
  51. case "QTERoll":
  52. this.pac.ChangeState(PlayerAction.StateEnum.QTERollEnd, 1f);
  53. break;
  54. }
  55. }
  56. }
  57. private IEnumerator ExecuteHitGround()
  58. {
  59. yield return new WaitForSeconds(0.05f);
  60. this.listener.StartExecute();
  61. yield break;
  62. }
  63. public void HitGround()
  64. {
  65. if (R.Player.TimeController.isPause)
  66. {
  67. return;
  68. }
  69. if (!this.pAttr.isOnGround && this.stateMachine.currentState.IsInArray(PlayerHitGroundAbility.CanHitGroundSta) && R.Player.Enhancement.HitGround != 0)
  70. {
  71. this.listener.StopIEnumerator("FlashPositionSet");
  72. if (this.pac.tempDir != 3)
  73. {
  74. this.pac.TurnRound(this.pac.tempDir);
  75. }
  76. this.weapon.HandleHitGround();
  77. }
  78. }
  79. public override void OnStateMachineStateTransfer(object sender, StateMachine.TransferEventArgs args)
  80. {
  81. if (args.nextState == "Roll")
  82. {
  83. Vector2 speed = new Vector2((float)(4 * this.pAttr.faceDir), 0f);
  84. this.listener.AirPhysic(0.8f);
  85. R.Player.TimeController.SetSpeed(speed);
  86. }
  87. }
  88. private static readonly string[] CanHitGroundSta = new string[]
  89. {
  90. "Fall1",
  91. "Fall2",
  92. "Flash2",
  93. "FlashDown2",
  94. "FlashUp2",
  95. "Flash1",
  96. "FlashDown1",
  97. "FlashUp1",
  98. "UpRising",
  99. "Jump",
  100. "Jump2",
  101. "RollJump",
  102. "IdleToDefense",
  103. "Defense",
  104. "FallToDefenseAir",
  105. "DefenseAir",
  106. "AirAtk1",
  107. "AirAtk2",
  108. "AirAtk3",
  109. "AirAtk4",
  110. "AirAtk6",
  111. "AirAtkHv1",
  112. "AirAtkHv2",
  113. "AirAtkHv3",
  114. "AirAtkHv4",
  115. "AirAtkHv5",
  116. "AirAtkHv1Push",
  117. "RollReady",
  118. "Roll",
  119. "Execute2ToFall"
  120. };
  121. private Transform _atkBox;
  122. private PlatformMovement _platform;
  123. }