177 lines
5.2 KiB
C#

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.SDK3.Components;
using VRC.Udon.Common;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class HostCardManager : UdonSharpBehaviour
{
[SerializeField] private GameManagerBase _GameManager;
private bool _IsBeingHeld = false;
private float _StoredJumpImpulse = 0.0f;
[Header("UI")]
[SerializeField] private HostCardBetweenRoundsInterface _BetweenRoundsInterface;
[SerializeField] private HostCardMultipleChoiceInterface _MultipleChoiceInterface;
[SerializeField] private HostCardLightningRoundInterface _LightningRoundInterface;
[SerializeField] private HostCardTheChaseInterface _TheChaseInterface;
[SerializeField] private HostCardTiebreakerInterface _TiebreakerInterface;
[SerializeField] private HostCardRecoverTheLootExplainerInterface _RecoverTheLootExplainerInterface;
[SerializeField] private HostCardRecoverTheLootInterface _RecoverTheLootInterface;
[SerializeField] private HostCardCaptureCarmenExplainerInterface _CaptureCarmenExplainerInterface;
[SerializeField] private HostCardCaptureCarmenInterface _CaptureCarmenInterface;
[SerializeField] private HostPanelInterface _AdminPanelInterface;
public override void OnPickup()
{
if (gameObject != null)
{
Networking.SetOwner(Networking.LocalPlayer, gameObject);
_StoredJumpImpulse = Networking.LocalPlayer.GetJumpImpulse();
Networking.LocalPlayer.SetJumpImpulse(0.0f);
_IsBeingHeld = true;
}
base.OnPickup();
}
public override void OnDrop()
{
if (gameObject != null)
{
Networking.SetOwner(Networking.InstanceOwner, gameObject);
Networking.LocalPlayer.SetJumpImpulse(_StoredJumpImpulse);
_StoredJumpImpulse = 0.0f;
_IsBeingHeld = false;
}
base.OnDrop();
}
public override bool OnOwnershipRequest(VRCPlayerApi RequestingPlayer, VRCPlayerApi RequestedOwner)
{
Debug.LogError(RequestingPlayer.displayName + " is requesting that " + RequestedOwner.displayName + " become the new owner of the host card. No fucking way.");
return false;
}
public override void OnOwnershipTransferred(VRCPlayerApi Player)
{
Debug.LogError("New owner is " + Player);
}
public override void InputJump(bool Value, UdonInputEventArgs Args)
{
if (Value && _IsBeingHeld)
{
_AdminPanelInterface.gameObject.SetActive(!_AdminPanelInterface.gameObject.activeSelf);
}
base.InputJump(Value, Args);
}
public override void OnPickupUseDown()
{
if (_GameManager) _GameManager.HostCardUseButtonDown();
base.OnPickupUseDown();
}
public void SetNextInteractionText(string NextInteractionText)
{
DisableInteractive = false;
VRCPickup Pickup = GetComponent<VRCPickup>();
if (Pickup != null)
{
Pickup.UseText = NextInteractionText;
}
}
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);
_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;
}
} 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;
}
}