228 lines
6.8 KiB
C#
228 lines
6.8 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Data;
|
|
using VRC.SDK3.UdonNetworkCalling;
|
|
using VRC.Udon.Common.Interfaces;
|
|
using VRC.SDKBase;
|
|
|
|
|
|
public enum PanelType
|
|
{
|
|
Empty,
|
|
Loot,
|
|
Warrant,
|
|
Crook
|
|
}
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class GameManagerRound2 : GameManagerBase
|
|
{
|
|
[SerializeField] private LocationBoard _LocationBoard;
|
|
|
|
protected override void InitialiseGameMode()
|
|
{
|
|
base.InitialiseGameMode();
|
|
}
|
|
|
|
|
|
public override void LoadQuestionData(DataToken Data)
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
|
|
DataDictionary DataDict = Data.DataDictionary;
|
|
|
|
if (DataDict.ContainsKey("Location") && DataDict.ContainsKey("Landmarks"))
|
|
{
|
|
if (DataDict["Landmarks"].TokenType == TokenType.DataList && DataDict["Landmarks"].DataList.Count >= 15)
|
|
{
|
|
DataList Landmarks = DataDict["Landmarks"].DataList;
|
|
for (int i = 0; i < Landmarks.Count; i++)
|
|
{
|
|
if (Landmarks[i].TokenType == TokenType.DataDictionary)
|
|
{
|
|
DataDictionary LandmarkEntry = Landmarks[i].DataDictionary;
|
|
if (LandmarkEntry.ContainsKey("Landmark"))
|
|
{
|
|
string LandmarkName = LandmarkEntry["Landmark"].ToString();
|
|
_LocationBoard.LocationPanelText[i].text = LandmarkName;
|
|
Interface.AddLandmarkName(i, LandmarkName);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("Malformed landmark entry. Ensure the 'Landmark' key exists.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("Malformed landmark entry. Ensure each landmark is a dictionary containing a 'Landmark' key.");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("Malformed landmark data. Ensure there is a list of at least 15 landmarks.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("Malformed round data. Ensure Round 2 contains 'Location' and 'Landmark' keys.");
|
|
}
|
|
|
|
//_GameHasBegun = false;
|
|
//EnableInteraction("Start Game");
|
|
}
|
|
|
|
|
|
public void OnTheRightTrack()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
Interface.SetComment("On the right track.", Color.green);
|
|
}
|
|
|
|
public void AlmostThere()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
Interface.SetComment("Almost got it...", Color.yellow);
|
|
}
|
|
|
|
public void OutOfOrder(PanelType Type)
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
Interface.SetComment("Found " + PanelTypeToString(Type) + ". Remember the order: loot, warrant, crook. Use some strategy.", Color.yellow);
|
|
}
|
|
|
|
// All of these next functions are the end of a turn, and should disable
|
|
// all inputs to prevent messing up the game state.
|
|
public void NothingThere()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
Interface.SetComment("Nothing there.", Color.black);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
}
|
|
|
|
public void AlreadyTried()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
Interface.SetComment("Already tried that one.", Color.black);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
}
|
|
|
|
public void NiceStrategy()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
Interface.SetComment("Nice strategy.", Color.green);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
}
|
|
|
|
// This is for when the player wins the game. This should disable all
|
|
// inputs, and should also enable victory animations.
|
|
public void YoureWinner()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
Interface.SetComment("Winner! Congratulations, [[PLAYER]]", Color.red);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
}
|
|
|
|
|
|
public void LocationBoardReset()
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent(
|
|
(IUdonEventReceiver)_LocationBoard,
|
|
NetworkEventTarget.All,
|
|
"ResetPanelBoard");
|
|
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot);
|
|
|
|
Interface.EnableAllPanelButtons(true);
|
|
|
|
Interface.SetComment("[[PLAYER]], your turn.", Color.black);
|
|
}
|
|
|
|
|
|
protected override HostCardInterfaceBase GetHostCardInterface(QuestionType Question)
|
|
{
|
|
return _HostCard.EnableHostCardDisplay(GameType.RecoverTheLoot, Question);
|
|
}
|
|
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
public void Button_RevealPanel(int Panel)
|
|
{
|
|
((HostCardRecoverTheLootInterface)GetHostCardInterface(QuestionType.RecoverTheLoot))
|
|
.DisablePanelButton(Panel);
|
|
NetworkCalling.SendCustomNetworkEvent(
|
|
(IUdonEventReceiver)_LocationBoard,
|
|
NetworkEventTarget.All,
|
|
"RevealPanel", Panel);
|
|
}
|
|
|
|
public void Button_RevealPanel1() { Button_RevealPanel(1); }
|
|
public void Button_RevealPanel2() { Button_RevealPanel(2); }
|
|
public void Button_RevealPanel3() { Button_RevealPanel(3); }
|
|
public void Button_RevealPanel4() { Button_RevealPanel(4); }
|
|
public void Button_RevealPanel5() { Button_RevealPanel(5); }
|
|
public void Button_RevealPanel6() { Button_RevealPanel(6); }
|
|
public void Button_RevealPanel7() { Button_RevealPanel(7); }
|
|
public void Button_RevealPanel8() { Button_RevealPanel(8); }
|
|
public void Button_RevealPanel9() { Button_RevealPanel(9); }
|
|
public void Button_RevealPanel10() { Button_RevealPanel(10); }
|
|
public void Button_RevealPanel11() { Button_RevealPanel(11); }
|
|
public void Button_RevealPanel12() { Button_RevealPanel(12); }
|
|
public void Button_RevealPanel13() { Button_RevealPanel(13); }
|
|
public void Button_RevealPanel14() { Button_RevealPanel(14); }
|
|
public void Button_RevealPanel15() { Button_RevealPanel(15); }
|
|
|
|
|
|
private string PanelTypeToString(PanelType Type)
|
|
{
|
|
switch(Type)
|
|
{
|
|
case PanelType.Empty: return "Empty";
|
|
case PanelType.Loot: return "Loot";
|
|
case PanelType.Warrant: return "Warrant";
|
|
case PanelType.Crook: return "Crook";
|
|
default: return "[[ERROR]]";
|
|
}
|
|
}
|
|
}
|