private void AssignJoysticksToPlayers()
        {
            IList <Joystick> joysticks = ReInput.controllers.Joysticks;

            for (int i = 0; i < joysticks.Count; i++)
            {
                Joystick joystick = joysticks[i];
                if (ReInput.controllers.IsControllerAssigned(joystick.type, joystick.id))
                {
                    continue;                                                                      // joystick is already assigned to a Player
                }
                if (joystick.GetAnyButtonDown())
                {
                    Player player = FindPlayerWithoutJoystick();
                    if (player == null)
                    {
                        return;                // return on no free joysticks
                    }
                    player.controllers.AddController(joystick, false);
                }
            }

            // If all players have joysticks, enable joystick auto-assignment
            // so controllers are re-assigned correctly when a joystick is disconnected
            // and re-connected and disable this script
            if (DoAllPlayersHaveJoysticks())
            {
                ReInput.configuration.autoAssignJoysticks = true;
                this.enabled = false; // disable this script
            }
        }
Пример #2
0
 private void CheckInputForJump()
 {
     if ((!mIsJumping) && (m_joystick.GetAnyButtonDown() || (Input.GetKeyDown(KeyCode.Space))))
     {
         StartJump();
     }
 }
Пример #3
0
    private void AssignJoysticksToPlayers()
    {
        IList <Joystick> joysticks = ReInput.controllers.Joysticks; //Get connected joysticks

        for (int i = 0; i < joysticks.Count; i++)
        {
            Joystick joystick = joysticks[i];
            if (ReInput.controllers.IsControllerAssigned(joystick.type, joystick.id))
            {
                continue;                                                                       //Next iteration if joystick is already assigned to a Player
            }
            if (joystick.GetAnyButtonDown())
            {
                Rewired.Player player = FindPlayerWithoutJoystick();
                if (player == null)
                {
                    return;                 // return on no free joysticks
                }
                //rewiredPlayer.controllers.maps.SetMapsEnabled(false, "Assignment");
                player.controllers.AddController(joystick, false);
            }
        }

        // If all players have joysticks, enable joystick auto-assignment
        if (DoAllPlayersHaveJoysticks())
        {
            ReInput.configuration.autoAssignJoysticks = true;
        }
    }
        private void AssignJoysticksToPlayers()
        {
            // Check all joysticks for a button press and assign it tp
            // the first Player foudn without a joystick
            IList <Joystick> joysticks = ReInput.controllers.Joysticks;

            for (int i = 0; i < joysticks.Count; i++)
            {
                Joystick joystick = joysticks[i];
                if (ReInput.controllers.IsControllerAssigned(joystick.type, joystick.id))
                {
                    continue;                                                                      // joystick is already assigned to a Player
                }
                // Chec if a button was pressed on the joystick
                if (joystick.GetAnyButtonDown())
                {
                    // Find the next Player without a Joystick
                    Player player = FindPlayerWithoutJoystick();
                    if (player == null)
                    {
                        return;                // no free joysticks
                    }
                    // Assign the joystick to this Player
                    player.controllers.AddController(joystick, false);
                }
            }

            // If all players have joysticks, enable joystick auto-assignment
            // so controllers are re-assigned correctly when a joystick is disconnected
            // and re-connected and disable this script
            if (DoAllPlayersHaveJoysticks())
            {
                ReInput.configuration.autoAssignJoysticks = true;
            }
        }
Пример #5
0
        private void CheckJoystickInput()
        {
            IList <Joystick> joysticks = ReInput.controllers.Joysticks;

            for (int i = 0; i < joysticks.Count; i++)
            {
                Joystick joystick = joysticks[i];
                if (joystick.GetAnyButtonDown())
                {
                    AudioManager.Instance.PlayOneShoot2D(this.readyFXClip);
                    Debug.Log("Someone pressed a button!");
                    this.assigner.enabled = true;
                    this.UI.ChangeScreen(1);
                    this.enabled = false;
                }
            }
        }
Пример #6
0
        private void AssignJoysticks()
        {
            IList <Joystick> joysticks = ReInput.controllers.Joysticks;

            for (int i = 0; i < joysticks.Count; i++)
            {
                Joystick joystick = joysticks[i];
                if (ReInput.controllers.IsControllerAssigned(joystick.type, joystick.id))
                {
                    this.m_CanvasController.SetPanel(i, JoystickPlayerState.Selected);
                    continue;
                }
                if (joystick.GetAnyButtonDown())
                {
                    Rewired.Player player = ReInput.players.Players[i];
                    //Rewired.Player player = FindPlayerWithoutJoystick();
                    //if (player == null)
                    //return;
                    players++;
                    Debug.Log("Joined: " + player.descriptiveName);
                    player.controllers.AddController(joystick, false);
                    Debug.Log(player.descriptiveName + " is playing: " + player.isPlaying);
                    AudioManager.Instance.PlayOneShoot2D(selectedClip);
                    this.EnableStart(true);
                }
            }
            // If all players have joysticks, enable joystick auto-assignment
            // so controllers are re-assigned correctly when a joystick is disconnected
            // and re-connected and disable this script
            //if (DoAllPlayersHaveJoysticks())
            //{
            //    ReInput.configuration.autoAssignJoysticks = true;
            //    this.enabled = false; // disable this script
            //    MenuManager.Instance.ChangeScene(1);
            //}
        }