- Fixed risk amount defaulting to -1 if no risk cards were chosen. - Fixed reference to Think About It music. - Resolved a bunch of fucking merge conflicts that keep popping up because git sucks shit.
159 lines
3.4 KiB
C#
159 lines
3.4 KiB
C#
|
|
using TMPro;
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Components;
|
|
using VRC.SDK3.UdonNetworkCalling;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon.Common.Interfaces;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class RiskCardGroup : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private PlayerPodium _Podium;
|
|
[SerializeField] private RiskCard[] _RiskCards;
|
|
[SerializeField] private TextMeshProUGUI[] _RiskCardText;
|
|
|
|
[SerializeField] private GameObject _PCCardHeldPosition;
|
|
[SerializeField] private Animator _PCCardAnimator;
|
|
|
|
[UdonSynced] private int _SelectedRiskAmount = -1;
|
|
|
|
|
|
void Start()
|
|
{
|
|
for (int i = 0; i < _RiskCards.Length; i++)
|
|
{
|
|
RiskCard Card = _RiskCards[i];
|
|
|
|
Card.SetCardGroup(this);
|
|
}
|
|
}
|
|
|
|
[NetworkCallable]
|
|
public void RiskCardPickedUp(int RiskAmount)
|
|
{
|
|
_SelectedRiskAmount = RiskAmount;
|
|
}
|
|
|
|
[NetworkCallable]
|
|
public void RiskCardInteract(int RiskAmount)
|
|
{
|
|
if (_SelectedRiskAmount == RiskAmount)
|
|
{
|
|
RevealChoice();
|
|
return;
|
|
}
|
|
|
|
_SelectedRiskAmount = RiskAmount;
|
|
|
|
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
|
|
Debug.Assert(Player != null);
|
|
|
|
for (int i = 0; i < _RiskCards.Length; i++)
|
|
{
|
|
RiskCard Card = _RiskCards[i];
|
|
|
|
_PCCardAnimator.SetBool("Turn Forward", false);
|
|
Card.DisableInteractive = false;
|
|
|
|
if (Card.RiskAmount == _SelectedRiskAmount)
|
|
{
|
|
if (!Player.IsUserInVR())
|
|
{
|
|
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)Card, NetworkEventTarget.All, "SetToHeldPosition");
|
|
Card.DisableInteractive = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Card.ResetPosition();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void RevealChoice()
|
|
{
|
|
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
|
|
if (Player != null && !Player.IsUserInVR())
|
|
{
|
|
for (int i = 0; i < _RiskCards.Length; i++)
|
|
{
|
|
RiskCard Card = _RiskCards[i];
|
|
|
|
if (Card.RiskAmount == _SelectedRiskAmount)
|
|
{
|
|
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
|
|
if (Pickup != null)
|
|
{
|
|
Pickup.Drop();
|
|
}
|
|
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)Card, NetworkEventTarget.All, "SetToHeldPosition");
|
|
_PCCardAnimator.SetBool("Turn Forward", true);
|
|
Card.DisableInteractive = true;
|
|
}
|
|
else
|
|
{
|
|
Card.ResetPosition();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public int GetSelectedChoice()
|
|
{
|
|
return (_SelectedRiskAmount < 0) ? 0 : _SelectedRiskAmount;
|
|
}
|
|
|
|
[NetworkCallable]
|
|
public void MakeRiskTextVisible()
|
|
{
|
|
for (int i = 0; i < _RiskCards.Length && i < _RiskCardText.Length; i++)
|
|
{
|
|
_RiskCardText[i].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void LockInChoice()
|
|
{
|
|
for (int i = 0; i < _RiskCards.Length; i++)
|
|
{
|
|
RiskCard Card = _RiskCards[i];
|
|
if (Card.RiskAmount == _SelectedRiskAmount) { Card.DisableInteractive = false; continue; }
|
|
Card.DisableInteractive = true;
|
|
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
|
|
if (Pickup != null) { Pickup.pickupable = false; }
|
|
}
|
|
}
|
|
|
|
public void ResetCards()
|
|
{
|
|
_SelectedRiskAmount = 0;
|
|
|
|
VRCPlayerApi Player = Networking.GetOwner(_Podium.gameObject);
|
|
Debug.Assert(Player != null);
|
|
|
|
bool IsInVR = Player.IsUserInVR();
|
|
|
|
for (int i = 0; i < _RiskCards.Length; i++)
|
|
{
|
|
RiskCard Card = _RiskCards[i];
|
|
|
|
Card.ResetPosition();
|
|
_RiskCardText[i].gameObject.SetActive(false);
|
|
|
|
Card.DisableInteractive = IsInVR;
|
|
|
|
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
|
|
if (Pickup != null)
|
|
{
|
|
Pickup.pickupable = IsInVR;
|
|
}
|
|
}
|
|
|
|
_PCCardAnimator.SetBool("Turn Forward", false);
|
|
}
|
|
}
|