Ejemplo n.º 1
0
    private void OnPlayerInputChanged(InputListener inputListener)
    {
        PlayerControlInfo playerControlInfos = inputListener.m_Player == EPlayer.Player1 ? m_Player1ControlsMapping : m_Player2ControlsMapping;
        List <EInputKey>  unassignedInputs   = new List <EInputKey>(PlayerGamePad.K_ASSIGNABLE_INPUTS);

        for (int i = 0; i < playerControlInfos.m_InputListeners.Length; i++)
        {
            if (playerControlInfos.m_InputListeners[i] != inputListener && playerControlInfos.m_InputListeners[i].m_CurrentInputKey == inputListener.m_CurrentInputKey)
            {
                EGamePadType playerGamepadType = GamePadManager.GetPlayerGamepadType((int)inputListener.m_Player);

                playerControlInfos.m_InputListeners[i].m_CurrentInputKey = inputListener.m_OldInputKey;
                playerControlInfos.m_InputListeners[i].UpdateInputForGamepadType(playerGamepadType);

                GamePadManager.SetPlayerGamepadInputMapping((int)inputListener.m_Player, inputListener.m_OldInputKey, playerControlInfos.m_InputListeners[i].m_DefaultInputKey);
            }

            unassignedInputs.Remove(playerControlInfos.m_InputListeners[i].m_CurrentInputKey);
        }

#if UNITY_EDITOR || DEBUG_DISPLAY
        if (unassignedInputs.Count > 1)
        {
            KakutoDebug.LogError("There should be only one unassigned remaining input after OnPlayerInputChanged");
        }
#endif

        for (int i = 0; i < unassignedInputs.Count; i++)
        {
            GamePadManager.SetPlayerGamepadInputMapping((int)inputListener.m_Player, unassignedInputs[i], PlayerGamePad.K_DEFAULT_UNASSIGNED_INPUT);
        }
    }
Ejemplo n.º 2
0
    private void UpdateInputForGamepadType(EGamePadType gamePadType, PlayerControlInfo playerControlInfos)
    {
        bool isXboxGamepad = gamePadType == EGamePadType.Xbox;

        playerControlInfos.m_PS4ConsoleText.enabled  = !isXboxGamepad;
        playerControlInfos.m_XboxConsoleText.enabled = isXboxGamepad;

        for (int i = 0; i < playerControlInfos.m_InputListeners.Length; i++)
        {
            playerControlInfos.m_InputListeners[i].UpdateInputForGamepadType(gamePadType);
        }
    }
Ejemplo n.º 3
0
    private IEnumerator EngineMonitor(PlayerControlInfo playerControlInfo)
    {
        while (true)
        {
            GameObject MySound;
            yield return(new WaitUntil(() => playerControlInfo.direction.magnitude > .2f));

            MySound = SoundManager.instance.StartLoop(EngineRun, p.ToString(), 0.3f * (myParts[p].val[(int)part.muffler] == 0 ? 2 : 1));
            MySound.GetComponent <AudioSource>().pitch = 1f + playerControlInfo.direction.magnitude;
            yield return(new WaitUntil(() => playerControlInfo.direction == Vector3.zero));

            SoundManager.instance.StopLoop(EngineRun, p.ToString());
        }
    }
Ejemplo n.º 4
0
    public void ResetPlayerInputMapping(int playerIndex)
    {
        // Check if it's the correct player's trying to update input
        List <GameInput> gamepadInputList = GamePadManager.GetPlayerGamepadInput(playerIndex);

        if (gamepadInputList.Exists(x => x.GetInputKey() == EInputKey.A))
        {
            GamePadManager.ResetPlayerGamepadInputMapping(playerIndex);
            PlayerControlInfo playerControlInfo = playerIndex == 0 ? m_Player1ControlsMapping : m_Player2ControlsMapping;
            for (int i = 0; i < playerControlInfo.m_InputListeners.Length; i++)
            {
                playerControlInfo.m_InputListeners[i].ResetInputMapping();
            }
        }
        else
        {
            DisplayWrongPlayerFeedback();
        }
    }