PlayerAbilities.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System;
  2. public class PlayerAbilities : BaseBehaviour
  3. {
  4. private void Awake()
  5. {
  6. this.stateMachine = R.Player.StateMachine;
  7. this.stateMachine.OnEnter += this.OnStateMachineStateEnter;
  8. this.stateMachine.OnExit += this.OnStateMachineStateExit;
  9. this.stateMachine.OnTransfer += this.OnStateMachineStateTransfer;
  10. this.states = new CharacterState[13];
  11. this.states[0] = this.move;
  12. this.states[1] = this.attack;
  13. this.states[2] = this.jump;
  14. this.states[3] = this.charge;
  15. this.states[4] = this.execute;
  16. this.states[5] = this.hitGround;
  17. this.states[6] = this.upRising;
  18. this.states[7] = this.jumpDown;
  19. this.states[8] = this.flash;
  20. this.states[9] = this.skill;
  21. this.states[10] = this.flashAttack;
  22. this.states[11] = this.hurt;
  23. this.states[12] = this.chase;
  24. for (int i = 0; i < this.states.Length; i++)
  25. {
  26. this.states[i].Init();
  27. }
  28. }
  29. private void Start()
  30. {
  31. for (int i = 0; i < this.states.Length; i++)
  32. {
  33. this.states[i].Start();
  34. }
  35. }
  36. private void Update()
  37. {
  38. for (int i = 0; i < this.states.Length; i++)
  39. {
  40. this.states[i].Update();
  41. }
  42. }
  43. private void OnEnable()
  44. {
  45. for (int i = 0; i < this.states.Length; i++)
  46. {
  47. this.states[i].OnEnable();
  48. }
  49. }
  50. private void OnDisable()
  51. {
  52. for (int i = 0; i < this.states.Length; i++)
  53. {
  54. this.states[i].OnDisable();
  55. }
  56. }
  57. private void OnDestroy()
  58. {
  59. for (int i = 0; i < this.states.Length; i++)
  60. {
  61. this.states[i].OnDestroy();
  62. }
  63. }
  64. private void FixedUpdate()
  65. {
  66. for (int i = 0; i < this.states.Length; i++)
  67. {
  68. this.states[i].FixedUpdate();
  69. }
  70. }
  71. public virtual void OnStateMachineStateTransfer(object sender, StateMachine.TransferEventArgs args)
  72. {
  73. for (int i = 0; i < this.states.Length; i++)
  74. {
  75. this.states[i].OnStateMachineStateTransfer(sender, args);
  76. }
  77. }
  78. public virtual void OnStateMachineStateEnter(object sender, StateMachine.StateEventArgs args)
  79. {
  80. for (int i = 0; i < this.states.Length; i++)
  81. {
  82. this.states[i].OnStateMachineStateEnter(sender, args);
  83. }
  84. }
  85. public virtual void OnStateMachineStateExit(object sender, StateMachine.StateEventArgs args)
  86. {
  87. for (int i = 0; i < this.states.Length; i++)
  88. {
  89. this.states[i].OnStateMachineStateExit(sender, args);
  90. }
  91. }
  92. public PlayerMoveAbility move = new PlayerMoveAbility();
  93. public PlayerAttackAbility attack = new PlayerAttackAbility();
  94. public PlayerJumpAbility jump = new PlayerJumpAbility();
  95. public PlayerChargingAbility charge = new PlayerChargingAbility();
  96. public PlayerExecuteAbility execute = new PlayerExecuteAbility();
  97. public PlayerHitGroundAbility hitGround = new PlayerHitGroundAbility();
  98. public PlayerUpRisingAbility upRising = new PlayerUpRisingAbility();
  99. public PlayerJumpDownAbility jumpDown = new PlayerJumpDownAbility();
  100. public PlayerFlashAbility flash = new PlayerFlashAbility();
  101. public PlayerSkillAbility skill = new PlayerSkillAbility();
  102. public PlayerFlashAttackAbility flashAttack = new PlayerFlashAttackAbility();
  103. public PlayerHurtAbility hurt = new PlayerHurtAbility();
  104. public PlayerChaseAbility chase = new PlayerChaseAbility();
  105. protected StateMachine stateMachine;
  106. private CharacterState[] states;
  107. }