297 lines
8.3 KiB
C#
297 lines
8.3 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 CaseManager _CaseManager;
|
|
|
|
[SerializeField] private LocationBoard _LocationBoard;
|
|
|
|
[SerializeField] private AudioManager _AudioManager;
|
|
|
|
private DataDictionary _LandmarkData;
|
|
private int _StageIndex = 0;
|
|
|
|
|
|
public override void InitialiseGameMode()
|
|
{
|
|
PopulateLandmarkDataOnLocationBoard();
|
|
|
|
base.InitialiseGameMode();
|
|
}
|
|
|
|
|
|
public override void LoadQuestionData(DataToken Data)
|
|
{
|
|
|
|
_LandmarkData = Data.DataDictionary;
|
|
|
|
if (_LandmarkData.ContainsKey("Location") && _LandmarkData.ContainsKey("Landmarks"))
|
|
{
|
|
if (_LandmarkData["Landmarks"].TokenType == TokenType.DataList && _LandmarkData["Landmarks"].DataList.Count >= 15)
|
|
{
|
|
PopulateLandmarkDataOnLocationBoard();
|
|
}
|
|
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.");
|
|
}
|
|
|
|
EnableInteraction("Start Game");
|
|
}
|
|
|
|
private void DisplayBriefing()
|
|
{
|
|
HostCardRecoverTheLootExplainerInterface RecoverTheLootInterface =
|
|
(HostCardRecoverTheLootExplainerInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLootExplainer);
|
|
|
|
RecoverTheLootInterface.HeaderUI.text = RoundSegmentTypeToString(RoundSegmentType.RecoverTheLootExplainer);
|
|
}
|
|
|
|
private void PopulateLandmarkDataOnLocationBoard()
|
|
{
|
|
DataList Landmarks = _LandmarkData["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"))
|
|
{
|
|
_LocationBoard.LocationPanelText[i].text = LandmarkEntry["Landmark"].ToString();
|
|
}
|
|
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.");
|
|
}
|
|
}
|
|
|
|
_LocationBoard.RandomiseLocations();
|
|
}
|
|
|
|
private void BeginRound()
|
|
{
|
|
HostCardRecoverTheLootInterface RecoverTheLootInterface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
|
|
DataList Landmarks = _LandmarkData["Landmarks"].DataList;
|
|
for (int i = 0; i < Landmarks.Count; i++)
|
|
{
|
|
if (Landmarks[i].TokenType == TokenType.DataDictionary)
|
|
{
|
|
RecoverTheLootInterface.AddLandmarkName(i, Landmarks[i].DataDictionary["Landmark"].ToString());
|
|
}
|
|
}
|
|
|
|
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
|
|
"PlayMusicLoop", MusicEventType.RecoverTheLoot);
|
|
}
|
|
|
|
|
|
public void OnTheRightTrack()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
Interface.SetComment("On the right track. You get a free turn.", Color.green);
|
|
}
|
|
|
|
public void AlmostThere()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
Interface.SetComment("Almost got it. Another free turn.", Color.yellow);
|
|
}
|
|
|
|
public void OutOfOrder(PanelType Type)
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
|
|
string PanelToken = "";
|
|
switch (Type)
|
|
{
|
|
case PanelType.Loot:
|
|
PanelToken = _CaseManager.GetLoot();
|
|
break;
|
|
case PanelType.Warrant:
|
|
PanelToken = "the warrant";
|
|
break;
|
|
case PanelType.Crook:
|
|
PanelToken = _CaseManager.GetAccusedCrook();
|
|
break;
|
|
}
|
|
|
|
Interface.SetComment("Found " + PanelToken + ". 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(RoundSegmentType.RecoverTheLoot);
|
|
Interface.SetComment("Nothing there.", Color.black);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
}
|
|
|
|
public void AlreadyTried()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
Interface.SetComment("Already tried that one.", Color.black);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
}
|
|
|
|
public void NiceStrategy()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
Interface.SetComment("Nice strategy.", Color.green);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
}
|
|
|
|
// This is for when a player wins the game. This should disable all inputs,
|
|
// and should also enable victory animations.
|
|
public void YoureWinner()
|
|
{
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
Interface.SetComment("Winner! Congratulations, [[PLAYER]]", Color.red);
|
|
|
|
Interface.EnableAllPanelButtons(false);
|
|
|
|
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
|
|
"StopMusic");
|
|
}
|
|
|
|
|
|
public void LocationBoardReset()
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent(
|
|
(IUdonEventReceiver)_LocationBoard,
|
|
NetworkEventTarget.All,
|
|
"ResetPanelBoard");
|
|
|
|
HostCardRecoverTheLootInterface Interface =
|
|
(HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.RecoverTheLoot);
|
|
|
|
Interface.EnableAllPanelButtons(true);
|
|
|
|
Interface.SetComment("[[PLAYER]], your turn.", Color.black);
|
|
}
|
|
|
|
|
|
public Texture GetCrookPortrait()
|
|
{
|
|
return _CaseManager.GetAccusedCrookPortrait();
|
|
}
|
|
|
|
|
|
public void PlayTheLoot()
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
|
|
NetworkEventTarget.All,
|
|
"PlaySFX", SFXEventType.TheLoot);
|
|
}
|
|
|
|
public void PlayTheWarrant()
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
|
|
NetworkEventTarget.All,
|
|
"PlaySFX", SFXEventType.TheWarrant);
|
|
}
|
|
|
|
public void PlayTheCrookTheme()
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager,
|
|
NetworkEventTarget.All,
|
|
"PlayCrookTheme", _CaseManager.GetCrook());
|
|
}
|
|
|
|
|
|
protected override HostCardInterfaceBase GetHostCardInterface(RoundSegmentType Question)
|
|
{
|
|
return _HostCard.EnableHostCardDisplay(RoundType.RecoverTheLoot, Question);
|
|
}
|
|
|
|
|
|
protected override void _HostCardUseButtonDown_Internal()
|
|
{
|
|
_StageIndex++;
|
|
switch(_StageIndex)
|
|
{
|
|
case 1: DisplayBriefing(); break;
|
|
case 2: BeginRound(); break;
|
|
}
|
|
}
|
|
|
|
|
|
public void Button_RevealPanel(int Panel)
|
|
{
|
|
((HostCardRecoverTheLootInterface)GetHostCardInterface(RoundSegmentType.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]]";
|
|
}
|
|
}
|
|
}
|