PlayerActionController.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using UnityEngine;
  3. public class PlayerActionController : BaseBehaviour
  4. {
  5. private void Awake()
  6. {
  7. this._playerAbilities = base.GetComponent<PlayerAbilities>();
  8. this._playerAction = base.GetComponent<PlayerAction>();
  9. this._stateMachine = base.GetComponent<StateMachine>();
  10. }
  11. public void ChangeState(PlayerAction.StateEnum nextState)
  12. {
  13. this._stateMachine.SetState(nextState);
  14. }
  15. public void TurnRound(int dir)
  16. {
  17. this._playerAction.TurnRound(dir);
  18. }
  19. public void StartMove()
  20. {
  21. this._move = true;
  22. }
  23. public void StopMove()
  24. {
  25. this._move = false;
  26. }
  27. public void Jump()
  28. {
  29. this._playerAbilities.jump.Jump();
  30. }
  31. public void Flash()
  32. {
  33. this._playerAbilities.flash.FlashOnce();
  34. }
  35. private void Update()
  36. {
  37. if (this.openPos)
  38. {
  39. base.transform.position = this.position;
  40. }
  41. if (this._move)
  42. {
  43. this._playerAbilities.move.Move(R.Player.Attribute.faceDir);
  44. }
  45. }
  46. private PlayerAction _playerAction;
  47. private PlayerAbilities _playerAbilities;
  48. private StateMachine _stateMachine;
  49. public Vector3 position;
  50. public bool openPos;
  51. private bool _move;
  52. }