コード例 #1
0
ファイル: InputManager.cs プロジェクト: mitjmcc/deepinsheep
        /// <summary>
        /// Changes the active input configuration.
        /// </summary>
        public static void SetInputConfiguration(string name, PlayerID playerID)
        {
            PlayerID?playerWhoUsesInputConfig = _instance.IsInputConfigurationInUse(name);

            if (playerWhoUsesInputConfig.HasValue && playerWhoUsesInputConfig.Value != playerID)
            {
                Debug.LogErrorFormat("The input configuration named \'{0}\' is already being used by player {1}", name, playerWhoUsesInputConfig.Value.ToString());
                return;
            }

            if (playerWhoUsesInputConfig.HasValue && playerWhoUsesInputConfig.Value == playerID)
            {
                return;
            }

            InputConfiguration inputConfig = null;

            if (_instance._configurationTable.TryGetValue(name, out inputConfig))
            {
                _instance.SetInputConfigurationByPlayerID(playerID, inputConfig);
                ResetInputConfiguration(playerID);
                _instance.RaiseInputConfigurationChangedEvent(playerID);
            }
            else
            {
                Debug.LogError(string.Format("An input configuration named \'{0}\' does not exist", name));
            }
        }