private void Update()
        {
            if (Input.GetKeyDown(KeyCode.P))
            {
                _audioSource.Play();
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                _audioSource.Stop();
            }

            if (Input.GetKeyDown(KeyCode.Pause))
            {
                if (_audioSource.IsPaused)
                {
                    _audioSource.UnPause();
                }
                else
                {
                    _audioSource.Pause();
                }
            }

            if (Input.GetKeyDown(KeyCode.M))
            {
                _audioSource.Mute = !_audioSource.Mute;
            }
        }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         AudioSource.Play();
         Particles.Play();
     }
 }
        MultiAudioSource SetupSource(AudioClip clip)
        {
            MultiAudioSource newSource = gameObject.AddComponent <MultiAudioSource>();

            newSource.loop              = true;
            newSource.volume            = 0;
            newSource.clip              = clip;
            newSource.dontDestroyOnLoad = true;

            newSource.Play();

            newSource.m_sourceObject.hideFlags = HideFlags.HideInHierarchy;
            return(newSource);
        }
示例#4
0
    private IEnumerator Nitro()
    {
        m_BrakingVelFactor = 1f;
        m_SlowingVelFactor = 1f;
        m_DriveForce       = 100f;
        m_TerminalVelocity = 400f;
        SendMessage("Detach");
        m_BoostStartAudio.Play();

        yield return(new WaitForSeconds(4));

        m_DriveForce       = 50f;
        m_TerminalVelocity = 250f;

        m_BrakingVelFactor = .95f;
        m_SlowingVelFactor = .90f;
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        if (RaceStartup.m_raceStarted == false)
        {
            m_engineStarted = false;
            m_PlayerSlot    = GetComponentInParent <DLPlayerSettings>().m_player;
            return;
        }
        else
        {
            //Get the values of the thruster, rudder, and brake from the input class
            m_Thruster = Input.GetAxis(m_playerSelected + "Throttle");
            m_Rudder   = Input.GetAxis(m_playerSelected + m_HorizontalAxisName);
            isBraking  = Input.GetButton("Player1Brake");

            if (!m_engineStarted)
            {
                m_EngineAudio.Play();
                m_FlameAudio.Play();
                m_engineStarted = true;
            }
        }
        if (m_Thruster >= 0f)
        {
        }
        else if (m_Thruster < 0f)
        {
            m_Rudder = -(Input.GetAxis(m_playerSelected + m_HorizontalAxisName));
        }

        float m_SpeedPercent = GetSpeedPercentage();

        m_EngineAudio.Volume = Mathf.Lerp(m_EngineMinVolume, m_EngineMaxVolume, m_SpeedPercent);            //++++++++
        m_EngineAudio.Pitch  = Mathf.Lerp(m_EngineMinPitch, m_EngineMaxPitch, m_SpeedPercent);

        m_FlameAudio.Volume = Mathf.Lerp(m_FlamesMinVolume, m_FlamesMaxVolume, m_SpeedPercent);
        m_FlameAudio.Pitch  = Mathf.Lerp(m_FlamesMinPitch, m_FlamesMaxPitch, m_SpeedPercent);



        //Starts to slowly increase drift value if drift button is pressed
        if (Input.GetButton(m_playerSelected + "Drift") && m_DriftIntencity < m_MaxDrift)
        {
            m_DriftIntencity = m_DriftIntencity * 1.05f;
            print("Drift on");
            isDrifting = true;
        }
        else if (Input.GetButton(m_playerSelected + "BoostDrift"))
        {
            m_DriftIntencity   = 1000f;
            m_BrakingVelFactor = 1f;
            m_SlowingVelFactor = 1f;
            print("BoostDrift on");
            isDrifting = true;
        }
        else if (Input.GetButtonUp(m_playerSelected + "BoostDrift"))
        {
            m_DriftIntencity   = 1f;
            m_BrakingVelFactor = .95f;
            m_SlowingVelFactor = .90f;

            print("BoostDrift off");
            isDrifting = true;
        }

        //...and slowly decrease the value when drift button isn't pressed
        else if (isDrifting == true && !Input.GetButton(m_playerSelected + "Drift"))
        {
            m_DriftIntencity = m_DriftIntencity * .90f;

            if (m_DriftIntencity < 1f)
            {
                isDrifting = false;
                print("dRIFT False");
                m_DriftIntencity = 1f;
            }
        }
        else if (Input.GetButton(m_playerSelected + "Respawn"))
        {
            StartCoroutine(Respawn());
        }

        foreach (SkillP2 s in skills)
        {
            if (s.m_CurrentCooldown < s.m_Cooldown)                                 //Current cooldown while it's running. Goes from 0 to skill Cooldown.
            {
                s.m_CurrentCooldown     += Time.deltaTime;                          //Remaining cooldown goes from 0 to skill Cooldown.
                s.m_SkillIcon.fillAmount = s.m_CurrentCooldown / s.m_Cooldown;      //Fills the icon with 360 radial fill
                s.m_TimeText.text        = s.m_CurrentCooldown.ToString("F0");      //Updates remaining cooldown Text to skill icon
            }
            else if (s.m_CurrentCooldown >= s.m_Cooldown)                           //Cooldown finished
            {
                s.m_TimeText.enabled = false;                                       //Hide cooldown text while skill cooldown isn't happening
            }
        }


        if (Input.GetButton(m_playerSelected + "Boost"))             //When key is pressed
        {
            if (skills[0].m_CurrentCooldown >= skills[0].m_Cooldown) //Cooldown is happening?
            {
                StartCoroutine(Nitro());                             //Do something
                skills[0].m_TimeText.enabled = true;                 //Enable cooldown time Text
                skills[0].m_CurrentCooldown  = 0;
            }
        }
        else if (Input.GetButtonDown(m_playerSelected + "Fire"))
        {
            if (skills[1].m_CurrentCooldown >= skills[1].m_Cooldown)
            {
                Fire();
                skills[1].m_TimeText.enabled = true;
                skills[1].m_CurrentCooldown  = 0;
            }
        }
        if (DLSetFinish.m_raceFinished == true)
        {
            RaceHolding();
        }
    }