diff --git a/Assets/Scripts/CasettePickup.cs b/Assets/Scripts/CasettePickup.cs index 56548df..b635a4c 100644 --- a/Assets/Scripts/CasettePickup.cs +++ b/Assets/Scripts/CasettePickup.cs @@ -15,20 +15,19 @@ public class CasettePickup : MonoBehaviour { return Source.isPlaying; } } + public bool PickedUp = false; private AudioSource Source; private CasettePickup PreviousInQueue; private int WaitingIndex; - private bool Disappear; private void Awake() { Source = GetComponent(); CasetteProgress.CasetteCount = Clips.Length; - Disappear = false; } private void Update() { - if (Disappear) { + if (PickedUp) { transform.localScale = Vector3.Lerp(transform.localScale, Vector3.zero, 10f * Time.deltaTime); } @@ -36,6 +35,8 @@ public class CasettePickup : MonoBehaviour { if (!PreviousInQueue.Playing) { PreviousInQueue = null; Source.PlayOneShot(Clips[WaitingIndex]); + } else if (PreviousInQueue == null && !Source.isPlaying) { + Destroy(gameObject); } } else if (CasetteProgress.AllCasettesPlayed && !Playing) { Destroy(gameObject); @@ -43,9 +44,9 @@ public class CasettePickup : MonoBehaviour { } public void Play(CasettePickup previous) { + PickedUp = true; int Index = CasetteProgress.PlayNext(); if (Index != -1) { - Disappear = true; if (previous == null) { Source.PlayOneShot(Clips[Index]); } else {