Support for multiple questions is implemented, after many stupid problems.

This commit is contained in:
Jamie Greunbaum
2025-05-31 22:01:04 -04:00
parent e042d089a5
commit 80dc94a696
19 changed files with 1057 additions and 733 deletions
+40 -39
View File
@@ -1,4 +1,5 @@
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using TMPro;
using UdonSharp;
using UnityEngine;
@@ -24,29 +25,20 @@ public class ChoiceCardGroup : UdonSharpBehaviour
void Start()
{
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
Debug.Assert(Player != null);
for (int i = 0; i < _ChoiceCards.Length; i++)
{
ChoiceCard Card = _ChoiceCards[i];
Card.SetCardGroup(this);
bool IsInVR = Player.IsUserInVR();
Card.DisableInteractive = IsInVR;
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
if (Pickup != null)
{
Pickup.pickupable = IsInVR;
}
}
}
[NetworkCallable]
public void ChoiceCardPickedUp(int ChoiceNumber)
{
_SelectedChoice = ChoiceNumber;
Debug.LogError("[[DEBUG]] Choice number is " + ChoiceNumber + "; selected choice is now " + _SelectedChoice);
}
[NetworkCallable]
@@ -60,8 +52,6 @@ public class ChoiceCardGroup : UdonSharpBehaviour
_SelectedChoice = ChoiceNumber;
Debug.LogWarning("[[DEBUG]] Selected choice is " + _SelectedChoice);
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
Debug.Assert(Player != null);
@@ -69,8 +59,6 @@ public class ChoiceCardGroup : UdonSharpBehaviour
{
ChoiceCard Card = _ChoiceCards[i];
Debug.LogWarning("[[DEBUG]] Card choice for index " + i + " is " + Card.ChoiceNumber);
_PCCardAnimator.SetBool("Turn Forward", false);
if (Card.ChoiceNumber == _SelectedChoice)
@@ -121,40 +109,53 @@ public class ChoiceCardGroup : UdonSharpBehaviour
}
public void SetChoices(string Choice1, string Choice2, string Choice3)
public void SetChoices(string[] Choices, int[] Indices)
{
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
float RandomSeed = (Player.GetPosition().x * 100) + (Player.GetPosition().z * 1000);
Random.InitState((int)RandomSeed);
_ChoiceCards[Indices[0]].ChoiceNumber = 1;
_ChoiceCardText[Indices[0]].text = Choices[0];
_ChoiceCards[Indices[1]].ChoiceNumber = 2;
_ChoiceCardText[Indices[1]].text = Choices[1];
_ChoiceCards[Indices[2]].ChoiceNumber = 3;
_ChoiceCardText[Indices[2]].text = Choices[2];
}
int[] ChoiceIndices = { 0, 1, 2 };
int Choice1Index = ChoiceIndices[Random.Range(0, 3)];
_ChoiceCards[Choice1Index].ChoiceNumber = 1;
_ChoiceCardText[Choice1Index].text = Choice1;
ChoiceIndices[Choice1Index] = -1;
int Choice2Index = -1;
while(Choice2Index == -1) { Choice2Index = ChoiceIndices[Random.Range(0, 3)]; }
_ChoiceCards[Choice2Index].ChoiceNumber = 2;
_ChoiceCardText[Choice2Index].text = Choice2;
ChoiceIndices[Choice2Index] = -1;
int Choice3Index = -1;
while (Choice3Index == -1) { Choice3Index = ChoiceIndices[Random.Range(0, 3)]; }
_ChoiceCards[Choice3Index].ChoiceNumber = 3;
_ChoiceCardText[Choice3Index].text = Choice3;
ChoiceIndices[Choice3Index] = -1;
public void LockInChoice()
{
for (int i = 0; i < _ChoiceCards.Length; i++)
{
ChoiceCard Card = _ChoiceCards[i];
if (Card.ChoiceNumber == _SelectedChoice) { continue; }
Card.DisableInteractive = true;
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
if (Pickup != null) { Pickup.pickupable = false; }
}
}
public void ResetCards()
{
_SelectedChoice = -1;
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
Debug.Assert(Player != null);
bool IsInVR = Player.IsUserInVR();
for (int i = 0; i < _ChoiceCards.Length; i++)
{
_ChoiceCards[i].ResetPosition();
ChoiceCard Card = _ChoiceCards[i];
Card.ResetPosition();
_ChoiceCardText[i].text = "";
Card.DisableInteractive = IsInVR;
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
if (Pickup != null)
{
Pickup.pickupable = IsInVR;
}
}
}
}
+268 -286
View File
@@ -50,19 +50,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _AdminPanel
Data: BuzzInAllowed
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _AdminPanel
Data: BuzzInAllowed
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.GameObject, UnityEngine.CoreModule
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
@@ -73,14 +73,14 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
@@ -89,7 +89,7 @@ MonoBehaviour:
Data: 1
- Name:
Entry: 7
Data: 5|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 5|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -110,19 +110,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: BuzzInAllowed
Data: PlayerBuzzInAllowed
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: BuzzInAllowed
Data: PlayerBuzzInAllowed
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
Data: System.Boolean[], mscorlib
- Name:
Entry: 8
Data:
@@ -170,19 +170,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: PlayerBuzzInAllowed
Data: _BuzzedInPlayer
- Name: $v
Entry: 7
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: PlayerBuzzInAllowed
Data: _BuzzedInPlayer
- Name: <UserType>k__BackingField
Entry: 7
Data: 11|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean[], mscorlib
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
@@ -230,19 +230,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _BuzzedInPlayer
Data: _QuestionsList
- Name: $v
Entry: 7
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _BuzzedInPlayer
Data: _QuestionsList
- Name: <UserType>k__BackingField
Entry: 7
Data: 15|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
Data: VRC.SDK3.Data.DataList, VRCSDK3
- Name:
Entry: 8
Data:
@@ -252,66 +252,6 @@ MonoBehaviour:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 17|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _CurrentQuestion
- Name: $v
Entry: 7
Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CurrentQuestion
- Name: <UserType>k__BackingField
Entry: 7
Data: 19|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataDictionary, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 19
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
@@ -323,7 +263,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -344,25 +284,121 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _CurrentQuestionType
Data: _QuestionIndex
- Name: $v
Entry: 7
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CurrentQuestionType
Data: _QuestionIndex
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _CurrentQuestion
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CurrentQuestion
- Name: <UserType>k__BackingField
Entry: 7
Data: 22|System.RuntimeType, mscorlib
Data: 20|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: QuestionType, Assembly-CSharp
Data: VRC.SDK3.Data.DataDictionary, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 15
Data: 20
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _QuestionStage
- Name: $v
Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _QuestionStage
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -404,19 +440,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _CurrentQuestionStage
Data: _QuestionCorrectResponse
- Name: $v
Entry: 7
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CurrentQuestionStage
Data: _QuestionCorrectResponse
- Name: <UserType>k__BackingField
Entry: 9
Data: 15
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 15
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -458,70 +494,16 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _CurrentQuestionCorrectResponse
Data: PlayerPodiums
- Name: $v
Entry: 7
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CurrentQuestionCorrectResponse
- Name: <UserType>k__BackingField
Entry: 9
Data: 15
- Name: <SystemType>k__BackingField
Entry: 9
Data: 15
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 30|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: PlayerPodiums
- Name: $v
Entry: 7
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: PlayerPodiums
- Name: <UserType>k__BackingField
Entry: 7
Data: 32|System.RuntimeType, mscorlib
Data: 29|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: PlayerPodium[], Assembly-CSharp
@@ -530,7 +512,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 33|System.RuntimeType, mscorlib
Data: 30|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Component[], UnityEngine.CoreModule
@@ -551,7 +533,7 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 34|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 31|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -575,13 +557,13 @@ MonoBehaviour:
Data: QuestionURL
- Name: $v
Entry: 7
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 32|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: QuestionURL
- Name: <UserType>k__BackingField
Entry: 7
Data: 36|System.RuntimeType, mscorlib
Data: 33|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDKBase.VRCUrl, VRCSDKBase
@@ -590,7 +572,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 36
Data: 33
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -605,13 +587,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 37|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 34|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 38|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 35|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -635,13 +617,13 @@ MonoBehaviour:
Data: _InfoHeader
- Name: $v
Entry: 7
Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _InfoHeader
- Name: <UserType>k__BackingField
Entry: 7
Data: 40|System.RuntimeType, mscorlib
Data: 37|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TMPro.TextMeshProUGUI, Unity.TextMeshPro
@@ -650,7 +632,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 40
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -665,13 +647,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 41|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 38|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 42|UnityEngine.HeaderAttribute, UnityEngine.CoreModule
Data: 39|UnityEngine.HeaderAttribute, UnityEngine.CoreModule
- Name: header
Entry: 1
Data: Multiple Choice Card UI
@@ -680,7 +662,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 7
Data: 43|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 40|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -704,13 +686,13 @@ MonoBehaviour:
Data: _InfoClues
- Name: $v
Entry: 7
Data: 44|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 41|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _InfoClues
- Name: <UserType>k__BackingField
Entry: 7
Data: 45|System.RuntimeType, mscorlib
Data: 42|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TMPro.TextMeshProUGUI[], Unity.TextMeshPro
@@ -719,7 +701,61 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 45
Data: 42
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 43|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 44|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _InfoChoices
- Name: $v
Entry: 7
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _InfoChoices
- Name: <UserType>k__BackingField
Entry: 9
Data: 42
- Name: <SystemType>k__BackingField
Entry: 9
Data: 42
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -761,19 +797,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _InfoChoices
Data: _InfoChoiceButtons
- Name: $v
Entry: 7
Data: 48|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _InfoChoices
Data: _InfoChoiceButtons
- Name: <UserType>k__BackingField
Entry: 9
Data: 45
Entry: 7
Data: 49|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.UI.Image[], UnityEngine.UI
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 45
Data: 49
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -788,13 +830,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 49|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 50|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 50|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 51|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -815,25 +857,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _InfoChoiceButtons
Data: _Answer
- Name: $v
Entry: 7
Data: 51|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 52|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _InfoChoiceButtons
Data: _Answer
- Name: <UserType>k__BackingField
Entry: 7
Data: 52|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.UI.Image[], UnityEngine.UI
- Name:
Entry: 8
Data:
Entry: 9
Data: 37
- Name: <SystemType>k__BackingField
Entry: 9
Data: 52
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -875,19 +911,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _Answer
Data: BuzzerSound
- Name: $v
Entry: 7
Data: 55|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Answer
Data: BuzzerSound
- Name: <UserType>k__BackingField
Entry: 9
Data: 40
Entry: 7
Data: 56|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.AudioClip, UnityEngine.AudioModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 40
Data: 56
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -902,13 +944,22 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 56|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 57|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
Data: 2
- Name:
Entry: 7
Data: 57|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 58|UnityEngine.HeaderAttribute, UnityEngine.CoreModule
- Name: header
Entry: 1
Data: Audio
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 59|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -929,25 +980,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: BuzzerSound
Data: WhereInTheWorld
- Name: $v
Entry: 7
Data: 58|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 60|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: BuzzerSound
Data: WhereInTheWorld
- Name: <UserType>k__BackingField
Entry: 7
Data: 59|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.AudioClip, UnityEngine.AudioModule
- Name:
Entry: 8
Data:
Entry: 9
Data: 56
- Name: <SystemType>k__BackingField
Entry: 9
Data: 59
Data: 56
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -962,19 +1007,10 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 60|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 61|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 61|UnityEngine.HeaderAttribute, UnityEngine.CoreModule
- Name: header
Entry: 1
Data: Audio
- Name:
Entry: 8
Data:
Data: 1
- Name:
Entry: 7
Data: 62|UnityEngine.SerializeField, UnityEngine.CoreModule
@@ -998,19 +1034,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: WhereInTheWorld
Data: RockapellaIdent
- Name: $v
Entry: 7
Data: 63|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: WhereInTheWorld
Data: RockapellaIdent
- Name: <UserType>k__BackingField
Entry: 9
Data: 59
Data: 56
- Name: <SystemType>k__BackingField
Entry: 9
Data: 59
Data: 56
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1052,19 +1088,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: RockapellaIdent
Data: MusicPlayer
- Name: $v
Entry: 7
Data: 66|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: RockapellaIdent
Data: MusicPlayer
- Name: <UserType>k__BackingField
Entry: 9
Data: 59
Entry: 7
Data: 67|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.AudioSource, UnityEngine.AudioModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 59
Data: 67
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1079,13 +1121,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 67|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 68|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 68|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 69|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -1106,25 +1148,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: MusicPlayer
Data: SFXPlayer
- Name: $v
Entry: 7
Data: 69|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 70|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: MusicPlayer
Data: SFXPlayer
- Name: <UserType>k__BackingField
Entry: 7
Data: 70|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.AudioSource, UnityEngine.AudioModule
- Name:
Entry: 8
Data:
Entry: 9
Data: 67
- Name: <SystemType>k__BackingField
Entry: 9
Data: 70
Data: 67
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1161,60 +1197,6 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: SFXPlayer
- Name: $v
Entry: 7
Data: 73|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: SFXPlayer
- Name: <UserType>k__BackingField
Entry: 9
Data: 70
- Name: <SystemType>k__BackingField
Entry: 9
Data: 70
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 74|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 75|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
+158 -55
View File
@@ -6,10 +6,10 @@ using VRC.SDK3.Data;
using VRC.SDK3.UdonNetworkCalling;
using VRC.Udon.Common.Interfaces;
using VRC.SDKBase;
using System.Linq;
using VRC.SDK3.StringLoading;
using System.Runtime.CompilerServices;
using TMPro;
using VRC.SDK3.Components;
using HarmonyLib;
public enum QuestionType
@@ -17,6 +17,7 @@ public enum QuestionType
None,
MultipleChoice,
LightningRound,
DumpsterDive,
TheChase,
FinalRound,
Tiebreaker
@@ -39,16 +40,15 @@ public enum SFXEventType
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class GameManager : UdonSharpBehaviour
{
[SerializeField] private GameObject _AdminPanel;
[UdonSynced] private bool BuzzInAllowed = false;
[UdonSynced] private bool[] PlayerBuzzInAllowed;
[UdonSynced] private int _BuzzedInPlayer = -1;
[UdonSynced] private int _BuzzedInPlayer = 0;
private DataList _QuestionsList = new DataList();
private int _QuestionIndex = 0;
private DataDictionary _CurrentQuestion;
[UdonSynced] private QuestionType _CurrentQuestionType = QuestionType.MultipleChoice;
[UdonSynced] private int _CurrentQuestionStage = 0;
[UdonSynced] private int _CurrentQuestionCorrectResponse = -1;
[UdonSynced] private int _QuestionStage = 0;
[UdonSynced] private int _QuestionCorrectResponse = 0;
public PlayerPodium[] PlayerPodiums;
@@ -84,82 +84,176 @@ public class GameManager : UdonSharpBehaviour
string JSONString = DownloadedString.Result;
if (VRCJson.TryDeserializeFromJson(JSONString, out DataToken JSONResult))
{
if (JSONResult.TokenType == TokenType.DataDictionary)
if (JSONResult.TokenType == TokenType.DataList)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)this, NetworkEventTarget.All, nameof(UpdateInfoCard), JSONString);
_QuestionsList.Clear();
_QuestionIndex = 0;
for (int i = 0; i < JSONResult.DataList.Count; i++)
{
if (JSONResult.DataList[i].TokenType == TokenType.DataDictionary)
{
_QuestionsList.Add(JSONResult.DataList[i]);
}
}
if (_QuestionsList.Count == 0)
{
Debug.LogError("Unable to find any questions. Ensure the root array elements are all objects.");
return;
}
_CurrentQuestion = _QuestionsList[0].DataDictionary;
Debug.Log("Found " + _QuestionsList.Count + " questions in this case file.");
}
}
else
{
Debug.LogError("The question should be a Dictionary type.");
}
}
[NetworkCallable]
public void UpdateInfoCard(string Data)
{
DisableChoiceCards();
if (VRCJson.TryDeserializeFromJson(Data, out DataToken ResultToken))
{
_CurrentQuestion = ResultToken.DataDictionary;
string Type = _CurrentQuestion["Type"].ToString();
if (Type == "Multiple Choice")
else
{
NewMultipleChoiceQuestion();
Debug.LogError("Malformed case file. Ensure the first element is an array of objects.");
}
}
}
private void NewMultipleChoiceQuestion()
{
_CurrentQuestionType = QuestionType.MultipleChoice;
_CurrentQuestionStage = 0;
_InfoHeader.text = _CurrentQuestion["Type"].Number.ToString();
_InfoHeader.text = _CurrentQuestion["Type"].ToString();
_InfoClues[0].text = _CurrentQuestion["Clues"].DataList[0].ToString();
_InfoClues[1].text = _CurrentQuestion["Clues"].DataList[1].ToString();
_InfoClues[2].text = _CurrentQuestion["Clues"].DataList[2].ToString();
DataList ClueStrings = _CurrentQuestion["Clues"].DataList;
for (int i = 0; i < _InfoClues.Length && i < ClueStrings.Count; i++)
{
_InfoClues[i].text = ClueStrings[i].ToString();
}
DataList Choices = _CurrentQuestion["Choices"].DataList;
_InfoChoices[0].text = Choices[0].ToString();
_InfoChoices[1].text = Choices[1].ToString();
_InfoChoices[2].text = Choices[2].ToString();
_CurrentQuestionCorrectResponse = (int)_CurrentQuestion["Correct Response"].Double;
_Answer.text = Choices[_CurrentQuestionCorrectResponse].ToString();
_QuestionCorrectResponse = (int)_CurrentQuestion["Correct Response"].Number;
_Answer.text = Choices[_QuestionCorrectResponse].ToString();
}
private void MultipleChoiceRevealChoices()
{
Debug.LogError("Advancing the current question stage now.");
SendCustomEvent(nameof(MultipleChoiceRevealChoice1));
SendCustomEventDelayedSeconds(nameof(MultipleChoiceRevealChoice2), 1.25f);
SendCustomEventDelayedSeconds(nameof(MultipleChoiceRevealChoice3), 2.5f);
}
public void MultipleChoiceRevealChoice1()
{
_InfoChoiceButtons[0].color = (_CurrentQuestionCorrectResponse == 0) ? Color.green : Color.red;
_InfoChoiceButtons[0].color = (_QuestionCorrectResponse == 1) ? Color.green : Color.red;
}
public void MultipleChoiceRevealChoice2()
{
_InfoChoiceButtons[1].color = (_CurrentQuestionCorrectResponse == 1) ? Color.green : Color.red;
_InfoChoiceButtons[1].color = (_QuestionCorrectResponse == 2) ? Color.green : Color.red;
}
public void MultipleChoiceRevealChoice3()
{
_InfoChoiceButtons[2].color = (_CurrentQuestionCorrectResponse == 2) ? Color.green : Color.red;
_InfoChoiceButtons[2].color = (_QuestionCorrectResponse == 3) ? Color.green : Color.red;
DataList Choices = _CurrentQuestion["Choices"].DataList;
EnableChoiceCards();
for (int i = 0; i < PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)PlayerPodiums[i], NetworkEventTarget.Owner, "SetCardChoices", Choices[0].ToString(), Choices[1].ToString(), Choices[2].ToString());
int[] Indices = { 0, 1, 2 };
int[] ChoiceOrder = { -1, -1, -1 };
int Choice1Index = Indices[Random.Range(0, 3)];
ChoiceOrder[0] = Choice1Index;
Indices[Choice1Index] = -1;
int Choice2Index = -1;
while (Choice2Index == -1) { Choice2Index = Indices[Random.Range(0, 3)]; }
ChoiceOrder[1] = Choice2Index;
Indices[Choice2Index] = -1;
int Choice3Index = -1;
while (Choice3Index == -1) { Choice3Index = Indices[Random.Range(0, 3)]; }
ChoiceOrder[2] = Choice3Index;
Indices[Choice3Index] = -1;
string[] ChoiceStrings = { Choices[0].ToString(), Choices[1].ToString(), Choices[2].ToString() };
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)PlayerPodiums[i], NetworkEventTarget.All, "SetCardChoices", ChoiceStrings, ChoiceOrder);
}
DisableInteractive = false;
}
private void MultipleChoiceLockAnswers()
{
for (int i = 0; i < PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)PlayerPodiums[i], NetworkEventTarget.All, "LockInChoice");
}
_InfoHeader.text = "LOCKED IN";
for (int i = 0; i < _InfoClues.Length; i++)
{
_InfoClues[i].text = "";
}
for (int i = 0; i < _InfoChoices.Length; i++)
{
if (i != (_QuestionCorrectResponse - 1))
{
_InfoChoices[i].text = "";
}
}
DisableInteractive = false;
}
private void MultipleChoiceConfirmAnswers()
{
_InfoHeader.text = "ANSWER REVEALED";
for (int i = 0; i < PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)PlayerPodiums[i], NetworkEventTarget.All, "VerifyResponse", _QuestionCorrectResponse);
}
DisableInteractive = false;
}
public void EnableChoiceCards()
private void AdvanceToNextQuestion()
{
DisableChoiceCards();
_QuestionIndex++;
if (_QuestionIndex >= _QuestionsList.Count)
{
Debug.LogError("No more questions.");
return;
}
_CurrentQuestion = _QuestionsList[_QuestionIndex].DataDictionary;
_QuestionCorrectResponse = (int)_CurrentQuestion["Correct Response"].Number;
_QuestionStage = 0;
ResetInfoCard("Next Question");
}
private void ResetInfoCard(string Header = "")
{
_InfoHeader.text = Header;
for (int i = 0; i < _InfoClues.Length; i++)
{
_InfoClues[i].text = "";
}
_InfoChoiceButtons[0].color = Color.white;
_InfoChoiceButtons[1].color = Color.white;
_InfoChoiceButtons[2].color = Color.white;
_InfoChoices[0].text = "";
_InfoChoices[1].text = "";
_InfoChoices[2].text = "";
}
private void EnableChoiceCards()
{
for (int i = 0; i < PlayerPodiums.Length; i++)
{
@@ -167,7 +261,7 @@ public class GameManager : UdonSharpBehaviour
}
}
public void DisableChoiceCards()
private void DisableChoiceCards()
{
for (int i = 0; i < PlayerPodiums.Length; i++)
{
@@ -226,12 +320,18 @@ public class GameManager : UdonSharpBehaviour
}
private void AdvanceQuestionStage()
private void AdvanceQuestion()
{
_CurrentQuestionStage++;
switch(_CurrentQuestionType)
_QuestionStage++;
// TO-DO: Ask someone at either Microsoft or VRChat why the VM crashes if you cast an int
// to an enum in a switch parameter, but not if you cast an enum to an int in a case
// statement. I'm starting to wonder if either C# or U# are just fucking terrible
// languages. C++ figured this problem out in at least 1985, and it turns out the proper
// solution was "it's not a problem, it's just two numbers, they're the same".
switch (_CurrentQuestion["Type"].Number)
{
case QuestionType.MultipleChoice:
case (int)QuestionType.MultipleChoice:
AdvanceMultipleChoiceStage();
break;
}
@@ -241,13 +341,14 @@ public class GameManager : UdonSharpBehaviour
private void AdvanceMultipleChoiceStage()
{
switch(_CurrentQuestionStage)
switch(_QuestionStage)
{
case 1:
MultipleChoiceRevealChoices();
break;
default:
return;
case 1: NewMultipleChoiceQuestion(); break;
case 2: MultipleChoiceRevealChoices(); break;
case 3: MultipleChoiceLockAnswers(); break;
case 4: MultipleChoiceConfirmAnswers(); break;
case 5: AdvanceToNextQuestion(); break;
default: return;
}
}
@@ -287,7 +388,9 @@ public class GameManager : UdonSharpBehaviour
public override void OnPickupUseDown()
{
AdvanceQuestionStage();
if (DisableInteractive) { return; }
AdvanceQuestion();
base.OnPickupUseDown();
}
+19 -2
View File
@@ -4,6 +4,7 @@ using VRC.SDKBase;
using VRC.SDK3.UdonNetworkCalling;
using TMPro;
using UnityEngine;
using VRC.SDK3.Components;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class PlayerPodium : UdonSharpBehaviour
@@ -24,6 +25,7 @@ public class PlayerPodium : UdonSharpBehaviour
[SerializeField] private TextMeshProUGUI _Nameplate;
[SerializeField] private TextMeshProUGUI _Scorecard;
void Start()
{
PlayerName = "Player " + PlayerNumber;
@@ -67,9 +69,24 @@ public class PlayerPodium : UdonSharpBehaviour
}
[NetworkCallable]
public void SetCardChoices(string Choice1, string Choice2, string Choice3)
public void SetCardChoices(string[] Choices, int[] Indices)
{
_ChoiceCards.SetChoices(Choice1, Choice2, Choice3);
_ChoiceCards.SetChoices(Choices, Indices);
}
[NetworkCallable]
public void LockInChoice()
{
_ChoiceCards.LockInChoice();
}
[NetworkCallable]
public void VerifyResponse(int CorrectResponse)
{
if (_ChoiceCards.GetSelectedChoice() == CorrectResponse)
{
IncreaseScoreBy10();
}
}