PlayerJumpAbility.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using ExtensionMethods;
  3. using GameWorld;
  4. using UnityEngine;
  5. public class PlayerJumpAbility : CharacterState
  6. {
  7. public override void Update()
  8. {
  9. if (this._invincibleRecover > 0)
  10. {
  11. this._invincibleRecover--;
  12. if (this._invincibleRecover <= 0)
  13. {
  14. this.pab.hurt.Invincible = false;
  15. }
  16. }
  17. }
  18. public void Jump()
  19. {
  20. if (R.Player.TimeController.isPause)
  21. {
  22. return;
  23. }
  24. if ((this.stateMachine.currentState.IsInArray(PlayerJumpAbility.CanJumpSta) || (this.stateMachine.currentState == "AtkUpRising" && this.pac.canChangeAnim)) && !this._firstJumped)
  25. {
  26. this._firstJumped = true;
  27. this.listener.PhysicReset();
  28. this.StateCheck();
  29. this.pac.ChangeState(PlayerAction.StateEnum.Jump, 1f);
  30. Vector2 currentSpeed = R.Player.TimeController.GetCurrentSpeed();
  31. currentSpeed.y = 20f;
  32. R.Player.TimeController.SetSpeed(currentSpeed);
  33. EventManager.PostEvent<PlayerJumpAbility, AssessmentEventArgs>("Assessment", this, new AssessmentEventArgs(AssessmentEventArgs.EventType.CurrentComboFinish));
  34. return;
  35. }
  36. if ((this.stateMachine.currentState.IsInArray(PlayerJumpAbility.SecondJumpSta) && this._firstJumped && !this._secondJumpped) || (this.stateMachine.currentState.IsInArray(PlayerJumpAbility.HurtJumpSta) && this.listener.hitJump))
  37. {
  38. if (this.listener.hitJump && this.stateMachine.currentState.IsInArray(PlayerJumpAbility.HurtJumpSta))
  39. {
  40. this.JumpEffect();
  41. this.listener.hitJump = false;
  42. this.listener.flyHitFlag = false;
  43. this.listener.flyHitGround = false;
  44. this.pab.hurt.Invincible = true;
  45. this._invincibleRecover = WorldTime.SecondToFrame(0.3f);
  46. }
  47. this._firstJumped = true;
  48. this._secondJumpped = true;
  49. this.listener.PhysicReset();
  50. this.StateCheck();
  51. this.pac.ChangeState(PlayerAction.StateEnum.RollJump, 1f);
  52. Vector2 currentSpeed2 = R.Player.TimeController.GetCurrentSpeed();
  53. currentSpeed2.y = 16f;
  54. R.Player.TimeController.SetSpeed(currentSpeed2);
  55. EventManager.PostEvent<PlayerJumpAbility, AssessmentEventArgs>("Assessment", this, new AssessmentEventArgs(AssessmentEventArgs.EventType.CurrentComboFinish));
  56. }
  57. }
  58. private void StateCheck()
  59. {
  60. this.listener.checkFallDown = false;
  61. this.listener.isFalling = false;
  62. this.listener.airAtkDown = false;
  63. }
  64. private void JumpEffect()
  65. {
  66. Transform transform = R.Effect.Generate(212, null, this.pab.transform.position, default(Vector3), default(Vector3), true);
  67. transform.localScale = this.pab.transform.localScale;
  68. }
  69. public override void OnStateMachineStateTransfer(object sender, StateMachine.TransferEventArgs args)
  70. {
  71. if (!args.lastState.IsInArray(PlayerAction.NormalSta) && args.nextState.IsInArray(PlayerAction.NormalSta))
  72. {
  73. this._firstJumped = false;
  74. this._secondJumpped = false;
  75. }
  76. }
  77. private bool _firstJumped;
  78. private bool _secondJumpped;
  79. private int _invincibleRecover;
  80. private static readonly string[] CanJumpSta = new string[]
  81. {
  82. "EndAtk",
  83. "Fall1",
  84. "Fall2",
  85. "GetUp",
  86. "Idle",
  87. "Ready",
  88. "Run",
  89. "RunSlow",
  90. "Atk1",
  91. "Atk2",
  92. "Atk3",
  93. "Atk4",
  94. "Atk5",
  95. "Atk6",
  96. "Atk7",
  97. "Atk8",
  98. "Atk11",
  99. "Atk12",
  100. "Atk13",
  101. "Atk14",
  102. "Atk23",
  103. "Atk15",
  104. "Atk16",
  105. "AtkHv1",
  106. "AtkHv2",
  107. "AtkHv3",
  108. "AtkHv1Push",
  109. "AtkUpRising",
  110. "RollReady",
  111. "Roll",
  112. "RollEnd",
  113. "Charge1Ready",
  114. "Charging1",
  115. "Charge1End",
  116. "AirAtk1",
  117. "AirAtk2",
  118. "AirAtk3",
  119. "AirAtk4",
  120. "AirAtk6",
  121. "AirAtkHv1",
  122. "AirAtkHv2",
  123. "AirAtkHv3",
  124. "AirAtkHv4",
  125. "AirAtkHv5",
  126. "AirAtkHv1Push",
  127. "AtkRollReady",
  128. "AtkRollEnd",
  129. "AirAtkRollReady",
  130. "AirAtkRoll"
  131. };
  132. private static readonly string[] SecondJumpSta = new string[]
  133. {
  134. "Fall1",
  135. "Fall2",
  136. "Jump"
  137. };
  138. private static readonly string[] HurtJumpSta = new string[]
  139. {
  140. "UnderAtkFlyToFall",
  141. "UnderAtkHitGround",
  142. "UnderAtkHitToFly"
  143. };
  144. }