// Update is called once per frame void Update() { // If player drinks, reset the counters if (hasdrunk) { StopCoroutine(thirstCoroutine); thirstCoroutine = ThirstTimer(); StartCoroutine(thirstCoroutine); hasdrunk = false; musicPicker.stressed--; if (musicPicker.stressed == 0) { leftCamera.enabled = false; rightCamera.enabled = false; musicPicker.StopClip(); } } // If player eats, reset the counters if (haseaten) { StopCoroutine(hungerCoroutine); hungerCoroutine = HungerTimer(); StartCoroutine(hungerCoroutine); haseaten = false; musicPicker.stressed--; if (musicPicker.stressed == 0) { leftCamera.enabled = false; rightCamera.enabled = false; musicPicker.StopClip(); } } }
IEnumerator PlaySuccessAndDestroy(GameObject item) { MusicPicker musicPicker = FindObjectOfType <MusicPicker> (); AudioClip successClip = musicPicker.successClip; musicPicker.PlayClip(successClip); inventory.reticleOnObject = false; yield return(new WaitForSeconds(successClip.length - 0.1f)); musicPicker.StopClip(); item.SetActive(true); Destroy(gameObject); }