Пример #1
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));
    }
Пример #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Pickup")
        {
            pickup       = other.gameObject;
            pickupScript = other.GetComponent <Pickup> ();

            if (!pickupScript.Activated)
            {
                pickupScript.Activated = true;
                noticesManager.RemoveNotice("A pickup has spawned!");
                noticesManager.RemoveNotice(pickupType + " pickup collected!");

                if (pickupScript.type == Pickup.PickupTypes.Time)
                {
                    // Time
                    gameTime.IncreaseTime(Random.Range(10, 20));
                    pickupType = "Time";
                }
                if (pickupScript.type == Pickup.PickupTypes.Multiplier)
                {
                    // Multiplier
                    StartCoroutine(NewMultiplier());
                    pickupType = "Multiplier";
                }
                if (pickupScript.type == Pickup.PickupTypes.Patience)
                {
                    // Multiplier
                    jobManager.TimeTaken -= Random.Range(15, 25);
                    pickupType            = "Patience";
                }

                pickupSound.volume = PlayerPrefs.GetFloat("sfx", 0.5f);
                pickupSound.Play();

                StartCoroutine(ShowNotice());
                Destroy(pickup.transform.parent.gameObject);
            }
        }
    }
Пример #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);
    }