예제 #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());
 }