Exemplo n.º 1
0
        /// <summary>
        /// Changes the active control scheme.
        /// </summary>
        public static void SetControlScheme(string name, PlayerID playerID)
        {
            PlayerID?playerWhoUsesControlScheme = m_instance.IsControlSchemeInUse(name);

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

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

            ControlScheme controlScheme = null;

            if (m_instance.m_schemeLookup.TryGetValue(name, out controlScheme))
            {
                controlScheme.Reset();
                m_instance.SetControlSchemeByPlayerID(playerID, controlScheme);
                m_instance.RaisePlayerControlsChangedEvent(playerID);
            }
            else
            {
                Debug.LogError(string.Format("A control scheme named \'{0}\' does not exist", name));
            }
        }