Working via NetworkManager
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
namespace Marro.PacManUdon
|
||||
{
|
||||
using System;
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon;
|
||||
using VRC.SDK3.Data;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Data;
|
||||
|
||||
public class GhostManager : UdonSharpBehaviour
|
||||
namespace Marro.PacManUdon
|
||||
{
|
||||
public class GhostManager : SyncedObject
|
||||
{
|
||||
[NonSerialized] public GameManager gameController;
|
||||
private Ghost[] ghosts;
|
||||
@@ -33,7 +30,7 @@
|
||||
private DataList ghostScaredQueue;
|
||||
|
||||
// Blink logic
|
||||
private float blinkCycleRate = 0.233333333f;
|
||||
private const float blinkCycleRate = 0.233333333f;
|
||||
private bool blinkingActivated;
|
||||
private float blinkCountdown;
|
||||
private bool blinkCurrentlyWhite;
|
||||
@@ -50,7 +47,7 @@
|
||||
// Ghost house logic
|
||||
private bool sharedPelletCounterActive;
|
||||
private int sharedPelletCounter;
|
||||
private int[] sharedPelletCounterReleaseValues = { 0, 7, 17, 32 };
|
||||
private readonly int[] sharedPelletCounterReleaseValues = { 0, 7, 17, 32 };
|
||||
private float pelletTimeout;
|
||||
private float pelletTimeoutLimit;
|
||||
|
||||
@@ -108,7 +105,7 @@
|
||||
SetSharedPelletCounterActive(true);
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
public override void SyncedUpdate()
|
||||
{
|
||||
// gameStateManager.statusDisplay.SetDebugText(1, this.blinkCountdown.ToString());
|
||||
if (frozen || kinematic)
|
||||
@@ -130,7 +127,7 @@
|
||||
|
||||
void UpdateScattering()
|
||||
{
|
||||
scatterCounter += Time.deltaTime;
|
||||
scatterCounter += networkManager.SyncedDeltaTime;
|
||||
if (scatterPatternIndex < scatterPattern.Length && scatterCounter >= scatterPattern[scatterPatternIndex])
|
||||
{
|
||||
// Debug.Log($"{gameObject} SetScattering: {scatterPatternIndex%1 == 0}, scatterCounter: {scatterCounter}, scatterPattern: {scatterPattern[scatterPatternIndex]}, scatterPatternIndex: {scatterPatternIndex}");
|
||||
@@ -141,7 +138,7 @@
|
||||
|
||||
void UpdatePowerPellet()
|
||||
{
|
||||
powerPelletCountdown -= Time.deltaTime;
|
||||
powerPelletCountdown -= networkManager.SyncedDeltaTime;
|
||||
if (powerPelletCountdown <= 0)
|
||||
{
|
||||
gameController.EndPowerPellet(); // End power pellet
|
||||
@@ -154,7 +151,7 @@
|
||||
|
||||
if (blinkingActivated)
|
||||
{
|
||||
blinkCountdown -= Time.deltaTime;
|
||||
blinkCountdown -= networkManager.SyncedDeltaTime;
|
||||
if (blinkCountdown <= 0)
|
||||
{
|
||||
blinkCountdown += blinkCycleRate;
|
||||
@@ -165,7 +162,8 @@
|
||||
|
||||
void UpdatePelletTimeout()
|
||||
{
|
||||
pelletTimeout += Time.deltaTime;
|
||||
pelletTimeout += networkManager.SyncedDeltaTime;
|
||||
|
||||
if (pelletTimeout >= pelletTimeoutLimit)
|
||||
{
|
||||
pelletTimeout -= pelletTimeoutLimit;
|
||||
@@ -471,6 +469,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Ghost[] Ghosts
|
||||
{
|
||||
get => ghosts;
|
||||
|
||||
Reference in New Issue
Block a user