Universally challenged added
This commit is contained in:
71
Assets/Quiz/Scripts/UC/PlayerSeat.cs
Normal file
71
Assets/Quiz/Scripts/UC/PlayerSeat.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
using System;
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.UdonNetworkCalling;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon;
|
||||
|
||||
public class PlayerSeat : UdonSharpBehaviour
|
||||
{
|
||||
public TMPro.TextMeshProUGUI seatLabel;
|
||||
public TMPro.TMP_Dropdown playerDropdown;
|
||||
public string[] dropdownOptions;
|
||||
public string deskTeam;
|
||||
public AudioSource audioSource;
|
||||
[UdonSynced] public string seatPlayerName;
|
||||
public AudioClip[] announcerSounds;
|
||||
public AudioClip buzzerSound;
|
||||
public float announcerDelay = 0.8f;
|
||||
|
||||
public void OnDropdownChanged()
|
||||
{
|
||||
int selectedIndex = playerDropdown.value;
|
||||
|
||||
|
||||
seatPlayerName = dropdownOptions[selectedIndex];
|
||||
|
||||
SetSeatLabel();
|
||||
RequestSerialization();
|
||||
}
|
||||
|
||||
public override void OnDeserialization()
|
||||
{
|
||||
SetSeatLabel();
|
||||
}
|
||||
|
||||
public void SetSeatLabel()
|
||||
{
|
||||
seatLabel.text = seatPlayerName;
|
||||
}
|
||||
[NetworkCallable]
|
||||
public void PlayBuzzerSound()
|
||||
{
|
||||
if (audioSource != null && buzzerSound != null)
|
||||
{
|
||||
audioSource.PlayOneShot(buzzerSound);
|
||||
SendCustomEventDelayedSeconds(nameof(PlayAnnouncerSound), announcerDelay);
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayAnnouncerSound()
|
||||
{
|
||||
string requiredName = deskTeam + "_" + seatPlayerName;
|
||||
AudioClip announcerSound = null;
|
||||
|
||||
for (int i = 0; i < announcerSounds.Length; i++)
|
||||
{
|
||||
AudioClip clip = announcerSounds[i];
|
||||
if (clip != null && clip.name == requiredName)
|
||||
{
|
||||
announcerSound = clip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (audioSource != null && announcerSound != null)
|
||||
{
|
||||
audioSource.PlayOneShot(announcerSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user