79 lines
1.5 KiB
C#
79 lines
1.5 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Components;
|
|
using VRC.SDK3.UdonNetworkCalling;
|
|
using VRC.SDKBase;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class ChoiceCardGroup : UdonSharpBehaviour
|
|
{
|
|
public ChoiceCard[] ChoiceCards;
|
|
|
|
[SerializeField] private PlayerPodium Podium = null;
|
|
[SerializeField] private Transform _PCCardHeldPosition;
|
|
|
|
private int _SelectedChoice = -1;
|
|
|
|
|
|
void Start()
|
|
{
|
|
for (int i = 0; i < ChoiceCards.Length; i++)
|
|
{
|
|
ChoiceCards[i].SetParent(this);
|
|
ChoiceCards[i].ResetPosition();
|
|
}
|
|
}
|
|
|
|
|
|
[NetworkCallable]
|
|
public void ChoiceCardInteract(int ChoiceNumber)
|
|
{
|
|
_SelectedChoice = ChoiceNumber;
|
|
|
|
for (int i = 0; i < ChoiceCards.Length; i++)
|
|
{
|
|
ChoiceCard Card = ChoiceCards[i];
|
|
|
|
if (Card.ChoiceNumber == _SelectedChoice)
|
|
{
|
|
VRCPlayerApi Player = Networking.GetOwner(Podium.gameObject);
|
|
if (Player != null && !Player.IsUserInVR())
|
|
{
|
|
VRCPickup Pickup = Card.GetComponent<VRCPickup>();
|
|
if (Pickup != null)
|
|
{
|
|
Pickup.Drop();
|
|
}
|
|
Card.transform.localPosition = _PCCardHeldPosition.localPosition;
|
|
Card.transform.localEulerAngles = _PCCardHeldPosition.localEulerAngles;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Card.ResetPosition();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void RevealChoice(int ChoiceNumber)
|
|
{
|
|
if (ChoiceNumber == _SelectedChoice)
|
|
{
|
|
VRCPlayerApi Player = Networking.GetOwner(Podium.gameObject);
|
|
if (Player != null && !Player.IsUserInVR())
|
|
{
|
|
// Play the PC turn-around animation here.
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public int GetSelectedChoice()
|
|
{
|
|
return _SelectedChoice;
|
|
}
|
|
}
|