Exemplo n.º 1
0
    public void SerialInputRecieved(int[] message)
    {
        if (debugMode && message.Length != 4)
        {
            return;
        }
        float wheelIntensity = (float)message [0];
        float pedalIntensity = (float)message [1];
        int   player         = (int)message [2];

        inputSystem.AddInput(pedalIntensity, player, InputSystem.PlayerInput.Type.Pedal);
        inputSystem.AddInput(wheelIntensity, player, InputSystem.PlayerInput.Type.Wheel);

        float pedalNormalized = inputSystem.players [player].pedal.GetRunningAverageNormalized();
        float wheelNormalized = -(inputSystem.players [player].wheel.GetRunningAverageNormalized() * 2f - 1f);

#if LOG_SERIAL
        serialInfo[player] = "Player " + player + "\n" +
                             "  Pedal: \n" +
                             "    Norm: " + pedalNormalized.ToString("F2") + " Cur: " + pedalIntensity + " Min: " + inputSystem.players[player].pedal.min + " Max: " + inputSystem.players[player].pedal.max +
                             "\n  Wheel: \n" +
                             "    Norm: " + wheelNormalized.ToString("F2") + " Cur: " + wheelIntensity + " Min: " + inputSystem.players[player].wheel.min + " Max: " + inputSystem.players[player].wheel.max;
#endif
        switch (currentState)
        {
        case States.playing:
            if (canControlCars)
            {
                PlayerManager.s_instance.SendOSCDataToCar(player, pedalNormalized, wheelNormalized);
            }
            break;

        case States.startScreen:
            print("I'M AT START SCREEN");
            if (pedalNormalized < .5f && playerBools [player] == false)
            {
                playerBools [player] = true;
                isPlayingTexts [player].gameObject.SetActive(true);
                if (!isCountingDown)
                {
                    StartCoroutine("CountDown");
                    isCountingDown = true;
                    joinUpSound.Play();
                }
                else
                {
                    counter = 10;
                    joinUpSound.Play();
                }
            }
            break;

        case States.config:
            break;
        }
    }