using UdonSharp; using UnityEngine; using VRC.SDK3.Data; using VRC.SDK3.UdonNetworkCalling; public enum ContinentMap { Africa, Asia, Europe, NorthAmerica, Oceania, SouthAmerica } [UdonBehaviourSyncMode(BehaviourSyncMode.Manual)] public class GameManagerRound3 : GameManagerBase { [SerializeField] private CaseManager _CaseManager; [SerializeField] private FloorMap[] _Maps; [SerializeField] private FloorMapMarker[] _Markers; [SerializeField] private AudioManager _AudioManager; private ContinentMap _ActiveMap = ContinentMap.Africa; private DataDictionary _ContinentData; private int _StageIndex = 0; private int _SuccessCounter = 0; private int _FailureCounter = 0; private const int MAX_FAILURE_COUNT = 2; private const int MAX_SUCCESS_COUNT = 8; public override void InitialiseGameMode() { base.InitialiseGameMode(); } public override void LoadQuestionData(DataToken Data) { _ContinentData = Data.DataDictionary; if (_ContinentData.ContainsKey("Continent")) { _ActiveMap = (ContinentMap)(int)_ContinentData["Continent"].Number; for (int i = 0; i < _Maps.Length; i++) { FloorMap Map = _Maps[i]; if (Map != null) { Map.gameObject.SetActive(i == (int)_ActiveMap); } } GetCurrentMap().RandomiseCountries(); } else { Debug.LogError("Malformed round data. Ensure Round 3 contains a continent to use for the map."); } EnableInteraction("Start Game"); } private void DisplayBriefing() { HostCardCaptureCarmenExplainerInterface CaptureCarmenExplainerInterface = (HostCardCaptureCarmenExplainerInterface)GetHostCardInterface(RoundSegmentType.CaptureCarmenExplainer); CaptureCarmenExplainerInterface.HeaderUI.text = RoundSegmentTypeToString(RoundSegmentType.CaptureCarmenExplainer); } public void BeginRound() { UpdateInterface(); GetCurrentMarker().EnablePickup(true); } public void CorrectResponse() { _AudioManager.PlaySFX(SFXEventType.MapCorrect); GetCurrentMarker().EnablePickup(false); _SuccessCounter++; if (_SuccessCounter >= MAX_SUCCESS_COUNT) { Debug.LogError("No error. We won."); } else { int NextCountry = GetCurrentMap().NextCountry(); _Markers[NextCountry].EnablePickup(true); UpdateInterface(); } } public void IncorrectResponse() { _FailureCounter++; if (_FailureCounter >= MAX_FAILURE_COUNT) { _FailureCounter = 0; GetCurrentMarker().EnablePickup(false); int NextCountry = GetCurrentMap().NextCountry(); _Markers[NextCountry].EnablePickup(true); UpdateInterface(); } _AudioManager.PlaySFX(SFXEventType.MapIncorrect); } public FloorMap GetCurrentMap() { return _Maps[(int)_ActiveMap]; } public FloorMapMarker GetCurrentMarker() { return _Markers[GetCurrentMap().GetCurrentCountryIndex()]; } public string GetCurrentCountry() { return GetCurrentMap().GetCurrentCountry(); } public string GetCurrentCity() { return GetCurrentMap().GetCurrentCity(); } private void UpdateInterface() { HostCardCaptureCarmenInterface CaptureCarmenInterface = (HostCardCaptureCarmenInterface)GetHostCardInterface(RoundSegmentType.CaptureCarmen); CaptureCarmenInterface.HeaderUI.text = RoundSegmentTypeToString(RoundSegmentType.CaptureCarmen); CaptureCarmenInterface.CommentUI.text = GetCurrentCity() + ", " + GetCurrentCountry(); } protected override HostCardInterfaceBase GetHostCardInterface(RoundSegmentType Question) { return _HostCard.EnableHostCardDisplay(RoundType.CaptureCarmen, Question); } protected override void _HostCardUseButtonDown_Internal() { _StageIndex++; switch (_StageIndex) { case 1: DisplayBriefing(); break; case 2: BeginRound(); break; } } }