示例#1
0
文件: Lobby.cs 项目: TxN/LD40Entry
    void InitInputConfigurations()
    {
        int playerNumber = InputMng.GetJoystickNames().Length;

        if (playerNumber > 4)
        {
            playerNumber = 4;
        }

        string confNamePrefix = "Win";

        if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor)
        {
            confNamePrefix = "OS_X";
        }

        for (int i = 0; i < playerNumber; i++)
        {
            TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(i);
            InputMng.SetInputConfiguration(confNamePrefix + "_gamepad_" + (i + 1), playerId);
        }

        if (playerNumber < 4)
        {
            TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(playerNumber);
            InputMng.SetInputConfiguration("keyboard", playerId);
            playersConnected = playerNumber + 1;
        }
        else
        {
            playersConnected = 4;
        }
    }
示例#2
0
 private IEnumerator UpdateJoystickCount()
 {
     while (true)
     {
         _joystickCount = InputManager.GetJoystickNames().Length;
         if (_inputDevice == InputDevice.Joystick && _joystickCount == 0)
         {
             Debug.LogWarning("Lost connection with joystick. Switching to keyboard and mouse input.");
             SetInputDevice(InputDevice.KeyboardAndMouse);
         }
         yield return(new WaitForSeconds(updateJoystickCountInterval));
     }
 }
示例#3
0
        public void OnInitializeAfterScriptReload()
        {
            if (_instance != null && _instance != this)
            {
                Debug.LogWarning("You have multiple InputAdapter instances in the scene!", gameObject);
            }
            else if (_instance == null)
            {
                SetInputManagerConfigurations();
                SetInputDevice(InputDevice.KeyboardAndMouse);

                _instance             = this;
                _joystickCount        = InputManager.GetJoystickNames().Length;
                _lastInputDeviceCheck = Time.deltaTime;
            }
        }
示例#4
0
        private void Awake()
        {
            if (_instance != null)
            {
                Destroy(this);
            }
            else
            {
                SetInputManagerConfigurations();
                SetInputDevice(InputDevice.KeyboardAndMouse);

                _instance      = this;
                _joystickCount = InputManager.GetJoystickNames().Length;

                if (dontDestroyOnLoad)
                {
                    DontDestroyOnLoad(gameObject);
                }
            }
        }
示例#5
0
 public static string[] GetJoystickNames()
 {
     return(InputManager.GetJoystickNames());
 }