88 lines
2.1 KiB
C#
88 lines
2.1 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Data;
|
|
using VRC.SDK3.UdonNetworkCalling;
|
|
using VRC.Udon.Common.Interfaces;
|
|
using VRC.SDKBase;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class GameManagerRound2 : GameManagerBase
|
|
{
|
|
protected override void InitialiseGameMode()
|
|
{
|
|
|
|
|
|
base.InitialiseGameMode();
|
|
}
|
|
|
|
|
|
protected override void LoadQuestionData(DataList Data)
|
|
{
|
|
_QuestionsList.Clear();
|
|
_QuestionIndex = 0;
|
|
|
|
HostCardBetweenRoundsInterface Interface =
|
|
(HostCardBetweenRoundsInterface)GetHostCardInterface(QuestionType.BetweenRounds);
|
|
|
|
for (int i = 0; i < Data.Count; i++)
|
|
{
|
|
if (Data[i].TokenType == TokenType.DataDictionary)
|
|
{
|
|
_QuestionsList.Add(Data[i]);
|
|
}
|
|
}
|
|
|
|
if (_QuestionsList.Count == 0)
|
|
{
|
|
Interface.HeaderUI.text =
|
|
"Unable to find any questions. Ensure the root array elements are all objects.";
|
|
return;
|
|
}
|
|
|
|
_CurrentQuestion = _QuestionsList[_QuestionIndex].DataDictionary;
|
|
|
|
Interface.HeaderUI.text =
|
|
"Found " + _QuestionsList.Count + " questions in this case file. Press 'Use' button to show scores.";
|
|
|
|
// Reset podiums on a successful case load
|
|
for (int i = 0; i < _PlayerPodiums.Length; i++)
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent(
|
|
(IUdonEventReceiver)_PlayerPodiums[i],
|
|
NetworkEventTarget.All,
|
|
"ResetPodium");
|
|
}
|
|
|
|
_GameHasBegun = false;
|
|
EnableInteraction("Start Game");
|
|
}
|
|
|
|
|
|
protected override void _HostCardUseButtonDown_Internal()
|
|
{
|
|
if (!_GameHasBegun)
|
|
{
|
|
for (int i = 0; i < _PlayerPodiums.Length; i++)
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent(
|
|
(IUdonEventReceiver)_PlayerPodiums[i],
|
|
NetworkEventTarget.All,
|
|
"DisplayScore");
|
|
}
|
|
|
|
SendCustomNetworkEvent(NetworkEventTarget.All, nameof(PlaySFXAtPitch), SFXEventType.Ding, D6);
|
|
|
|
HostCardBetweenRoundsInterface Interface =
|
|
(HostCardBetweenRoundsInterface)GetHostCardInterface(QuestionType.BetweenRounds);
|
|
Interface.HeaderUI.text = "Upcoming Question: " + QuestionTypeToString((QuestionType)((int)_CurrentQuestion["Type"].Number));
|
|
|
|
_GameHasBegun = true;
|
|
return;
|
|
}
|
|
|
|
AdvanceQuestion();
|
|
}
|
|
}
|