Add PickedUp to casette
This commit is contained in:
parent
f550b2838a
commit
b5bd863822
@ -15,20 +15,19 @@ public class CasettePickup : MonoBehaviour {
|
|||||||
return Source.isPlaying;
|
return Source.isPlaying;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool PickedUp = false;
|
||||||
|
|
||||||
private AudioSource Source;
|
private AudioSource Source;
|
||||||
private CasettePickup PreviousInQueue;
|
private CasettePickup PreviousInQueue;
|
||||||
private int WaitingIndex;
|
private int WaitingIndex;
|
||||||
private bool Disappear;
|
|
||||||
|
|
||||||
private void Awake() {
|
private void Awake() {
|
||||||
Source = GetComponent<AudioSource>();
|
Source = GetComponent<AudioSource>();
|
||||||
CasetteProgress.CasetteCount = Clips.Length;
|
CasetteProgress.CasetteCount = Clips.Length;
|
||||||
Disappear = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update() {
|
private void Update() {
|
||||||
if (Disappear) {
|
if (PickedUp) {
|
||||||
transform.localScale = Vector3.Lerp(transform.localScale, Vector3.zero, 10f * Time.deltaTime);
|
transform.localScale = Vector3.Lerp(transform.localScale, Vector3.zero, 10f * Time.deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +35,8 @@ public class CasettePickup : MonoBehaviour {
|
|||||||
if (!PreviousInQueue.Playing) {
|
if (!PreviousInQueue.Playing) {
|
||||||
PreviousInQueue = null;
|
PreviousInQueue = null;
|
||||||
Source.PlayOneShot(Clips[WaitingIndex]);
|
Source.PlayOneShot(Clips[WaitingIndex]);
|
||||||
|
} else if (PreviousInQueue == null && !Source.isPlaying) {
|
||||||
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
} else if (CasetteProgress.AllCasettesPlayed && !Playing) {
|
} else if (CasetteProgress.AllCasettesPlayed && !Playing) {
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
@ -43,9 +44,9 @@ public class CasettePickup : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Play(CasettePickup previous) {
|
public void Play(CasettePickup previous) {
|
||||||
|
PickedUp = true;
|
||||||
int Index = CasetteProgress.PlayNext();
|
int Index = CasetteProgress.PlayNext();
|
||||||
if (Index != -1) {
|
if (Index != -1) {
|
||||||
Disappear = true;
|
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
Source.PlayOneShot(Clips[Index]);
|
Source.PlayOneShot(Clips[Index]);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user