114 lines
2.3 KiB
C#
114 lines
2.3 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Data;
|
|
using VRC.SDK3.StringLoading;
|
|
using VRC.SDK3.UdonNetworkCalling;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon.Common.Interfaces;
|
|
|
|
|
|
public enum QuestionType
|
|
{
|
|
BetweenRounds,
|
|
MultipleChoice,
|
|
LightningRound,
|
|
DumpsterDive,
|
|
TheChase,
|
|
FinalRound,
|
|
Tiebreaker
|
|
}
|
|
|
|
public enum MusicEventType
|
|
{
|
|
None,
|
|
TheChase,
|
|
ThinkAboutIt,
|
|
WhereInTheWorld,
|
|
RockapellaIdent
|
|
}
|
|
|
|
public enum SFXEventType
|
|
{
|
|
None,
|
|
Ding,
|
|
Buzzer
|
|
}
|
|
|
|
|
|
public class GameManagerBase : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] protected HostCardManager _HostCard = null;
|
|
|
|
[SerializeField] protected VRCUrl _QuestionURL;
|
|
|
|
private bool _AllowInteractionFromHostCard = false;
|
|
|
|
|
|
void Start()
|
|
{
|
|
InitialiseGameMode();
|
|
}
|
|
|
|
protected void EnableInteraction(string NextInteraction = "Advance")
|
|
{
|
|
_AllowInteractionFromHostCard = true;
|
|
_HostCard.SetNextInteractionText(NextInteraction);
|
|
}
|
|
protected void DisableInteraction()
|
|
{
|
|
_AllowInteractionFromHostCard = false;
|
|
}
|
|
|
|
public bool IsInteractionEnabled()
|
|
{
|
|
return _AllowInteractionFromHostCard;
|
|
}
|
|
|
|
public void HostCardUseButtonDown()
|
|
{
|
|
if (!IsInteractionEnabled()) { return; }
|
|
|
|
_HostCardUseButtonDown_Internal();
|
|
}
|
|
|
|
protected HostCardInterfaceBase GetHostCardInterface(QuestionType Type)
|
|
{
|
|
return _HostCard.EnableHostCardDisplay(Type);
|
|
}
|
|
|
|
protected virtual void _HostCardUseButtonDown_Internal()
|
|
{
|
|
Debug.LogError("You should not be seeing this. You don't need to call base._HostCardUseButtonDown_Internal()");
|
|
}
|
|
|
|
|
|
protected virtual void InitialiseGameMode()
|
|
{
|
|
// Download our test question.
|
|
VRCStringDownloader.LoadUrl(_QuestionURL, (IUdonEventReceiver)this);
|
|
}
|
|
|
|
|
|
public override void OnStringLoadSuccess(IVRCStringDownload DownloadedString)
|
|
{
|
|
string JSONString = DownloadedString.Result;
|
|
if (VRCJson.TryDeserializeFromJson(JSONString, out DataToken JSONResult))
|
|
{
|
|
if (JSONResult.TokenType == TokenType.DataList)
|
|
{
|
|
// For the moment, we're assuming that only Round 1 exists, so just pass
|
|
// the data over under that assumption. This will need to be fixed once
|
|
// we start expecting more game modes.
|
|
LoadQuestionData(JSONResult.DataList);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("Malformed case file. Ensure the first element is an array of objects.");
|
|
}
|
|
}
|
|
}
|
|
|
|
protected virtual void LoadQuestionData(DataList Data) {}
|
|
}
|