147 lines
4.0 KiB
C#

using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDK3.UdonNetworkCalling;
using VRC.Udon.Common.Interfaces;
using VRC.SDKBase;
using VRC.SDK3.StringLoading;
using VRC.SDK3.Components;
using VRC.Udon.Common;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class HostCardManager : UdonSharpBehaviour
{
[SerializeField] private GameManagerBase _GameManager;
private int[] _FinalRoundPlayersSortedByScore;
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 HostCardFinalRoundInterface _FinalRoundInterface;
//[SerializeField] private HostCardRound2Interface _Round2Interface;
[SerializeField] private HostPanelInterface _AdminPanelInterface;
public override void OnPickup()
{
Networking.SetOwner(Networking.LocalPlayer, gameObject);
_StoredJumpImpulse = Networking.LocalPlayer.GetJumpImpulse();
Networking.LocalPlayer.SetJumpImpulse(0.0f);
_IsBeingHeld = true;
base.OnPickup();
}
public override void OnDrop()
{
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()
{
_GameManager.HostCardUseButtonDown();
base.OnPickupUseDown();
}
public void SetNextInteractionText(string NextInteractionText)
{
DisableInteractive = false;
VRCPickup Pickup = GetComponent<VRCPickup>();
if (Pickup != null)
{
Pickup.UseText = NextInteractionText;
}
}
public HostCardInterfaceBase EnableHostCardDisplay(GameType Game, QuestionType Question)
{
_BetweenRoundsInterface.gameObject.SetActive(false);
_MultipleChoiceInterface.gameObject.SetActive(false);
_LightningRoundInterface.gameObject.SetActive(false);
_TheChaseInterface.gameObject.SetActive(false);
_FinalRoundInterface.gameObject.SetActive(false);
//_Round2Interface.gameObject.SetActive(false);
switch (Game)
{
case GameType.LocateTheCrook:
{
switch (Question)
{
case QuestionType.MultipleChoice:
_MultipleChoiceInterface.gameObject.SetActive(true);
return _MultipleChoiceInterface;
case QuestionType.LightningRound:
_LightningRoundInterface.gameObject.SetActive(true);
return _LightningRoundInterface;
case QuestionType.DumpsterDive: break;
case QuestionType.TheChase:
_TheChaseInterface.gameObject.SetActive(true);
return _TheChaseInterface;
case QuestionType.FinalRound:
_FinalRoundInterface.gameObject.SetActive(true);
return _FinalRoundInterface;
case QuestionType.Tiebreaker:
default:
_BetweenRoundsInterface.gameObject.SetActive(true);
return _BetweenRoundsInterface;
}
} break;
case GameType.RecoverTheLoot:
{
} break;
case GameType.ChaseCarmen:
{
} break;
default:
_BetweenRoundsInterface.gameObject.SetActive(true);
return _BetweenRoundsInterface;
}
_BetweenRoundsInterface.gameObject.SetActive(true);
return _BetweenRoundsInterface;
}
}