Jamie Greunbaum 1b167390cb - Host card now also uses VRCObjectSync.
- Host card spawner now switches ownership on interact to prevent sync issues.
- Host card spawner now has an inset square collider to get in the way less.
- Adjusted collision box of location board to not block the host card spawner.
- Phone box cover now closes automatically when round 2 ends.
2026-05-15 13:56:37 -04:00

208 lines
5.8 KiB
C#

using TMPro;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Components;
using VRC.SDKBase;
using VRC.Udon.Common;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class HostCardManager : UdonSharpBehaviour
{
[SerializeField] private GameManagerBase _GameManager;
[SerializeField] private VRCPickup _PickupComponent;
[Space, Header("UI")]
[SerializeField] private HostCardBetweenRoundsInterface _BetweenRoundsInterface;
[Space]
[SerializeField] private HostCardMultipleChoiceInterface _MultipleChoiceInterface;
[SerializeField] private HostCardLightningRoundInterface _LightningRoundInterface;
[SerializeField] private HostCardTheChaseInterface _TheChaseInterface;
[SerializeField] private HostCardTiebreakerInterface _TiebreakerInterface;
[Space]
[SerializeField] private HostCardRecoverTheLootExplainerInterface _RecoverTheLootExplainerInterface;
[SerializeField] private HostCardRecoverTheLootInterface _RecoverTheLootInterface;
[SerializeField] private HostCardRecoverTheLootEndInterface _RecoverTheLootEndInterface;
[Space]
[SerializeField] private HostCardCaptureCarmenExplainerInterface _CaptureCarmenExplainerInterface;
[SerializeField] private HostCardCaptureCarmenInterface _CaptureCarmenInterface;
[Space]
[SerializeField] private HostPanelInterface _AdminPanelInterface;
[Space]
[SerializeField] private TextMeshProUGUI _InteractionText;
private bool _IsBeingHeld = false;
private float _StoredJumpImpulse = 0.0f;
public void HostCardPickedUp()
{
_StoredJumpImpulse = Networking.LocalPlayer.GetJumpImpulse();
Networking.LocalPlayer.SetJumpImpulse(0.0f);
_IsBeingHeld = true;
_InteractionText.gameObject.SetActive(true);
}
public void HostCardDropped()
{
Networking.LocalPlayer.SetJumpImpulse(_StoredJumpImpulse);
_StoredJumpImpulse = 0.0f;
_IsBeingHeld = false;
_InteractionText.gameObject.SetActive(false);
}
public override void InputJump(bool Value, UdonInputEventArgs Args)
{
if (Value && _IsBeingHeld)
{
_AdminPanelInterface.gameObject.SetActive(!_AdminPanelInterface.gameObject.activeSelf);
}
base.InputJump(Value, Args);
}
public override void InputLookVertical(float Value, UdonInputEventArgs Args)
{
if (Networking.LocalPlayer.IsUserInVR() && _IsBeingHeld)
{
_ChangeFontSize_VR((int)Value, Args);
}
base.InputLookVertical(Value, Args);
}
private void _ChangeFontSize_VR(int Direction, UdonInputEventArgs Args)
{
if (Direction > 0)
{
// Increase host card font sizes here later
}
else if (Direction < 0)
{
// Decrease host card font sizes here later
}
}
public void HostCardUseDown()
{
if (_GameManager) _GameManager.HostCardUseButtonDown();
}
public void EnablePickup(bool Enable)
{
_PickupComponent.pickupable = Enable;
_PickupComponent.AutoHold = Networking.LocalPlayer.IsUserInVR() ? VRC_Pickup.AutoHoldMode.No : VRC_Pickup.AutoHoldMode.Yes;
}
public void SetNextInteractionText(string NextInteractionText)
{
if (NextInteractionText != "")
{
DisableInteractive = false;
_InteractionText.text = "Next: " + NextInteractionText;
}
else
{
_InteractionText.text = "Please wait...";
}
}
public void SetGameManager(GameManagerBase Manager)
{
_GameManager = Manager;
}
public HostCardInterfaceBase EnableHostCardDisplay(RoundType Game, RoundSegmentType Question)
{
_BetweenRoundsInterface.gameObject.SetActive(false);
_MultipleChoiceInterface.gameObject.SetActive(false);
_LightningRoundInterface.gameObject.SetActive(false);
_TheChaseInterface.gameObject.SetActive(false);
_TiebreakerInterface.gameObject.SetActive(false);
_RecoverTheLootExplainerInterface.gameObject.SetActive(false);
_RecoverTheLootInterface.gameObject.SetActive(false);
_RecoverTheLootEndInterface.gameObject.SetActive(false);
_CaptureCarmenExplainerInterface.gameObject.SetActive(false);
_CaptureCarmenInterface.gameObject.SetActive(false);
switch (Game)
{
case RoundType.LocateTheCrook:
{
switch (Question)
{
case RoundSegmentType.MultipleChoice:
_MultipleChoiceInterface.gameObject.SetActive(true);
return _MultipleChoiceInterface;
case RoundSegmentType.LightningRound:
_LightningRoundInterface.gameObject.SetActive(true);
return _LightningRoundInterface;
case RoundSegmentType.DumpsterDive: break;
case RoundSegmentType.TheChase:
_TheChaseInterface.gameObject.SetActive(true);
return _TheChaseInterface;
case RoundSegmentType.FinalRound:
_MultipleChoiceInterface.gameObject.SetActive(true);
return _MultipleChoiceInterface;
case RoundSegmentType.Tiebreaker:
_TiebreakerInterface.gameObject.SetActive(true);
return _TiebreakerInterface;
}
} break;
case RoundType.RecoverTheLoot:
{
switch(Question)
{
case RoundSegmentType.RecoverTheLootExplainer:
_RecoverTheLootExplainerInterface.gameObject.SetActive(true);
return _RecoverTheLootExplainerInterface;
case RoundSegmentType.RecoverTheLoot:
_RecoverTheLootInterface.gameObject.SetActive(true);
return _RecoverTheLootInterface;
case RoundSegmentType.EndRecoverTheLoot:
_RecoverTheLootEndInterface.gameObject.SetActive(true);
return _RecoverTheLootEndInterface;
}
} break;
case RoundType.CaptureCarmen:
{
switch (Question)
{
case RoundSegmentType.CaptureCarmenExplainer:
_CaptureCarmenExplainerInterface.gameObject.SetActive(true);
return _CaptureCarmenExplainerInterface;
case RoundSegmentType.CaptureCarmen:
_CaptureCarmenInterface.gameObject.SetActive(true);
return _CaptureCarmenInterface;
}
} break;
default:
_BetweenRoundsInterface.gameObject.SetActive(true);
return _BetweenRoundsInterface;
}
_BetweenRoundsInterface.gameObject.SetActive(true);
return _BetweenRoundsInterface;
}
}