using System.Diagnostics; using UdonSharp; using UnityEngine; using VRC.SDKBase; using VRC.Udon; public enum MusicEvent { INTERNAL = -1, None, WhereInTheWorld, RockapellaIdent } [UdonBehaviourSyncMode(BehaviourSyncMode.Manual)] public class GameManager : UdonSharpBehaviour { private bool BuzzInAllowed = false; [Header("Player Data")] public PlayerPodium Player1Podium; public PlayerPodium Player2Podium; public PlayerPodium Player3Podium; [Header("Audio")] public AudioClip WhereInTheWorld = null; public AudioClip RockapellaIdent = null; private AudioSource AudioPlayer = null; [UdonSynced, FieldChangeCallback(nameof(SetMusicEvent))] private MusicEvent _MusicEvent = MusicEvent.None; void Start() { AudioPlayer = GetComponent(); } public void PlayerBuzzedIn(int PlayerID) { if (!BuzzInAllowed) { return; } BuzzInAllowed = false; } public void CancelBuzzIn() { BuzzInAllowed = true; } public void PlayWhereInTheWorld() { SetMusicEvent = MusicEvent.WhereInTheWorld; RequestSerialization(); } public void PlayRockapellaIdent() { SetMusicEvent = MusicEvent.RockapellaIdent; RequestSerialization(); } public MusicEvent SetMusicEvent { set { _MusicEvent = value; AudioPlayer.Stop(); switch(_MusicEvent) { case MusicEvent.WhereInTheWorld: AudioPlayer.clip = WhereInTheWorld; break; case MusicEvent.RockapellaIdent: AudioPlayer.clip = RockapellaIdent; break; default: break; } if (_MusicEvent != MusicEvent.None) AudioPlayer.Play(); } get => _MusicEvent; } }