TO SQUASH: Added background.

This commit is contained in:
2026-07-25 20:42:09 -04:00
parent c7bc76ce98
commit 433bbd88e0
63 changed files with 1740 additions and 73 deletions
+50
View File
@@ -0,0 +1,50 @@
using UnityEngine;
using System.Collections.Generic;
public class MusicManager : MonoBehaviour
{
public AudioClip intro;
public AudioClip loop;
public AudioClip outro;
private AudioSource audioSource;
private Queue<AudioClip> clipsQueue;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
audioSource = GetComponent<AudioSource>();
clipsQueue = new Queue<AudioClip>();
// Intro is only played once, so we enqueue it first.
clipsQueue.Enqueue(intro);
ResetQueue();
}
// Update is called once per frame
void FixedUpdate()
{
if (audioSource.isPlaying == false)
{
audioSource.clip = clipsQueue.Dequeue();
audioSource.Play();
if(clipsQueue.Count == 0)
{
ResetQueue();
}
}
}
private void ResetQueue()
{
clipsQueue.Enqueue(loop);
clipsQueue.Enqueue(loop);
clipsQueue.Enqueue(loop);
clipsQueue.Enqueue(loop);
clipsQueue.Enqueue(outro);
}
}