예제 #1
0
 void Start()
 {
     cameraInputData.ResetInput();
     movementInputData.ResetInput();
     interactionInputData.ResetInput();
 }
예제 #2
0
 void Start()
 {
     cameraInputData.ResetInput();
     movementInputData.ResetInput();
 }
예제 #3
0
        void Awake()
        {
            _playerControls = new PlayerControls();

            _controls = GetComponent <PlayerInput>();

            InputSystem.pollingFrequency = 120;

            // _controls.onControlsChanged += onInputDeviceChange;

            //InputUser.onChange += onInputDeviceChange;

            _playerControls.Player.Continue.performed += context =>
            {
                if (!_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }

                _playerManager.isDead = false;
                //_playerManager.SetUp();

                GameMaster._current.RestartLevel();
            };

            _playerControls.Player.Movement.performed += context =>
            {
                if (_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }

                movementInputData.InputVector = context.ReadValue <Vector2>();
            };

            _playerControls.Player.Sprint.performed += context =>
            {
                if (_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }

                movementInputData.RunClicked  = true;
                movementInputData.RunReleased = false;
                movementInputData.IsRunning   = true;
                PlayerEvents.Current.StartSprint();
            };

            _playerControls.Player.Sprint.canceled += context =>
            {
                if (_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }

                movementInputData.RunReleased = true;
                movementInputData.RunClicked  = false;
                movementInputData.IsRunning   = false;
                PlayerEvents.Current.StopSprint();
            };

            _playerControls.Player.Jump.performed += context =>
            {
                if (_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }
                movementInputData.JumpClicked = true;
            };

            _playerControls.Player.Crouch.performed += context =>
            {
                if (_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }

                if (PlayerEvents.Current.isCrouching)
                {
                    PlayerEvents.Current.Stand();
                }
                else
                {
                    PlayerEvents.Current.Crouch();
                }

                movementInputData.CrouchClicked = true;
            };

            _playerControls.Player.Look.performed += context =>
            {
                if (_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }

                cameraInputData.InputVector = context.ReadValue <Vector2>();
            };

            _playerControls.Player.Interact.performed += context =>
            {
                if (_playerManager.isDead || GameMaster._current.IsPaused)
                {
                    return;
                }
                _interactionController.Interact();
            };

            cameraInputData.ResetInput();
            movementInputData.ResetInput();
        }