- Added a callback class to allow interactions to send signals to non-pickups. - Round 2 phone now syncs with VRCObjectSync, like many simple pick-ups now do. - Doors can now choose whether they auto-close. - GameManagers now enable and disable live lights as necessary. - More transparent textures now have "Alpha is transparency" enabled. - Podium prefab shifted slightly in its default position. This changes nothing.
256 lines
6.1 KiB
C#
256 lines
6.1 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Data;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon.Common;
|
|
|
|
|
|
public enum RoundType
|
|
{
|
|
None,
|
|
LocateTheCrook,
|
|
RecoverTheLoot,
|
|
CaptureCarmen
|
|
}
|
|
|
|
public enum RoundSegmentType
|
|
{
|
|
BetweenSegments,
|
|
|
|
MultipleChoice,
|
|
LightningRound,
|
|
DumpsterDive,
|
|
TheChase,
|
|
FinalRound,
|
|
Tiebreaker,
|
|
EndGame,
|
|
|
|
RecoverTheLootExplainer,
|
|
RecoverTheLoot,
|
|
EndRecoverTheLoot,
|
|
|
|
CaptureCarmenExplainer,
|
|
CaptureCarmen
|
|
}
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class GameManagerBase : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] protected VideoLoadIndicator _HostVideoLoadIndicator;
|
|
|
|
[SerializeField] protected HostCardManager _HostCard = null;
|
|
[SerializeField] protected CaseManager _CaseManager;
|
|
[SerializeField] protected AudioManager _AudioManager;
|
|
[SerializeField] protected GameObject[] _MiscellaneousObjects;
|
|
[SerializeField] protected Microphone _PlayerMicrophone = null;
|
|
[SerializeField] protected Microphone _AudienceSilencer = null;
|
|
[Space]
|
|
[SerializeField] private PositionMarker _HostPositionMarker;
|
|
[SerializeField] private PositionMarker[] _PlayerPositionMarkers;
|
|
[Space]
|
|
[SerializeField] protected CameraControllerBase _CameraController;
|
|
|
|
[UdonSynced] private bool _Initialised = false;
|
|
|
|
private bool _IsHostEnabled = false;
|
|
private bool _AllowInteractionFromHostCard = false;
|
|
|
|
|
|
protected void EnableInteraction(string NextInteraction = "Advance")
|
|
{
|
|
_AllowInteractionFromHostCard = true;
|
|
_HostCard.SetNextInteractionText(NextInteraction);
|
|
}
|
|
protected void DisableInteraction(string DisableReason = "")
|
|
{
|
|
_AllowInteractionFromHostCard = false;
|
|
_HostCard.SetNextInteractionText(DisableReason);
|
|
}
|
|
|
|
public override void OnOwnershipTransferred(VRCPlayerApi Player)
|
|
{
|
|
SetOwnershipOfObjects(Player);
|
|
base.OnOwnershipTransferred(Player);
|
|
}
|
|
|
|
public override void OnDeserialization(DeserializationResult Result)
|
|
{
|
|
_InitAndDeinit_Synced();
|
|
|
|
base.OnDeserialization(Result);
|
|
}
|
|
|
|
public void HostEnabled()
|
|
{
|
|
_IsHostEnabled = true;
|
|
|
|
if (IsRoundInitialised())
|
|
{
|
|
EnablePlayerMicrophone(true);
|
|
}
|
|
}
|
|
|
|
public void HostDisabled()
|
|
{
|
|
_IsHostEnabled = false;
|
|
|
|
if (IsRoundInitialised())
|
|
{
|
|
EnablePlayerMicrophone(false);
|
|
}
|
|
}
|
|
|
|
public VRCPlayerApi GetHostOwner()
|
|
{
|
|
return _CaseManager.GetHostOwner();
|
|
}
|
|
|
|
public bool IsInteractionEnabled()
|
|
{
|
|
return _AllowInteractionFromHostCard;
|
|
}
|
|
|
|
public void HostCardUseButtonDown()
|
|
{
|
|
if (!IsInteractionEnabled()) { return; }
|
|
|
|
_HostCardUseButtonDown_Internal();
|
|
}
|
|
|
|
protected virtual HostCardInterfaceBase GetHostCardInterface(RoundSegmentType Question)
|
|
{
|
|
Debug.LogError("You should not be seeing this. You don't need to call base.GetHostCardInterface()");
|
|
return _HostCard.EnableHostCardDisplay(RoundType.None, Question);
|
|
}
|
|
|
|
protected virtual void _HostCardUseButtonDown_Internal()
|
|
{
|
|
Debug.LogError("You should not be seeing this. You don't need to call base._HostCardUseButtonDown_Internal()");
|
|
}
|
|
|
|
|
|
public virtual void InitialiseGameMode()
|
|
{
|
|
_Initialised = true;
|
|
_InitAndDeinit_Synced();
|
|
|
|
SetOwnershipOfObjects(_CaseManager.GetHostOwner());
|
|
|
|
_AllowInteractionFromHostCard = true;
|
|
|
|
EnablePlayerMicrophone(true);
|
|
EnableAudienceSilencer(false);
|
|
|
|
_HostPositionMarker.SetPlayer(_CaseManager.GetHostOwner().displayName);
|
|
string[] WinningPlayers = _CaseManager.GetCurrentWinningPlayers();
|
|
for (int i = 0; i < _PlayerPositionMarkers.Length; i++)
|
|
{
|
|
string PlayerName = "";
|
|
if (i < WinningPlayers.Length)
|
|
{
|
|
PlayerName = WinningPlayers[i];
|
|
}
|
|
else
|
|
{
|
|
PlayerName = _CaseManager.GetHostOwner().displayName;
|
|
}
|
|
_PlayerPositionMarkers[i].SetPlayer(PlayerName);
|
|
}
|
|
|
|
RequestSerialization();
|
|
}
|
|
|
|
public virtual void DeinitialiseGameMode()
|
|
{
|
|
EnablePlayerMicrophone(false);
|
|
EnableAudienceSilencer(true);
|
|
|
|
_HostPositionMarker.ClearPlayer();
|
|
for (int i = 0; i < _PlayerPositionMarkers.Length; i++)
|
|
{
|
|
_PlayerPositionMarkers[i].ClearPlayer();
|
|
}
|
|
|
|
_Initialised = false;
|
|
_InitAndDeinit_Synced();
|
|
|
|
RequestSerialization();
|
|
}
|
|
|
|
private void _InitAndDeinit_Synced()
|
|
{
|
|
foreach (GameObject Object in _MiscellaneousObjects)
|
|
{
|
|
Object.SetActive(_Initialised);
|
|
}
|
|
}
|
|
|
|
public bool IsRoundInitialised()
|
|
{
|
|
return _Initialised;
|
|
}
|
|
|
|
public void EnablePlayerMicrophone(bool Enable)
|
|
{
|
|
if (_PlayerMicrophone && _IsHostEnabled)
|
|
{
|
|
_PlayerMicrophone.EnableMicrophone(Enable);
|
|
}
|
|
}
|
|
|
|
public void EnableAudienceSilencer(bool Enable)
|
|
{
|
|
if (_AudienceSilencer && _IsHostEnabled)
|
|
{
|
|
_AudienceSilencer.EnableMicrophone(Enable);
|
|
}
|
|
}
|
|
|
|
public virtual void SetOwnershipOfObjects(VRCPlayerApi NewOwner)
|
|
{
|
|
Networking.SetOwner(NewOwner, _HostVideoLoadIndicator.gameObject);
|
|
|
|
if (_PlayerMicrophone) Networking.SetOwner(NewOwner, _PlayerMicrophone.gameObject);
|
|
if (_AudienceSilencer) Networking.SetOwner(NewOwner, _AudienceSilencer.gameObject);
|
|
}
|
|
|
|
public virtual void LoadQuestionData(DataToken Data) { }
|
|
|
|
|
|
protected string RoundTypeToString(RoundType Type)
|
|
{
|
|
switch ((int)Type)
|
|
{
|
|
case (int)RoundType.LocateTheCrook: return "Locate The Crook";
|
|
case (int)RoundType.RecoverTheLoot: return "Recover The Loot";
|
|
case (int)RoundType.CaptureCarmen: return "Capture Carmen";
|
|
default: return "[[ERROR]]";
|
|
}
|
|
}
|
|
|
|
protected string RoundSegmentTypeToString(RoundSegmentType Type)
|
|
{
|
|
switch (Type)
|
|
{
|
|
case RoundSegmentType.BetweenSegments: return "None";
|
|
case RoundSegmentType.MultipleChoice: return "Standard Round";
|
|
case RoundSegmentType.LightningRound: return "Lightning Round";
|
|
case RoundSegmentType.DumpsterDive: return "Dumpster Dive";
|
|
case RoundSegmentType.TheChase: return "The Chase";
|
|
case RoundSegmentType.FinalRound: return "Final Round";
|
|
case RoundSegmentType.Tiebreaker: return "Tiebreaker";
|
|
|
|
case RoundSegmentType.RecoverTheLootExplainer: return "Recover The Loot - Briefing";
|
|
case RoundSegmentType.RecoverTheLoot: return "Recover The Loot";
|
|
case RoundSegmentType.EndRecoverTheLoot: return "Recover The Loot - Debriefing";
|
|
|
|
case RoundSegmentType.CaptureCarmenExplainer: return "Capture Carmen - Briefing";
|
|
case RoundSegmentType.CaptureCarmen: return "Capture Carmen";
|
|
|
|
default: return "[[ERROR]]";
|
|
}
|
|
}
|
|
}
|