PlayerChargingAbility.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using System;
  2. using Core;
  3. using ExtensionMethods;
  4. using UnityEngine;
  5. public class PlayerChargingAbility : CharacterState
  6. {
  7. public override void Update()
  8. {
  9. if (this.pAttr.isInCharging && Core.Input.Game.Atk.OnReleased)
  10. {
  11. bool flag = this.stateMachine.currentState == "AirCharging";
  12. if (this.weapon.canChargeAttack)
  13. {
  14. this.pac.TurnRound(this.pac.tempDir);
  15. this.ReleaseCharge(flag);
  16. }
  17. else
  18. {
  19. this.pac.ChangeState((!flag) ? PlayerAction.StateEnum.EndAtk : PlayerAction.StateEnum.Fall1, 1f);
  20. this.CancelCharge();
  21. }
  22. }
  23. }
  24. public void Charging()
  25. {
  26. if (this.stateMachine.currentState.IsInArray(PlayerChargingAbility.CanChargeSta) && R.Player.Enhancement.Charging != 0 && ChipManager.HasChipInScene())
  27. {
  28. if (this.pAttr.isOnGround)
  29. {
  30. this.StartChargeGround();
  31. }
  32. else
  33. {
  34. this.StartChargeInAir();
  35. }
  36. }
  37. }
  38. private void StartChargeGround()
  39. {
  40. if (!this._chargeReset)
  41. {
  42. return;
  43. }
  44. R.Player.TimeController.SetSpeed(Vector2.zero);
  45. this.weapon.StartCharge(false);
  46. this._chargeReset = false;
  47. }
  48. private void StartChargeInAir()
  49. {
  50. if (!this._chargeReset)
  51. {
  52. return;
  53. }
  54. R.Player.TimeController.SetSpeed(Vector2.zero);
  55. this.listener.AirPhysic(0f);
  56. this.weapon.StartCharge(true);
  57. this._chargeReset = false;
  58. }
  59. public void CancelCharge()
  60. {
  61. this.ChargeReset();
  62. this.weapon.ChargeCancel();
  63. }
  64. public void ChargeReset()
  65. {
  66. this._chargeReset = true;
  67. }
  68. private void ReleaseCharge(bool inAir)
  69. {
  70. this.weapon.ReleaseCharge(inAir);
  71. }
  72. public override void OnStateMachineStateTransfer(object sender, StateMachine.TransferEventArgs args)
  73. {
  74. if (args.lastState.IsInArray(PlayerAction.ChargeSta) && !args.nextState.IsInArray(PlayerAction.ChargeSta))
  75. {
  76. this.CancelCharge();
  77. this.pac.absorbNum = 0;
  78. }
  79. }
  80. public override void Start()
  81. {
  82. this.ChargeReset();
  83. }
  84. private bool _chargeReset;
  85. private static readonly string[] CanChargeSta = new string[]
  86. {
  87. "Atk1",
  88. "Atk2",
  89. "Atk3",
  90. "Atk4",
  91. "Atk5",
  92. "Atk6",
  93. "Atk7",
  94. "Atk8",
  95. "Atk11",
  96. "Atk12",
  97. "Atk13",
  98. "Atk14",
  99. "Atk23",
  100. "Atk15",
  101. "AtkHv1",
  102. "AtkHv2",
  103. "AtkHv3",
  104. "Atk16",
  105. "AirAtk1",
  106. "AirAtk2",
  107. "AirAtk3",
  108. "AirAtk4",
  109. "AirAtk6",
  110. "AirAtkHv1",
  111. "AirAtkHv2",
  112. "AirAtkHv3",
  113. "AirAtkHv4",
  114. "AirAtkHv5",
  115. "AirAtkHv1Push",
  116. "AirAtkRollReady",
  117. "AirAtkRoll",
  118. "Fall1",
  119. "Fall2",
  120. "Flash2",
  121. "FlashDown2",
  122. "FlashUp2",
  123. "AtkHv1Push",
  124. "Flash1",
  125. "FlashDown1",
  126. "FlashUp1",
  127. "HitGround",
  128. "HitGround2",
  129. "RollReady",
  130. "Roll",
  131. "RollEnd",
  132. "IdleToDefense",
  133. "Defense",
  134. "FallToDefenseAir",
  135. "DefenseAir",
  136. "EndAtk",
  137. "GetUp",
  138. "Idle",
  139. "Ready",
  140. "Run",
  141. "RunSlow",
  142. "ExecuteToIdle",
  143. "Execute2ToFall",
  144. "FlashGround"
  145. };
  146. }