Пример #1
0
    IEnumerator ShowNotice()
    {
        pickupManager.TotalCollected++;
        pickupManager.ChangeTotalPickups(-1);
        noticesManager.ShowNotice(noticeSprite, pickupType + " pickup collected!");
        noticesManager.RemoveNotice("A pickup has spawned!");
        yield return(new WaitForSeconds(3f));

        noticesManager.RemoveNotice(pickupType + " pickup collected!");
    }
Пример #2
0
    // Show a notice to say a pickup has spawned
    IEnumerator ShowNotice()
    {
        pickupManager.ChangeTotalPickups(1);
        noticesManager.ShowNotice(noticeSprite, "A pickup has spawned!");
        yield return(new WaitForSeconds(3f));

        noticesManager.RemoveNotice("A pickup has spawned!");
        yield return(new WaitForSeconds(3f));
    }
Пример #3
0
    void Update()
    {
        if (!pauseManager.Paused)
        {
            // Horn sound
            if (Input.GetKeyDown(KeyCode.H))
            {
                if (!hornSound.isPlaying)
                {
                    hornSound.volume = PlayerPrefs.GetFloat("sfx");
                    hornSound.Play();
                }
            }

            // Handbrake toggle
            if (Input.GetKeyDown(KeyCode.Space))
            {
                if (forceHandbrake)
                {
                    handbrake = true;
                }
                else
                {
                    handbrake = !handbrake;

                    // Pick a random sound from the list, set its volume, and play it
                    AudioSource handbrakeSound = handbrakeSounds [Random.Range(0, handbrakeSounds.Count)];
                    handbrakeSound.volume = PlayerPrefs.GetFloat("sfx", 0.5f);
                    handbrakeSound.Play();

                    // Handbrake toggle
                    if (handbrake)
                    {
                        leftWheel.brakeTorque  = 400f;
                        rightWheel.brakeTorque = 400f;
                        noticesManager.ShowNotice(handbrakeSprite, "Handbrake Active");
                    }
                    else
                    {
                        leftWheel.brakeTorque  = 0f;
                        rightWheel.brakeTorque = 0f;
                        noticesManager.RemoveNotice("Handbrake Active");
                    }
                }
            }

            drivingSound.volume = PlayerPrefs.GetFloat("sfx", 0.5f);
        }
        else
        {
            drivingSound.volume = 0f;
        }

        // Prevent the car getting stuck
        if ((Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) && !handbrake && rb.velocity.magnitude < 1f)
        {
            StartCoroutine("ResetCar");
        }
        else if (rb.velocity.magnitude > 1f)
        {
            StopCoroutine("ResetCar");
        }

        drivingSound.pitch = 1f + (GetComponent <Rigidbody> ().velocity.magnitude * 0.025f);
    }