Add PickedUp to casette

This commit is contained in:
Jens Pitkänen 2020-04-21 03:01:37 +03:00
parent f550b2838a
commit b5bd863822
1 changed files with 5 additions and 4 deletions

View File

@ -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<AudioSource>();
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 {