71 lines
1.5 KiB
C#
71 lines
1.5 KiB
C#
|
|
using Marro.PacManUdon;
|
|
using TMPro;
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
|
|
public class TestBallManager : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] TestBall[] testBalls;
|
|
[SerializeField] NetworkManager networkManager;
|
|
[SerializeField] private TMP_InputField debugOutput;
|
|
|
|
void Start()
|
|
{
|
|
networkManager.Initialize();
|
|
foreach (var testBall in testBalls)
|
|
{
|
|
testBall.Initialize(networkManager);
|
|
}
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (debugOutput == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
debugOutput.text = "";
|
|
networkManager.WriteDebugOutput(debugOutput);
|
|
foreach (var testBall in testBalls)
|
|
{
|
|
testBall.WriteDebugOutput(debugOutput);
|
|
}
|
|
}
|
|
|
|
public void ResetButtonPressed()
|
|
{
|
|
Start();
|
|
}
|
|
|
|
public void UpButtonPressed()
|
|
{
|
|
foreach (var testBall in testBalls)
|
|
{
|
|
testBall.UpButtonPressed();
|
|
}
|
|
|
|
networkManager.SendEventSoon(NetworkEventType.PacManTurn);
|
|
}
|
|
|
|
public void SyncButtonPressed()
|
|
{
|
|
if (VRCPlayerApi.GetPlayerCount() == 1)
|
|
{
|
|
networkManager.SimulateSyncToTimestamp(networkManager.SyncedTime - 0.5f);
|
|
}
|
|
else if (networkManager.IsOwner)
|
|
{
|
|
networkManager.SendEventSoon(NetworkEventType.FullSync);
|
|
}
|
|
else
|
|
{
|
|
networkManager.RequestEvent(NetworkEventType.FullSync);
|
|
}
|
|
}
|
|
}
|