using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace RhythmHeavenMania.Util { public class Jukebox { public enum AudioType { OGG, WAV } /// /// This is me just idiot-proofing. /// public static void BasicCheck() { if (FindJukebox() == null) { GameObject Jukebox = new GameObject("Jukebox"); Jukebox.AddComponent(); Jukebox.tag = "Jukebox"; } } public static GameObject FindJukebox() { if (GameObject.FindGameObjectWithTag("Jukebox") != null) return GameObject.FindGameObjectWithTag("Jukebox"); else return null; } public static void SetVolume(float volume) { BasicCheck(); FindJukebox().GetComponent().volume = volume; } public static void PlayOneShot(string name, bool relyOnBeat = true) { GameObject oneShot = new GameObject("oneShot"); AudioSource aus = oneShot.AddComponent(); aus.playOnAwake = false; Sound snd = oneShot.AddComponent(); snd.relyOnBeat = relyOnBeat; AudioClip clip = Resources.Load($"Sfx/{name}"); snd.clip = clip; // snd.pitch = (clip.length / Conductor.instance.secPerBeat); } public static void PlayOneShotGame(string name, bool relyOnBeat = true) { if (GameManager.instance.currentGame == name.Split('/')[0]) PlayOneShot($"games/{name}", relyOnBeat); } } }