Пример #1
0
    void Update()
    {
        if (_currentGamepads != null)
        {
            for (int i = 0; i < _currentGamepads.Length; i++)
            {
                float h = GamepadInput.GetAxis("Horizontal", _currentGamepads[i].Type, _currentGamepads[i].Id);
                float v = GamepadInput.GetAxis("Vertical", _currentGamepads[i].Type, _currentGamepads[i].Id);

                playerPanels[i].h.text  = "H = " + h.ToString("0.00");
                playerPanels[i].h.color = (h == 0f ? Color.black : Color.red);

                playerPanels[i].v.text  = "V = " + v.ToString("0.00");
                playerPanels[i].v.color = (v == 0f ? Color.black : Color.red);

                bool f1 = GamepadInput.GetButton("Fire1", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f2 = GamepadInput.GetButton("Fire2", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f3 = GamepadInput.GetButton("Fire3", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f4 = GamepadInput.GetButton("Fire4", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f5 = GamepadInput.GetButton("Fire5", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f6 = GamepadInput.GetButton("Fire6", _currentGamepads[i].Type, _currentGamepads[i].Id);

                playerPanels[i].f1.color = (f1 ? Color.red : Color.black);
                playerPanels[i].f2.color = (f2 ? Color.red : Color.black);
                playerPanels[i].f3.color = (f3 ? Color.red : Color.black);
                playerPanels[i].f4.color = (f4 ? Color.red : Color.black);
                playerPanels[i].f5.color = (f5 ? Color.red : Color.black);
                playerPanels[i].f6.color = (f6 ? Color.red : Color.black);

                if (_currentGamepads[i].Player == Player.One)
                {
                    string submit = GamepadInput.GetButtonForUI("Submit", _currentGamepads[i].Type, _currentGamepads[i].Id);
                    string cancel = GamepadInput.GetButtonForUI("Cancel", _currentGamepads[i].Type, _currentGamepads[i].Id);

                    bool sValue = Input.GetButtonDown(submit);
                    bool cValue = Input.GetButtonDown(cancel);

                    playerPanels[i].submit.color = (sValue ? Color.red : Color.black);
                    playerPanels[i].cancel.color = (cValue ? Color.red : Color.black);

                    bool start = GamepadInput.GetButton("Start", _currentGamepads[i].Type, _currentGamepads[i].Id);

                    if (f5 && f6 && start)
                    {
                        gameObject.SetActive(false);
                        prevScreen.SetActive(true);

                        if (_prevButton != null)
                        {
                            EventSystem.current.SetSelectedGameObject(_prevButton);
                        }
                    }
                }
            }
        }
    }
Пример #2
0
    private void UpdateForGamepadManager()
    {
        _state = GamepadManager.Instance.GetAssignedGamepad(0);

        if (!_state.IsConnected())
        {
            return;
        }

        float h = GamepadInput.GetAxis("Horizontal", _state.Type, _state.Id);
        float v = GamepadInput.GetAxis("Vertical", _state.Type, _state.Id);

        _player.SetMoveValue(h, v);

        if (GamepadInput.GetButtonDown("Fire1", _state.Type, _state.Id))
        {
            _player.SetRunValue(true);
        }

        if (GamepadInput.GetButtonUp("Fire1", _state.Type, _state.Id))
        {
            _player.SetRunValue(true);
        }

        switch (currentShootType)
        {
        case ShootType.WithButtons:


            if (GamepadInput.GetButtonDown("Fire4", _state.Type, _state.Id))
            {
                _player.InitShootAttack();
            }

            if (GamepadInput.GetButton("Fire4", _state.Type, _state.Id))
            {
                _player.UpdateShootAttack();
            }

            if (GamepadInput.GetButtonUp("Fire4", _state.Type, _state.Id))
            {
                _player.FinalizeShootAttack();
            }
            break;
        }
    }
Пример #3
0
    private void UpdateForGamepadManager()
    {
        _state = GamepadManager.Instance.GetAssignedGamepad(0);

        if (!_state.IsConnected())
        {
            return;
        }

        float ah = GamepadInput.GetAxis("AltHorizontal", _state.Type, _state.Id);
        float av = GamepadInput.GetAxis("AltVertical", _state.Type, _state.Id);

        _assist.SetMoveValue(ah, av);

        if (GamepadInput.GetButton("Fire5", _state.Type, _state.Id))
        {
            _assist.SetState(-1f);
        }

        if (GamepadInput.GetButton("Fire6", _state.Type, _state.Id))
        {
            _assist.SetState(1f);
        }

        float rt = GamepadInput.GetAxis("RightTrigger", _state.Type, _state.Id);

        if (rt > 0f && _prevRT == 0f)  // RT Down
        {
            _assist.SetHead(true);
        }
        _prevRT = rt;

        float lt = GamepadInput.GetAxis("LeftTrigger", _state.Type, _state.Id);

        if (lt > 0f && _prevLT == 0f)  // LT Down
        {
            _assist.SetHead(false);
        }
        _prevLT = lt;
    }
    private void UpdateForGamepadManager()
    {
        _state = GamepadManager.Instance.GetAssignedGamepad(0);

        if (!_state.IsConnected())
        {
            return;
        }

        float ah = GamepadInput.GetAxis("AltHorizontal", _state.Type, _state.Id);
        float av = GamepadInput.GetAxis("AltVertical", _state.Type, _state.Id);

        _assist.SetMoveValue(ah, av);

        if (GamepadInput.GetButton("Fire1", _state.Type, _state.Id))
        {
            _assist.SetState(AssistBehavior.AssistState.Shield);
        }

        if (GamepadInput.GetButton("Fire2", _state.Type, _state.Id))
        {
            _assist.SetState(AssistBehavior.AssistState.AutoFire);
        }

        if (GamepadInput.GetButton("Fire3", _state.Type, _state.Id))
        {
            _assist.SetState(AssistBehavior.AssistState.MultiplyFire);
        }

        if (GamepadInput.GetButton("Fire4", _state.Type, _state.Id))
        {
            _assist.SetState(AssistBehavior.AssistState.MultiplyVelocity);
        }

        _assist.AlignWithPlayer(GamepadInput.GetButton("Fire5", _state.Type, _state.Id));
    }
    private void UpdateForGamepadManager()
    {
        _state = GamepadManager.Instance.GetAssignedGamepad(0);

        if (!_state.IsConnected())
        {
            return;
        }

        float h = GamepadInput.GetAxis("Horizontal", _state.Type, _state.Id);
        float v = GamepadInput.GetAxis("Vertical", _state.Type, _state.Id);

        _player.SetMoveValue(h, v);

        float lt = GamepadInput.GetAxis("LeftTrigger", _state.Type, _state.Id);

        if (lt > 0f && _prevLT == 0f)  // LT Down
        {
            _player.SetRunValue(true);
        }
        else if (lt == 0f && _prevLT > 0f) // LT Up
        {
            _player.SetRunValue(false);
        }
        _prevLT = lt;

        switch (currentShootType)
        {
        case ShootType.WithTriggers:
            float rt = GamepadInput.GetAxis("RightTrigger", _state.Type, _state.Id);
            if (rt > 0f && _prevRT == 0f)      // RT Down
            {
                _player.InstantShootAttack();
            }
            else if (rt > 0f && _prevRT > 0f)     // RT Stay
            {
                _player.InstantShootAttack();
            }
            _prevRT = rt;

            if (GamepadInput.GetButtonDown("Fire6", _state.Type, _state.Id))
            {
                _player.InitShootAttack();
            }

            if (GamepadInput.GetButton("Fire6", _state.Type, _state.Id))
            {
                _player.UpdateShootAttack();
            }

            if (GamepadInput.GetButtonUp("Fire6", _state.Type, _state.Id))
            {
                _player.FinalizeShootAttack();
            }
            break;

        case ShootType.WithStick:
            float ah = GamepadInput.GetAxis("AltHorizontal", _state.Type, _state.Id);
            float av = GamepadInput.GetAxis("AltVertical", _state.Type, _state.Id);
            _player.InstantShootAttack(ah, av);
            break;
        }
    }
 public static float GetWhammyInput(this GamepadInput gamepad)
 {
     return(gamepad.GetAxis(GamepadInput.Axis.RightStickX));
 }