Compare commits

...

29 Commits

Author SHA1 Message Date
a8b395b1d3 Fixed bug 2026-02-01 15:42:33 +01:00
d03d06b5a7 Applied constant update rate 2026-02-01 15:03:52 +01:00
912be35172 Working on ghost issues 2026-01-24 16:23:53 +01:00
1433b9bdfc Ghosts synced with some issues 2026-01-24 15:04:54 +01:00
9554d1c512 Working on ghost sync 2026-01-19 20:08:06 +01:00
c3a19cc53e Pellet sync 2026-01-18 19:28:12 +01:00
eef7084e21 Fixed ghost bug 2026-01-18 17:14:15 +01:00
f2910d7506 Fix 2026-01-18 17:12:25 +01:00
9f86308d8a Test files 2026-01-18 16:47:11 +01:00
305a0ec3a1 ByteUtils to extension methods 2026-01-18 16:45:47 +01:00
b68b3d1c25 Switched to 1d array CollectSyncedData 2026-01-17 19:25:45 +01:00
3642006bb2 Fixed bugs 2026-01-17 16:37:23 +01:00
154c642cce Pacman syncs really well now 2026-01-16 20:36:21 +01:00
c41491e55e Initial progress syncing + many existing bugs 2026-01-15 23:00:15 +01:00
fb902aaddc Working via NetworkManager 2026-01-14 21:39:24 +01:00
89607f0868 Scene save 2026-01-14 20:05:23 +01:00
fa38960e01 Scene save 2026-01-14 20:05:12 +01:00
d9aac0158d Removed most old networking stuff 2026-01-14 20:03:52 +01:00
4922a91a04 Cleaning a bit 2026-01-14 19:37:37 +01:00
65b153f97d Ready for PacMan?? 2026-01-13 21:28:53 +01:00
da0e6699e7 Working well now I think? 2026-01-12 21:08:20 +01:00
e76df964e5 Cleaner sync 2026-01-08 21:47:58 +01:00
bcf830d52d Cleaned up and more use of Ready 2026-01-08 20:11:21 +01:00
af87ffea42 Small fix 2026-01-08 19:51:11 +01:00
14fc9ea576 Timestamp is now float 2026-01-08 19:45:22 +01:00
630dc5a176 Kinda working refactor 2026-01-05 20:10:13 +01:00
2636e65e4d Some handling of dropped packages 2026-01-04 19:06:03 +01:00
60abba8498 Added eventId 2026-01-04 16:59:04 +01:00
24b2ea09f1 Fixed sync issue 2026-01-04 15:47:11 +01:00
46 changed files with 8311 additions and 4992 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,15 @@
namespace Marro.PacManUdon
{
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDKBase;
using VRC.Udon;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
public class BonusFruit : UdonSharpBehaviour
namespace Marro.PacManUdon
{
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Renderer))]
[RequireComponent(typeof(Collider))]
public class BonusFruit : SyncedObject
{
[SerializeField, UdonSynced, FieldChangeCallback(nameof(FruitType))] PacManFruitType fruitType;
PacManFruitType fruitType;
Animator animator;
new Renderer renderer;
@@ -30,11 +31,11 @@
SetActive(false);
}
void Update()
public override void SyncedUpdate()
{
if (active && !frozen)
{
activeCountdown -= Time.deltaTime;
activeCountdown -= networkManager.SyncedDeltaTime;
if (activeCountdown <= 0)
{
SetActive(false);
@@ -67,7 +68,6 @@
this.fruitType = fruitType;
value = (int)fruitScoreValue[PacManConstants.FruitTypeToValue(fruitType)];
animator.SetFloat("FruitType", PacManConstants.FruitTypeToValue(fruitType));
RequestSerialization();
}
public void SetFrozen(bool frozen)
@@ -80,7 +80,16 @@
renderer.enabled = active;
collider.enabled = active;
this.active = active;
RequestSerialization();
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
return true;
}
public PacManFruitType FruitType
@@ -101,18 +110,17 @@
get => active;
}
private DataDictionary fruitScoreValue = new DataDictionary()
{
{(int)PacManFruitType.None , 0},
{(int)PacManFruitType.Cherries , 100},
{(int)PacManFruitType.Strawberry, 300},
{(int)PacManFruitType.Peach , 500},
{(int)PacManFruitType.Apple , 700},
{(int)PacManFruitType.Grapes , 1000},
{(int)PacManFruitType.Galaxian , 2000},
{(int)PacManFruitType.Bell , 3000},
{(int)PacManFruitType.Key , 5000}
};
private readonly DataDictionary fruitScoreValue = new DataDictionary()
{
{(int)PacManFruitType.None , 0},
{(int)PacManFruitType.Cherries , 100},
{(int)PacManFruitType.Strawberry, 300},
{(int)PacManFruitType.Peach , 500},
{(int)PacManFruitType.Apple , 700},
{(int)PacManFruitType.Grapes , 1000},
{(int)PacManFruitType.Galaxian , 2000},
{(int)PacManFruitType.Bell , 3000},
{(int)PacManFruitType.Key , 5000}
};
}
}

161
Assets/Scripts/ByteUtils.cs Normal file
View File

@@ -0,0 +1,161 @@
using System;
using UnityEngine;
namespace Marro.PacManUdon
{
public static class ByteUtils
{
public static void Append(this byte[] target, byte[] value, ref int index)
{
//Debug.Log($"ByteUtils Append {nameof(value)}.Length: {value.Length}, {nameof(target)}.Length : {target.Length}, {nameof(index)}: {index}");
Array.Copy(value, 0, target, index, value.Length);
index += value.Length;
}
public static void Append(this byte[] target, byte value, ref int index) =>
target[index++] = value;
public static void Append(this byte[] target, sbyte value, ref int index) =>
target[index++] = (byte)value;
public static void Append(this byte[] target, bool value, ref int index) =>
target[index++] = value ? (byte)1 : (byte)0;
public static void Append(this byte[] target, ushort value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, short value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, uint value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, int value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
/// <summary>
/// Casts <paramref name="value"/> to a byte and then appends it.
/// Safer than doing <c>Append((byte)value, ref index)</c>, which can crash the Udonbehaviour.
/// </summary>
public static void AppendAsByte(this byte[] target, int value, ref int index) =>
target.Append(value.ToByte(), ref index);
public static void Append(this byte[] target, ulong value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, long value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, float value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, double value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, char value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
public static void Append(this byte[] target, Vector2 value, ref int index)
{
target.Append(value.x, ref index);
target.Append(value.y, ref index);
}
public static void Append(this byte[] target, Vector3 value, ref int index)
{
target.Append(value.x, ref index);
target.Append(value.y, ref index);
target.Append(value.z, ref index);
}
public static byte ReadByte(this byte[] source, ref int index) =>
source[index++];
public static bool ReadBool(this byte[] source, ref int index) =>
source[index++] > 0;
public static ushort ReadUShort(this byte[] source, ref int index)
{
var value = BitConverter.ToUInt16(source, index);
index += 2;
return value;
}
public static short ReadShort(this byte[] source, ref int index)
{
var value = BitConverter.ToInt16(source, (int)index);
index += 2;
return value;
}
public static uint ReadUInt(this byte[] source, ref int index)
{
var value = BitConverter.ToUInt32(source, index);
index += 4;
return value;
}
public static int ReadInt(this byte[] source, ref int index)
{
var value = BitConverter.ToInt32(source, index);
index += 4;
return value;
}
public static ulong ReadULong(this byte[] source, ref int index)
{
var value = BitConverter.ToUInt64(source, index);
index += 8;
return value;
}
public static long ReadLong(this byte[] source, ref int index)
{
var value = BitConverter.ToInt64(source, index);
index += 8;
return value;
}
public static float ReadFloat(this byte[] source, ref int index)
{
var value = BitConverter.ToSingle(source, index);
index += 4;
return value;
}
public static double ReadDouble(this byte[] source, ref int index)
{
var value = BitConverter.ToDouble(source, index);
index += 8;
return value;
}
public static char ReadChar(this byte[] source, ref int index)
{
var value = BitConverter.ToChar(source, index);
index += 2;
return value;
}
public static Vector2 ReadVector2(this byte[] source, ref int index)
{
var value = new Vector2(BitConverter.ToSingle(source, index), BitConverter.ToSingle(source, index + 4));
index += 8;
return value;
}
public static Vector3 ReadVector3(this byte[] source, ref int index)
{
var value = new Vector3(BitConverter.ToSingle(source, index), BitConverter.ToSingle(source, index + 4), BitConverter.ToSingle(source, index + 8));
index += 12;
return value;
}
/// <summary>
/// Casts an Int32 to a byte.
/// Doing this inline sometimes causes an udon exception, but doing it via a separate method seems to work fine.
/// </summary>
public static byte ToByte(this int value) =>
(byte)value;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7d2126e683a87e241ad0399cefcda807
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -43,25 +43,25 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 10
Data: 11
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: fruitType
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: fruitType
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.PacManFruitType, Assembly-CSharp
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
@@ -70,7 +70,7 @@ MonoBehaviour:
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
@@ -78,8 +78,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
Entry: 6
Data:
- Name:
Entry: 8
Data:
@@ -91,25 +91,67 @@ MonoBehaviour:
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 3
Data: 0
- Name:
Entry: 7
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 7|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
- Name: $k
Entry: 1
Data: fruitType
- Name: $v
Entry: 7
Data: 8|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: fruitType
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.PacManFruitType, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
@@ -130,13 +172,13 @@ MonoBehaviour:
Data: animator
- Name: $v
Entry: 7
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: animator
- Name: <UserType>k__BackingField
Entry: 7
Data: 10|System.RuntimeType, mscorlib
Data: 11|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
@@ -145,7 +187,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 10
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -160,7 +202,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -184,13 +226,13 @@ MonoBehaviour:
Data: renderer
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: renderer
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
Data: 14|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Renderer, UnityEngine.CoreModule
@@ -199,7 +241,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
Data: 14
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -214,7 +256,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -238,13 +280,13 @@ MonoBehaviour:
Data: collider
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: collider
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Collider, UnityEngine.PhysicsModule
@@ -253,7 +295,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
Data: 17
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -268,7 +310,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -292,13 +334,13 @@ MonoBehaviour:
Data: scoreBonusDisplay
- Name: $v
Entry: 7
Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: scoreBonusDisplay
- Name: <UserType>k__BackingField
Entry: 7
Data: 19|System.RuntimeType, mscorlib
Data: 20|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.ScoreBonusDisplay, Assembly-CSharp
@@ -306,14 +348,8 @@ MonoBehaviour:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 20|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
Entry: 9
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -418,10 +454,10 @@ MonoBehaviour:
Data: value
- Name: <UserType>k__BackingField
Entry: 9
Data: 4
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,8 @@
#define RECORDING_DEMO
using UdonSharp;
using UnityEngine;
namespace Marro.PacManUdon
{
using System;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Components;
using VRC.SDKBase;
public partial class GameManager : SyncedObject
{
[Header("Static game components")]
@@ -16,39 +11,33 @@ namespace Marro.PacManUdon
[SerializeField] private GhostManager ghostManager;
[SerializeField] private BonusFruit bonusFruit;
[SerializeField] private PelletManager pelletManager;
[SerializeField] public StatusDisplay statusDisplay; // This one is public so other scripts can write to the debug display
[SerializeField] private StatusDisplay statusDisplay;
[SerializeField] private PelletManager attractScreen;
[SerializeField] private GameObject intermissionScreen;
[SerializeField] private GameObject pressStartButtonScreen;
[SerializeField] private PlayerInput playerInput;
[SerializeField] private Animator demo;
[SerializeField] private SoundManager soundManager;
[SerializeField] private NetworkManager networkManager;
[SerializeField] private NetworkManager networkManagerSetup;
[SerializeField] private GameObject recorder;
[Header("Game settings")]
[SerializeField] private int startingExtraLives = 3;
[SerializeField] private int scoreToExtraLife = 10000;
[Tooltip("Override amount of pellets needed to clear stage, set to -1 to disable.")]
[SerializeField] private int pelletCountOverride = -1;
private Maze maze;
private VRCObjectPool pelletPool;
private Intermission2Pole intermission2Pole;
private Animator mazeSpriteAnimator;
private int pelletCountTotal;
private int pelletCountRemaining;
private GameObject[] attractScreenElements;
private GameObject[] intermissionScreenElements;
private PacManGameState gameState;
[UdonSynced, FieldChangeCallback(nameof(Score))] private int score;
[UdonSynced, FieldChangeCallback(nameof(Level))] private int level;
[UdonSynced, FieldChangeCallback(nameof(HighScore))] private int highScore;
[UdonSynced, FieldChangeCallback(nameof(ExtraLives))] private int extraLives;
private int score;
private int level;
private int highScore;
private int extraLives;
public void Start()
{
@@ -65,19 +54,18 @@ namespace Marro.PacManUdon
}
maze = mazes[0];
pelletPool = maze.pelletContainer.GetComponent<VRCObjectPool>();
mazeSpriteAnimator = maze.mazeSprite.GetComponent<Animator>();
intermission2Pole = intermissionScreenElements[4].GetComponent<Intermission2Pole>();
ghostManager.Initialize(maze.ghostTargets, pacMan, this);
pacMan.Initialize(playerInput, pelletPool, this);
networkManager.Initialize();
ghostManager.Initialize(maze.ghostStarts, maze.ghostTargets, pacMan, pelletManager, this);
pacMan.Initialize(playerInput, maze.pacManStart, this);
bonusFruit.Initialize();
pelletManager.Initialize(pelletPool);
pelletManager.Initialize();
statusDisplay.Initialize();
playerInput.Initialize(this);
soundManager.Initialize();
intermission2Pole.Initialize(this, ghostManager.Ghosts[0]);
networkManager.Initialize();
HideEverything();
@@ -90,7 +78,7 @@ namespace Marro.PacManUdon
public override void SyncedUpdate()
{
TimeSequenceUpdate(Time.deltaTime);
TimeSequenceUpdate(networkManager.SyncedDeltaTime);
}
public void JoystickGrabbed()
@@ -114,7 +102,10 @@ namespace Marro.PacManUdon
public void StartGameButtonPressed()
{
Debug.Log($"{gameObject} Start Game Button was pressed!");
TakeOwnership();
if (networkManager.IsOwner)
{
networkManager.SendEventNow(NetworkEventType.StartGameButtonPressed);
}
StartTimeSequence(PacManTimeSequence.StartNewGame);
}
@@ -142,27 +133,20 @@ namespace Marro.PacManUdon
{
Debug.Log($"{gameObject} New level started!");
pelletCountTotal = pelletPool.Pool.Length;
pelletCountRemaining = pelletCountTotal;
ghostManager.SetPelletsRemaining(pelletCountRemaining);
ghostManager.NewLevel();
pelletManager.RestoreAllPellets();
if (pelletCountOverride > 0)
{
pelletCountRemaining = pelletCountOverride;
}
ghostManager.NewLevel();
mazeSpriteAnimator.SetBool("Blinking", false);
}
private void RestartLevel()
private void RestartLevel(bool afterLifeLost = false)
{
Debug.Log($"{gameObject} (Re)started level!");
// SetInGameComponentVisibility(true);
ghostManager.Reset();
ghostManager.RestartLevel(afterLifeLost);
pacMan.Reset();
bonusFruit.Despawn();
soundManager.Reset();
@@ -176,36 +160,40 @@ namespace Marro.PacManUdon
SetFrozen(true);
}
public void GotPellet(bool addScore = true)
public void GotPellet(Pellet pellet, bool addScore = true)
{
pelletCountRemaining--;
var pelletCollectedCount = pelletManager.PelletCollected(pellet);
if (addScore) AddScore(10);
ghostManager.PelletConsumed();
soundManager.PlayPelletSound();
var pelletCountRemaining = pelletManager.PelletCount - pelletCollectedCount;
soundManager.UpdatePelletCount(pelletCountRemaining);
int pelletsConsumed = pelletCountTotal - pelletCountRemaining;
if (pelletCountRemaining <= 0)
{
StartTimeSequence(PacManTimeSequence.BoardClear);
}
else if (pelletsConsumed == 70 || pelletsConsumed == 170)
else if (pelletCollectedCount == 70 || pelletCollectedCount == 170)
{
bonusFruit.Spawn();
}
}
public void GotPowerPellet()
public void GotPowerPellet(Pellet pellet)
{
Debug.Log($"{gameObject} GotPowerPellet");
if (gameState == PacManGameState.AttractMode)
{
TimeSequenceSkipToNextStep();
return;
}
GotPellet(addScore: false);
GotPellet(pellet, addScore: false);
AddScore(50);
ghostManager.SetPowerPellet(true);
pacMan.SetPowerPellet(true);
@@ -227,6 +215,8 @@ namespace Marro.PacManUdon
public void GhostCaught(int scoreBonus)
{
Debug.Log($"{gameObject} GhostCaught");
if (gameState == PacManGameState.AttractMode)
{
TimeSequenceSkipToNextStep();
@@ -240,6 +230,7 @@ namespace Marro.PacManUdon
public void PacManCaught()
{
return;
StartTimeSequence(PacManTimeSequence.PacManCaught);
}
@@ -255,6 +246,8 @@ namespace Marro.PacManUdon
public void Intermission2PoleUpdate()
{
Debug.Log($"{gameObject} Intermission2PoleUpdate");
TimeSequenceSkipToNextStep();
}
@@ -283,7 +276,7 @@ namespace Marro.PacManUdon
void SetPelletsActive(bool active)
{
pelletPool.gameObject.SetActive(active);
pelletManager.gameObject.SetActive(active);
}
void SetMazeVisible(bool visible)
@@ -315,10 +308,6 @@ namespace Marro.PacManUdon
{
// Debug.Log($"{gameObject} State transitioning from {gameState} to {newGameState}");
gameState = newGameState;
if (Networking.IsOwner(gameObject))
{
RequestSerialization();
}
}
private void IncrementLevel()
@@ -348,7 +337,6 @@ namespace Marro.PacManUdon
}
SetScore(this.score + score);
RequestSerialization();
}
void SetScore(int score)
@@ -370,20 +358,12 @@ namespace Marro.PacManUdon
public void DecrementLives()
{
if (!Networking.IsOwner(gameObject))
{
return;
}
// Debug.Log($"{gameObject} Decremented lives from {extraLives} to {extraLives - 1}");
SetExtraLives(extraLives - 1);
}
void IncrementLives()
{
if (!Networking.IsOwner(gameObject))
{
return;
}
// Debug.Log($"{gameObject} Incremented lives from {extraLives} to {extraLives + 1}");
SetExtraLives(extraLives + 1);
}
@@ -414,91 +394,34 @@ namespace Marro.PacManUdon
}
}
void TakeOwnership()
public override void CollectSyncedData(byte[] data, ref int offset, NetworkEventType eventType)
{
Networking.SetOwner(Networking.LocalPlayer, gameObject);
Networking.SetOwner(Networking.LocalPlayer, pacMan.gameObject);
Networking.SetOwner(Networking.LocalPlayer, pelletPool.gameObject);
ghostManager.SetOwner(Networking.LocalPlayer);
//data[offset++] = new byte[] { NetworkManager.Int32ToByte((int)gameState) };
//data[offset++] = BitConverter.GetBytes(currentlyInTimeSequence);
//data[offset++] = new byte[] { NetworkManager.Int32ToByte((int)currentTimeSequence) };
//data[offset++] = BitConverter.GetBytes(timeSequenceSecondsPassed);
}
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType)
public override bool WriteSyncedData(byte[] data, ref int offset, NetworkEventType eventType)
{
data[offset++] = new byte[] { Int32ToByte((int)gameState) };
data[offset++] = BitConverter.GetBytes(currentlyInTimeSequence);
data[offset++] = new byte[] { Int32ToByte((int)currentTimeSequence) };
data[offset++] = BitConverter.GetBytes(timeSequenceProgress);
}
if (eventType == NetworkEventType.StartGameButtonPressed)
{
StartGameButtonPressed();
}
public override bool SetSyncedData(byte[] data, ref int offset, NetworkEventType eventType)
{
SetGameState((PacManGameState)data[offset++]);
//SetGameState((PacManGameState)data[offset++]);
var currentlyInTimeSequence = BitConverter.ToBoolean(data, offset++);
var currentTimeSequence = (PacManTimeSequence)data[offset++];
var timeSequenceProgress = BitConverter.ToSingle(data, offset);
offset += 4;
TimeSequenceSyncWithRemote(currentlyInTimeSequence, currentTimeSequence, timeSequenceProgress);
//var currentlyInTimeSequence = BitConverter.ToBoolean(data, offset++);
//var currentTimeSequence = (PacManTimeSequence)data[offset++];
//var timeSequenceSecondsPassed = BitConverter.ToSingle(data, offset);
//offset += 4;
//TimeSequenceSyncWithRemote(currentlyInTimeSequence, currentTimeSequence, timeSequenceSecondsPassed);
return true;
}
public int ExtraLives
{
set
{
SetExtraLives(value);
}
get => extraLives;
}
public PacManGameState GameState => gameState;
public PacManGameState GameState
{
set
{
SetGameState(value);
}
get => gameState;
}
public bool GhostsScared
{
set
{
}
get => GhostsScared;
}
public int Score
{
set
{
SetScore(value);
}
get => score;
}
public int HighScore
{
set
{
SetHighScore(value);
}
get => score;
}
public int Level
{
set
{
SetLevel(value);
}
get => level;
}
public static byte Int32ToByte(int value) =>
(byte)value;
//byte.Parse(value.ToString()); // This is the only way I could find to cast an int to byte in Udon, a regular cast crashes in runtime...
public int Level => level;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,8 @@
#define RECORDING_DEMO
using System;
using UnityEngine;
namespace Marro.PacManUdon
{
using UdonSharp;
using System;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using VRC.SDK3.Components;
using VRC.Udon.Common.Interfaces;
enum PacManGhostType
{
Caught,
@@ -39,11 +32,14 @@ namespace Marro.PacManUdon
TargetingIdlePosition2
}
[RequireComponent(typeof(Renderer))]
[RequireComponent(typeof(Animator))]
public class Ghost : GridMover
{
[SerializeField] private PacManGhostType ghostType;
[SerializeField] private PacManGhostStartState startState;
// External references
private GhostManager ghostManager;
private Animator animator;
private new Renderer renderer;
@@ -53,41 +49,46 @@ namespace Marro.PacManUdon
private Vector3 startPosition;
private Quaternion startRotation;
private Vector3 startScale;
private Vector2 homePosition;
private Vector2 idlePosition1;
private Vector2 idlePosition2;
private Vector2 cornerPosition;
private bool kinematic;
// Pathfinding
private Vector2 target;
private bool horizontalOnly;
private int housePelletCounterLimit;
private bool inTunnel;
private int rngState;
private bool turnAroundSoon;
private float speed;
// State
private PacManGhostState ghostState;
private bool isScared;
private bool scattering;
private PacManGhostFrozenState frozenState;
// Home
private bool offGrid;
private int housePelletCounter;
private bool housePelletCounterActive;
private int housePelletCounterLimit;
private bool faceInStartingDirectionUntilUnfrozen;
// Cutscene
private bool kinematic;
private bool specialLook;
private bool followingPredefinedPath;
private Vector2[] predefinedPath;
private int predefinedPathIndex;
int rngState;
private Vector2 syncedPosition;
private float speed;
private Vector2 target;
private bool offGrid;
private bool inTunnel;
private PacManGhostState ghostState;
private bool isScared;
private bool scattering;
private PacManGhostFrozenState frozenState;
private bool hideUntilUnfrozen;
private int housePelletCounter;
private bool housePelletCounterActive;
private bool turnAroundSoon;
public bool IsScared => isScared;
public int Index { get; private set; }
public void Initialize(PacMan pacMan, Ghost blinky, Vector2 homePosition, Vector2 idlePosition1, Vector2 idlePosition2, Vector2 cornerPosition)
public void Initialize(PacMan pacMan, Ghost blinky, Transform startTransform, Vector2 homePosition, Vector2 idlePosition1, Vector2 idlePosition2, Vector2 cornerPosition, int index)
{
ghostManager = transform.parent.GetComponent<GhostManager>();
animator = GetComponent<Animator>();
@@ -102,21 +103,18 @@ namespace Marro.PacManUdon
scoreBonusDisplay = transform.Find("ScoreBonusDisplay").gameObject.GetComponent<ScoreBonusDisplay>();
scoreBonusDisplay.Initialize();
startPosition = transform.localPosition;
startRotation = transform.localRotation;
startScale = transform.localScale;
startPosition = startTransform.localPosition;
startRotation = startTransform.localRotation;
frozenState = PacManGhostFrozenState.Frozen;
// Debug.Log($"{gameObject} Begin localScale = {initialScale}");
Index = index;
}
public void Reset()
{
// Debug.Log($"{gameObject} Reset!");
transform.localPosition = startPosition;
transform.localRotation = startRotation;
transform.localScale = startScale;
// Debug.Log($"{gameObject} Reset localScale = {transform.localScale}");
transform.SetLocalPositionAndRotation(startPosition, startRotation);
if (startState == PacManGhostStartState.Outside)
{
@@ -145,39 +143,35 @@ namespace Marro.PacManUdon
faceInStartingDirectionUntilUnfrozen = true;
UpdateAnimator();
RequestSerialization();
// Debug.Log($"{gameObject} reset with state: {state}, target: {target}, offGrid: {offGrid}");
}
public override void SyncedUpdate()
{
if (ghostType == PacManGhostType.Blinky)
{
// ghostManager.gameStateManager.statusDisplay.SetDebugText(2, $"{turnAroundSoon}");
}
if (frozenState == PacManGhostFrozenState.Frozen ||
(frozenState == PacManGhostFrozenState.FrozenIfNotCaught && ((ghostState != PacManGhostState.Returning && ghostState != PacManGhostState.Entering) || hideUntilUnfrozen)))
(frozenState == PacManGhostFrozenState.FrozenIfNotCaught && ghostState != PacManGhostState.Returning && ghostState != PacManGhostState.Entering))
{
return;
}
Vector2 position = GetPosition();
Vector2 nextPosition = GridMoverTools.GetNextPosition(position, direction, speed);
Vector2 nextPosition = GridMoverTools.GetNextPosition(position, direction, speed, networkManager.SyncedDeltaTime);
nextPosition = ProcessNextPosition(position, nextPosition);
SetPosition(nextPosition);
}
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
{
if (turnAroundSoon && ghostState == PacManGhostState.Normal
&& GridMoverTools.CrossesTileBorder(position, nextPosition, direction.x != 0, direction.y != 0))
{
// Debug.Log($"{gameObject} turned around");
SetDirection(direction * -1);
Debug.Log($"{gameObject} turned around to direction {GetDirection()}");
turnAroundSoon = false;
return nextPosition;
}
if (kinematic)
@@ -228,17 +222,23 @@ namespace Marro.PacManUdon
{
target = GetGridTarget(gridPosition);
SetDirection(GetGridDirectionToTargetGreedy(availableDirections, gridPosition, target));
nextPosition = GridMoverTools.GetNextPosition(gridPosition, direction, speed);
nextPosition = GridMoverTools.GetNextPosition(gridPosition, direction, speed, networkManager.SyncedDeltaTime);
// Debug.Log($"GetNextPosition at gridPosition {gridPosition} with direction {direction} and speed {speed} gives nextPosition {nextPosition}");
}
else if (availableDirections.Length == 1 && availableDirections[0] != direction)
{
SetDirection(availableDirections[0]);
nextPosition = GridMoverTools.GetNextPosition(gridPosition, direction, speed);
nextPosition = GridMoverTools.GetNextPosition(gridPosition, direction, speed, networkManager.SyncedDeltaTime);
}
// Debug.Log($"{gameObject} crossed tile center {gridPosition}, new target: {target}, new direction: {direction}");
}
var distance = Vector2.Distance(position, nextPosition);
if (distance > 0.5f)
{
Debug.LogError($"{gameObject} Just jumped by distance {distance}! position: {position}, nextPosition: {nextPosition}, direction: {direction}, offGrid: {offGrid}, ghostState: {ghostState}");
}
return nextPosition;
}
@@ -657,7 +657,7 @@ namespace Marro.PacManUdon
if (reverseDirection && this.scattering != scattering)
{
if (ghostState == PacManGhostState.Normal || ghostState == PacManGhostState.Home || ghostState == PacManGhostState.Exiting
// This is afaik not normal PacMan behaviour, but is needed to accomidate slight timing differences
// This is afaik not normal PacMan behaviour, but is needed to accomidate slight timing differences during the demo
|| ghostState == PacManGhostState.Entering && ghostManager.gameController.GameState == PacManGameState.AttractModeDemo
)
{
@@ -666,7 +666,6 @@ namespace Marro.PacManUdon
}
this.scattering = scattering;
UpdateAnimator();
RequestSerialization();
}
public void SetFrozen(bool frozen, bool ignoreIfCaught = false, bool keepAnimating = false)
@@ -771,17 +770,72 @@ namespace Marro.PacManUdon
return ghostState;
}
public bool IsScared => isScared;
public void SetSpeed(float speed)
{
this.speed = speed;
UpdateAnimator();
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.GhostUpdate)
{
return;
}
data.Append(target, ref index);
data.Append(horizontalOnly, ref index);
data.Append(inTunnel, ref index);
data.Append(rngState, ref index);
data.Append(turnAroundSoon, ref index);
data.Append(speed, ref index);
data.AppendAsByte((int)ghostState, ref index);
data.Append(isScared, ref index);
data.Append(scattering, ref index);
data.AppendAsByte((int)frozenState, ref index);
data.Append(offGrid, ref index);
data.AppendAsByte(housePelletCounter, ref index);
data.Append(housePelletCounterActive, ref index);
data.AppendAsByte(housePelletCounterLimit, ref index);
data.Append(faceInStartingDirectionUntilUnfrozen, ref index);
base.CollectSyncedData(data, ref index, eventType);
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.GhostUpdate)
{
return true;
}
target = data.ReadVector2(ref index);
horizontalOnly = data.ReadBool(ref index);
inTunnel = data.ReadBool(ref index);
rngState = data.ReadInt(ref index);
turnAroundSoon = data.ReadBool(ref index);
Debug.Log($"{gameObject} turnAroundSoon = {turnAroundSoon}");
speed = data.ReadFloat(ref index);
ghostState = (PacManGhostState)data.ReadByte(ref index);
isScared = data.ReadBool(ref index);
scattering = data.ReadBool(ref index);
frozenState = (PacManGhostFrozenState)data.ReadByte(ref index);
offGrid = data.ReadBool(ref index);
housePelletCounter = data.ReadByte(ref index);
housePelletCounterActive = data.ReadBool(ref index);
housePelletCounterLimit = data.ReadByte(ref index);
faceInStartingDirectionUntilUnfrozen = data.ReadBool(ref index);
return base.WriteSyncedData(data, ref index, eventType);
}
void OnTriggerEnter(Collider other)
{
if (Networking.IsOwner(gameObject) && other.gameObject.GetComponent<PacManGhostCollider>())
if (other.gameObject.GetComponent<PacManGhostCollider>())
{
if (isScared)
{
@@ -815,14 +869,5 @@ namespace Marro.PacManUdon
SetInTunnel(false);
}
}
PacManGhostState State
{
set
{
SetState(value);
}
get => ghostState;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,18 @@
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;
private Ghost blinky;
private PelletManager pelletManager;
// Level constants
private float speedDefault;
private float speedScared;
@@ -24,58 +24,59 @@
private int elroy1PelletCount;
private int elroy2PelletCount;
private float powerPelletDuration;
private float[] scatterPattern;
private float pelletTimeoutLimit;
// Power Pellet logic
private bool powerPelletActive;
private float powerPelletDuration;
private float powerPelletCountdown;
private int powerPelletMultiplier;
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;
// Scattering logic
private float scatterCounter;
private float[] scatterPattern;
private int scatterPatternIndex;
// Elroy logic
public int elroyLevel;
private int pelletsRemaining;
// 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;
private bool frozen;
private bool kinematic;
// This should be called once when the game is initialized
public void Initialize(GameObject[] ghostTargets, PacMan pacMan, GameManager gameController)
public void Initialize(Transform[] ghostStarts, Transform[] ghostTargets, PacMan pacMan, PelletManager pelletManager, GameManager gameController)
{
this.gameController = gameController;
this.pelletManager = pelletManager;
ghosts = transform.GetComponentsInChildren<Ghost>(true);
blinky = ghosts[0];
for (int ghostIndex = 0; ghostIndex < ghosts.Length; ghostIndex++)
{
Vector2 homePosition = ghostTargets[0].transform.localPosition;
Vector2 idlePosition1 = ghostTargets[1 + ghostIndex * 3].transform.localPosition;
Vector2 idlePosition2 = ghostTargets[2 + ghostIndex * 3].transform.localPosition;
Vector2 cornerPosition = ghostTargets[3 + ghostIndex * 3].transform.localPosition;
Transform startTransform = ghostStarts[ghostIndex];
Vector2 homePosition = ghostTargets[0].localPosition;
Vector2 idlePosition1 = ghostTargets[1 + ghostIndex * 3].localPosition;
Vector2 idlePosition2 = ghostTargets[2 + ghostIndex * 3].localPosition;
Vector2 cornerPosition = ghostTargets[3 + ghostIndex * 3].localPosition;
ghosts[ghostIndex].Initialize(pacMan, blinky, homePosition, idlePosition1, idlePosition2, cornerPosition);
ghosts[ghostIndex].Initialize(pacMan, blinky, startTransform, homePosition, idlePosition1, idlePosition2, cornerPosition, ghostIndex);
}
}
// This should be called every time the level is reset
public void Reset()
public void RestartLevel(bool afterLifeLost = false)
{
ghostScaredQueue = new DataList();
powerPelletActive = false;
@@ -86,32 +87,31 @@
elroyLevel = 0;
kinematic = false;
if (afterLifeLost)
{
SetSharedPelletCounterActive(true);
}
foreach (Ghost ghost in ghosts)
{
ghost.Reset();
}
SetScattering(true, reverseDirection: false);
RequestSerialization();
}
public void NewLevel()
{
SetSharedPelletCounterActive(false);
UpdateElroyLevel();
foreach (Ghost ghost in ghosts)
{
ghost.ResetHousePelletCounter();
}
}
public void LifeLost()
public override void SyncedUpdate()
{
SetSharedPelletCounterActive(true);
}
public void FixedUpdate()
{
// gameStateManager.statusDisplay.SetDebugText(1, this.blinkCountdown.ToString());
if (frozen || kinematic)
{
return;
@@ -131,7 +131,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}");
@@ -142,7 +142,7 @@
void UpdatePowerPellet()
{
powerPelletCountdown -= Time.deltaTime;
powerPelletCountdown -= networkManager.SyncedDeltaTime;
if (powerPelletCountdown <= 0)
{
gameController.EndPowerPellet(); // End power pellet
@@ -155,7 +155,7 @@
if (blinkingActivated)
{
blinkCountdown -= Time.deltaTime;
blinkCountdown -= networkManager.SyncedDeltaTime;
if (blinkCountdown <= 0)
{
blinkCountdown += blinkCycleRate;
@@ -166,7 +166,8 @@
void UpdatePelletTimeout()
{
pelletTimeout += Time.deltaTime;
pelletTimeout += networkManager.SyncedDeltaTime;
if (pelletTimeout >= pelletTimeoutLimit)
{
pelletTimeout -= pelletTimeoutLimit;
@@ -190,7 +191,10 @@
gameController.GhostCaught(0);
return;
}
// Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
//networkManager.SendEventSoon(NetworkEventType.GhostUpdate);
ghostScaredQueue.Add(ghost);
GhostCaughtExecute(ghost);
}
@@ -312,6 +316,18 @@
public void SetLevel(int level)
{
Debug.Log($"GhostManager: SetLevel {level}");
SetLevelConstants(level);
int[] privatePelletCounterReleaseValues = PacManConstants.GetGhostHousePrivatePelletCounterLimitForLevel(level);
for (int i = 0; i < ghosts.Length; i++)
{
ghosts[i].SetHousePelletCounterLimit(privatePelletCounterReleaseValues[i]);
RestartLevel(); // Reset needed to properly apply level
}
}
private void SetLevelConstants(int level)
{
speedDefault = PacManConstants.GetGhostDefaultSpeedForLevel(level);
speedScared = PacManConstants.GetGhostScaredSpeedForLevel(level);
speedReturn = 15f;
@@ -324,22 +340,6 @@
powerPelletDuration = PacManConstants.GetScaredDurationForLevel(level);
scatterPattern = PacManConstants.GetScatterPatternForLevel(level);
pelletTimeoutLimit = PacManConstants.GetGhostHousePelletTimeoutLimitForLevel(level);
int[] privatePelletCounterReleaseValues = PacManConstants.GetGhostHousePrivatePelletCounterLimitForLevel(level);
for (int i = 0; i < ghosts.Length; i++)
{
ghosts[i].SetHousePelletCounterLimit(privatePelletCounterReleaseValues[i]);
Reset(); // Reset needed to properly apply level
}
}
public void SetOwner(VRCPlayerApi player)
{
Networking.SetOwner(player, gameObject);
foreach (Ghost ghost in ghosts)
{
Networking.SetOwner(player, ghost.gameObject);
}
}
public float GetTargetSpeed(Ghost ghost, PacManGhostState ghostState, bool isScared, bool inTunnel)
@@ -379,7 +379,7 @@
Debug.Log($"{gameObject} SetScattering: {scattering}");
foreach (Ghost ghost in ghosts)
{
if (ghost == blinky && pelletsRemaining <= elroy1PelletCount)
if (ghost == blinky && elroyLevel > 0) // Once blinky is elroy he no longer scatters
{
continue;
}
@@ -387,15 +387,13 @@
}
}
public void SetPelletsRemaining(int pelletsRemaining)
{
this.pelletsRemaining = pelletsRemaining;
UpdateElroyLevel();
}
/// <summary>
/// Whether to use the shared pellet counter for ghost exiting.
/// Should be called before ghosts are reset.
/// </summary>
void SetSharedPelletCounterActive(bool active)
{
// Debug.Log($"{gameObject} SetSharedPelletCounterActive {active}");
Debug.Log($"{gameObject} SetSharedPelletCounterActive {active}");
sharedPelletCounterActive = active;
foreach (Ghost ghost in ghosts)
{
@@ -405,10 +403,10 @@
public void PelletConsumed()
{
SetPelletsRemaining(pelletsRemaining - 1);
pelletTimeout = 0;
UpdateElroyLevel();
if (sharedPelletCounterActive)
{
IncrementSharedPelletCounter();
@@ -422,6 +420,7 @@
void IncrementSharedPelletCounter()
{
sharedPelletCounter++;
//Debug.Log($"Incremented shared pellet counter to {sharedPelletCounter}");
for (int ghostIndex = 0; ghostIndex < sharedPelletCounterReleaseValues.Length; ghostIndex++)
{
Ghost ghost = ghosts[ghostIndex];
@@ -453,10 +452,13 @@
void UpdateElroyLevel()
{
// Debug.Log($"{gameObject} Updating Elroy Level with pelletsRemaining {pelletsRemaining} with elroy2PelletCount {elroy2PelletCount} and elroy1PelletCount {elroy1PelletCount}");
int oldElroyLevel = elroyLevel;
var oldElroyLevel = elroyLevel;
var pelletsRemaining = pelletManager.PelletCount - pelletManager.PelletCollectedCount;
if (pelletsRemaining < elroy2PelletCount) elroyLevel = 2;
else if (pelletsRemaining < elroy1PelletCount) elroyLevel = 1;
else elroyLevel = 0;
if (elroyLevel != oldElroyLevel)
{
blinky.SetElroy(elroyLevel);
@@ -481,6 +483,106 @@
}
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.GhostUpdate)
{
return;
}
// Power Pellet logic
data.Append(powerPelletActive, ref index);
data.Append(powerPelletCountdown, ref index);
data.AppendAsByte(powerPelletMultiplier, ref index);
// Blink logic
data.Append(blinkingActivated, ref index);
data.Append(blinkCountdown, ref index);
data.Append(blinkCurrentlyWhite, ref index);
// Scattering logic
data.Append(scatterCounter, ref index);
data.AppendAsByte(scatterPatternIndex, ref index);
// Elroy logic
data.AppendAsByte(elroyLevel, ref index);
// Ghost house logic
data.Append(sharedPelletCounterActive, ref index);
data.AppendAsByte(sharedPelletCounter, ref index);
data.Append(pelletTimeout, ref index);
data.Append(frozen, ref index);
data.Append(kinematic, ref index);
data.AppendAsByte(gameController.Level, ref index);
var ghostScaredQueueArray = new byte[ghosts.Length];
for (int i = 0; i < ghostScaredQueueArray.Length; i++)
{
var add = ghostScaredQueue.TryGetValue(i, out var ghost);
if (!add)
{
ghostScaredQueueArray[i] = byte.MaxValue; // Add a terminator
break;
}
ghostScaredQueueArray[i] = (byte)((Ghost)ghost.Reference).Index;
}
Debug.Log($"{gameObject} Sent a ghostScareQueue of length {ghostScaredQueue.Count}");
data.Append(ghostScaredQueueArray, ref index);
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.GhostUpdate)
{
return true;
}
// Power Pellet logic
powerPelletActive = data.ReadBool(ref index);
powerPelletCountdown = data.ReadFloat(ref index);
powerPelletMultiplier = data.ReadByte(ref index);
// Blink logic
blinkingActivated = data.ReadBool(ref index);
blinkCountdown = data.ReadFloat(ref index);
blinkCurrentlyWhite = data.ReadBool(ref index);
// Scattering logic
scatterCounter = data.ReadFloat(ref index);
scatterPatternIndex = data.ReadByte(ref index);
// Elroy logic
elroyLevel = data.ReadByte(ref index);
// Ghost house logic
sharedPelletCounterActive = data.ReadBool(ref index);
sharedPelletCounter = data.ReadByte(ref index);
pelletTimeout = data.ReadFloat(ref index);
frozen = data.ReadBool(ref index);
kinematic = data.ReadBool(ref index);
var level = data.ReadByte(ref index);
SetLevelConstants(level);
ghostScaredQueue.Clear();
for (int i = 0; i < ghosts.Length; i++)
{
var ghostIndex = data[index + i];
if (ghostIndex > ghosts.Length) // Reached terminator
{
break;
}
ghostScaredQueue.Add(ghosts[ghostIndex]);
}
index += ghosts.Length;
Debug.Log($"{gameObject} Read back a ghostScareQueue of length {ghostScaredQueue.Count}");
return true;
}
public Ghost[] Ghosts
{
get => ghosts;

View File

@@ -1,9 +1,7 @@
namespace Marro.PacManUdon
{
using System;
using UdonSharp;
using UnityEngine;
using VRC.Udon.Serialization.OdinSerializer;
public abstract class GridMover : SyncedObject
{
@@ -32,22 +30,16 @@ namespace Marro.PacManUdon
protected abstract void UpdateAnimator();
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType)
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
var position = GetPosition();
data[offset++] = BitConverter.GetBytes(position.x);
data[offset++] = BitConverter.GetBytes(position.y);
var direction = GetDirection();
data[offset++] = BitConverter.GetBytes(direction.x);
data[offset++] = BitConverter.GetBytes(direction.y);
data.Append(GetPosition(), ref index);
data.Append(GetDirection(), ref index);
}
public override bool SetSyncedData(byte[] data, ref int offset, NetworkEventType eventType)
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
SetPosition(new Vector2(BitConverter.ToSingle(data, offset), BitConverter.ToSingle(data, offset + 2)));
SetDirection(new Vector2(BitConverter.ToSingle(data, offset + 4), BitConverter.ToSingle(data, offset + 6)));
offset += 8;
SetPosition(data.ReadVector2(ref index));
SetDirection(data.ReadVector2(ref index));
return true;
}

View File

@@ -5,9 +5,9 @@ namespace Marro.PacManUdon
public static class GridMoverTools
{
public static Vector2 GetNextPosition(Vector2 currentPosition, Vector2 direction, float speed)
public static Vector2 GetNextPosition(Vector2 currentPosition, Vector2 direction, float speed, float deltaTime)
{
return currentPosition + direction * speed * Time.deltaTime;
return currentPosition + direction * speed * deltaTime;
}
public static Vector2 PositionToGrid(Vector2 position)

View File

@@ -43,31 +43,37 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 4
Data: 5
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _animator
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _animator
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -79,10 +85,10 @@ MonoBehaviour:
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -103,31 +109,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _gameManager
Data: _animator
- Name: $v
Entry: 7
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _gameManager
Data: _animator
- Name: <UserType>k__BackingField
Entry: 7
Data: 6|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
Data: UnityEngine.Animator, UnityEngine.AnimationModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -163,25 +163,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _ghost
Data: _gameManager
- Name: $v
Entry: 7
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ghost
Data: _gameManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 10|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Ghost, Assembly-CSharp
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -217,16 +217,70 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _lastUpdate
Data: _ghost
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _lastUpdate
Data: _ghost
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Ghost, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _lastUpdate
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _lastUpdate
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.PoleStrechLevels, Assembly-CSharp
@@ -235,7 +289,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 14|System.RuntimeType, mscorlib
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
@@ -256,7 +310,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0

View File

@@ -2,6 +2,7 @@
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using static Cinemachine.DocumentationSortingAttribute;
namespace Marro.PacManUdon
{
@@ -15,7 +16,7 @@ namespace Marro.PacManUdon
}
[RequireComponent(typeof(Animator))]
public class Intermission2Pole : UdonSharpBehaviour
public class Intermission2Pole : SyncedObject
{
Animator _animator;
@@ -34,6 +35,7 @@ namespace Marro.PacManUdon
_ghost = ghost;
_gameManager = gameManager;
_animator = GetComponent<Animator>();
SetActive(false); // Should only activate for intermission 2
Reset();
}
@@ -43,7 +45,13 @@ namespace Marro.PacManUdon
SetStrechLevel(PoleStrechLevels.None);
}
public void FixedUpdate()
public void SetActive(bool isActive)
{
Debug.Log($"({nameof(PacManUdon)} {nameof(Intermission2Pole)}) SetActive {isActive}.");
gameObject.SetActive(isActive);
}
public override void SyncedUpdate()
{
if (!_ghost.gameObject.activeInHierarchy)
{
@@ -107,6 +115,7 @@ namespace Marro.PacManUdon
public void SetStrechLevel(PoleStrechLevels level)
{
Debug.Log($"({nameof(PacManUdon)} {nameof(Intermission2Pole)}) Set strech level to {level}.");
_animator.SetFloat("Strech", GetAnimatorValueForStrechLevel(level));
}
@@ -134,5 +143,15 @@ namespace Marro.PacManUdon
{
return (Vector2)transform.localPosition;
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
return true;
}
}
}

View File

@@ -43,7 +43,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 4
Data: 6
- Name:
Entry: 7
Data:
@@ -109,19 +109,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: ghostTargets
Data: pelletContainer
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: ghostTargets
Data: pelletContainer
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.GameObject[], UnityEngine.CoreModule
Data: UnityEngine.GameObject, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -169,25 +169,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: pelletContainer
Data: mazeSprite
- Name: $v
Entry: 7
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletContainer
Data: mazeSprite
- Name: <UserType>k__BackingField
Entry: 7
Data: 11|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.GameObject, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
Entry: 9
Data: 7
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -202,13 +196,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 13|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 12|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -229,19 +223,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: mazeSprite
Data: ghostTargets
- Name: $v
Entry: 7
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: mazeSprite
Data: ghostTargets
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
Entry: 7
Data: 14|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Transform[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
Data: 14
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -278,6 +278,120 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: ghostStarts
- Name: $v
Entry: 7
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: ghostStarts
- Name: <UserType>k__BackingField
Entry: 9
Data: 14
- Name: <SystemType>k__BackingField
Entry: 9
Data: 14
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 19|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: pacManStart
- Name: $v
Entry: 7
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pacManStart
- Name: <UserType>k__BackingField
Entry: 7
Data: 21|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Transform, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 21
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 23|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:

View File

@@ -1,15 +1,15 @@
namespace Marro.PacManUdon
{
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using UdonSharp;
using UnityEngine;
namespace Marro.PacManUdon
{
public class Maze : UdonSharpBehaviour
{
[SerializeField] public Vector2 mazeBoundaries;
[SerializeField] public GameObject[] ghostTargets;
[SerializeField] public GameObject pelletContainer;
[SerializeField] public GameObject mazeSprite;
[SerializeField] public Transform[] ghostTargets;
[SerializeField] public Transform[] ghostStarts;
[SerializeField] public Transform pacManStart;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -43,31 +43,37 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 22
Data: 20
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: direction
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: direction
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Vector2, UnityEngine.CoreModule
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -79,10 +85,10 @@ MonoBehaviour:
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -103,31 +109,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: gameController
Data: direction
- Name: $v
Entry: 7
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: gameController
Data: direction
- Name: <UserType>k__BackingField
Entry: 7
Data: 6|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
Data: UnityEngine.Vector2, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -163,25 +163,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: input
Data: gameController
- Name: $v
Entry: 7
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: input
Data: gameController
- Name: <UserType>k__BackingField
Entry: 7
Data: 10|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.PlayerInput, Assembly-CSharp
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -217,25 +217,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: defaultSpeed
Data: input
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: defaultSpeed
Data: input
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
Data: Marro.PacManUdon.PlayerInput, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -271,19 +271,73 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: powerPelletSpeed
Data: defaultSpeed
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: defaultSpeed
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: powerPelletSpeed
- Name: $v
Entry: 7
Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: powerPelletSpeed
- Name: <UserType>k__BackingField
Entry: 9
Data: 13
Data: 16
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
Data: 16
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -298,7 +352,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -322,70 +376,16 @@ MonoBehaviour:
Data: speed
- Name: $v
Entry: 7
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: speed
- Name: <UserType>k__BackingField
Entry: 9
Data: 13
Data: 16
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: startPosition
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startPosition
- Name: <UserType>k__BackingField
Entry: 7
Data: 20|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Vector3, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 20
Data: 16
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -421,19 +421,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: startRotation
Data: startPosition
- Name: $v
Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startRotation
Data: startPosition
- Name: <UserType>k__BackingField
Entry: 7
Data: 23|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Quaternion, UnityEngine.CoreModule
Data: UnityEngine.Vector3, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -475,19 +475,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: startScale
Data: startRotation
- Name: $v
Entry: 7
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startScale
Data: startRotation
- Name: <UserType>k__BackingField
Entry: 9
Data: 20
Entry: 7
Data: 26|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Quaternion, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 20
Data: 26
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -502,7 +508,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -526,13 +532,13 @@ MonoBehaviour:
Data: animator
- Name: $v
Entry: 7
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: animator
- Name: <UserType>k__BackingField
Entry: 7
Data: 28|System.RuntimeType, mscorlib
Data: 29|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
@@ -541,7 +547,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 28
Data: 29
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -556,7 +562,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -580,13 +586,13 @@ MonoBehaviour:
Data: renderer
- Name: $v
Entry: 7
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: renderer
- Name: <UserType>k__BackingField
Entry: 7
Data: 31|System.RuntimeType, mscorlib
Data: 32|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Renderer, UnityEngine.CoreModule
@@ -595,7 +601,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 31
Data: 32
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -610,61 +616,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: pelletPool
- Name: $v
Entry: 7
Data: 33|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletPool
- Name: <UserType>k__BackingField
Entry: 7
Data: 34|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCObjectPool, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 34
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 33|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -688,13 +640,13 @@ MonoBehaviour:
Data: hideUntilUnfrozen
- Name: $v
Entry: 7
Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: hideUntilUnfrozen
- Name: <UserType>k__BackingField
Entry: 7
Data: 37|System.RuntimeType, mscorlib
Data: 35|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
@@ -703,7 +655,55 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 37
Data: 35
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 36|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: dead
- Name: $v
Entry: 7
Data: 37|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: dead
- Name: <UserType>k__BackingField
Entry: 9
Data: 35
- Name: <SystemType>k__BackingField
Entry: 9
Data: 35
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -739,19 +739,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: dead
Data: kinematic
- Name: $v
Entry: 7
Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: dead
Data: kinematic
- Name: <UserType>k__BackingField
Entry: 9
Data: 37
Data: 35
- Name: <SystemType>k__BackingField
Entry: 9
Data: 37
Data: 35
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -787,19 +787,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: kinematic
Data: followingPredefinedPath
- Name: $v
Entry: 7
Data: 41|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: kinematic
Data: followingPredefinedPath
- Name: <UserType>k__BackingField
Entry: 9
Data: 37
Data: 35
- Name: <SystemType>k__BackingField
Entry: 9
Data: 37
Data: 35
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -835,64 +835,16 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: followingPredefinedPath
Data: predefinedPath
- Name: $v
Entry: 7
Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: followingPredefinedPath
- Name: <UserType>k__BackingField
Entry: 9
Data: 37
- Name: <SystemType>k__BackingField
Entry: 9
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 44|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: predefinedPath
- Name: $v
Entry: 7
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPath
- Name: <UserType>k__BackingField
Entry: 7
Data: 46|System.RuntimeType, mscorlib
Data: 44|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Vector2[], UnityEngine.CoreModule
@@ -901,7 +853,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 46
Data: 44
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -916,7 +868,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 47|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 45|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -940,13 +892,13 @@ MonoBehaviour:
Data: predefinedPathIndex
- Name: $v
Entry: 7
Data: 48|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 46|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPathIndex
- Name: <UserType>k__BackingField
Entry: 7
Data: 49|System.RuntimeType, mscorlib
Data: 47|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
@@ -955,7 +907,55 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 49
Data: 47
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 48|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: targetDirection
- Name: $v
Entry: 7
Data: 49|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: targetDirection
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -991,19 +991,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: syncedPosition
Data: freezeSeconds
- Name: $v
Entry: 7
Data: 51|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: syncedPosition
Data: freezeSeconds
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
Data: 16
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 16
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1039,19 +1039,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: targetDirection
Data: frozen
- Name: $v
Entry: 7
Data: 53|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: targetDirection
Data: frozen
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
Data: 35
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 35
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1082,102 +1082,6 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: freezeSeconds
- Name: $v
Entry: 7
Data: 55|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: freezeSeconds
- Name: <UserType>k__BackingField
Entry: 9
Data: 13
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 56|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: frozen
- Name: $v
Entry: 7
Data: 57|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: frozen
- Name: <UserType>k__BackingField
Entry: 9
Data: 37
- Name: <SystemType>k__BackingField
Entry: 9
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 58|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:

View File

@@ -1,12 +1,10 @@
namespace Marro.PacManUdon
using System;
using UnityEngine;
namespace Marro.PacManUdon
{
using System;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using VRC.SDK3.Components;
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Renderer))]
public class PacMan : GridMover
{
private GameManager gameController;
@@ -16,10 +14,8 @@
private float speed;
private Vector3 startPosition;
private Quaternion startRotation;
private Vector3 startScale;
private Animator animator;
new Renderer renderer;
private VRCObjectPool pelletPool;
private bool hideUntilUnfrozen;
private bool dead;
private bool kinematic;
@@ -28,12 +24,11 @@
private Vector2[] predefinedPath;
private int predefinedPathIndex;
private Vector2 syncedPosition;
private Vector2 targetDirection;
private float freezeSeconds;
private bool frozen;
#region Animator constants
#region Animator constants
private const string AnimatorKeyDead = "Dead";
private const string AnimatorKeyDirection = "Direction";
private const float AnimatorDirectionNone = 0f;
@@ -42,29 +37,24 @@
private const float AnimatorDirectionUp = 0.75f;
private const float AnimatorDirectionDown = 1f;
private const float AnimatorDirectionRightBig = 1.25f;
#endregion
#endregion
public void Initialize(PlayerInput input, VRCObjectPool pelletPool, GameManager gameController)
public void Initialize(PlayerInput input, Transform startTransform, GameManager gameController)
{
this.gameController = gameController;
this.input = input;
this.pelletPool = pelletPool;
animator = GetComponent<Animator>();
renderer = GetComponent<Renderer>();
frozen = false;
hideUntilUnfrozen = false;
startPosition = transform.localPosition;
startRotation = transform.localRotation;
startScale = transform.localScale;
startPosition = startTransform.localPosition;
startRotation = startTransform.localRotation;
}
public void Reset()
{
// Debug.Log($"{gameObject} Reset!");
transform.localPosition = startPosition;
transform.localRotation = startRotation;
transform.localScale = startScale;
transform.SetLocalPositionAndRotation(startPosition, startRotation);
direction = Vector2.left;
targetDirection = Vector2.left;
speed = defaultSpeed;
@@ -73,6 +63,8 @@
SetDead(false);
animator.SetTrigger("Reset");
Debug.Log($"{gameObject} Reset! Position is now {GetPosition()}.");
}
public override void SyncedUpdate()
@@ -93,10 +85,10 @@
float speed = this.speed;
if (freezeSeconds > 0)
{
float freezePart = freezeSeconds / Time.deltaTime;
float freezePart = freezeSeconds / networkManager.SyncedDeltaTime;
if (freezePart >= 1)
{
freezeSeconds -= Time.deltaTime;
freezeSeconds -= networkManager.SyncedDeltaTime;
animator.speed = 0;
return;
}
@@ -110,7 +102,7 @@
}
Vector2 position = GetPosition();
Vector2 nextPosition = GridMoverTools.GetNextPosition(position, direction, speed); // The position pacman will move to, assuming it doens't get changed
Vector2 nextPosition = GridMoverTools.GetNextPosition(position, direction, speed, networkManager.SyncedDeltaTime); // The position pacman will move to, assuming it doens't get changed
if (!kinematic)
{
@@ -145,23 +137,21 @@
// Debug.Log($"{gameObject} crossed Y tile center from {currentPosition} with targetDirection {targetDirection}, nextPosition is now {nextPosition} and direction is now {direction}");
}
if (Networking.IsOwner(gameObject))
{
Vector2 inputDirection = input.GetDirection();
if (!inputDirection.Equals(Vector2.zero) && !inputDirection.Equals(targetDirection) // Ignore neutral input or input in our current direction
&& (inputDirection.x == 0 || (Math.Round(nextPosition.y, 5) - 0.5) % 1 != 0) && (inputDirection.y == 0 || (Math.Round(nextPosition.x, 5) - 0.5) % 1 != 0) // Target grid position near the edge of a tile may not be correct, ignore inputs near the border
&& !GridMoverTools.CheckCollisionInDirection(transform, nextPosition, inputDirection))
{ // Check if the requested direction does not have a wall
if (inputDirection.x != 0)
{ // Move in the requested direction, as well as perpundicular to it to get to the center of the tunnel
SetDirection(inputDirection + new Vector2(0, GridMoverTools.PositionToGrid(nextPosition).y - nextPosition.y).normalized);
}
else
{
SetDirection(inputDirection + new Vector2(GridMoverTools.PositionToGrid(nextPosition).x - nextPosition.x, 0).normalized);
}
SetTargetDirection(inputDirection); // This is the direction most logic should assume pacman is moving, the actual direction may be different due to cornering
Vector2 inputDirection = input.GetDirection();
if (!inputDirection.Equals(Vector2.zero) && !inputDirection.Equals(targetDirection) // Ignore neutral input or input in our current direction
&& (inputDirection.x == 0 || (Math.Round(nextPosition.y, 5) - 0.5) % 1 != 0) && (inputDirection.y == 0 || (Math.Round(nextPosition.x, 5) - 0.5) % 1 != 0) // Target grid position near the edge of a tile may not be correct, ignore inputs near the border
&& !GridMoverTools.CheckCollisionInDirection(transform, nextPosition, inputDirection))
{ // Check if the requested direction does not have a wall
if (inputDirection.x != 0)
{ // Move in the requested direction, as well as perpundicular to it to get to the center of the tunnel
SetDirection(inputDirection + new Vector2(0, GridMoverTools.PositionToGrid(nextPosition).y - nextPosition.y).normalized);
}
else
{
SetDirection(inputDirection + new Vector2(GridMoverTools.PositionToGrid(nextPosition).x - nextPosition.x, 0).normalized);
}
SetTargetDirection(inputDirection); // This is the direction most logic should assume pacman is moving, the actual direction may be different due to cornering
networkManager.SendEventSoon(NetworkEventType.PacManTurn);
}
return nextPosition;
@@ -211,7 +201,7 @@
// Debug.Log($"{gameObject} UpdateAnimator with direction {direction}, dead {dead}, frozen {frozen}");
if (!gameObject.activeInHierarchy)
return;
animator.SetBool(AnimatorKeyDead, dead);
if (dead)
{
@@ -326,32 +316,46 @@
Pellet pellet = other.gameObject.GetComponent<Pellet>();
if (pellet)
{
if (Networking.IsOwner(gameObject))
{
pelletPool.Return(pellet.gameObject);
}
else
{
pellet.pelletRenderer.enabled = false;
pellet.gameObject.SetActive(false);
}
if (pellet.isPowerPellet)
{
gameController.GotPowerPellet();
gameController.GotPowerPellet(pellet);
freezeSeconds = 0.05f;
}
else
{
gameController.GotPellet();
gameController.GotPellet(pellet);
freezeSeconds = 0.0166666666666667f;
}
return;
}
else if (Networking.IsOwner(gameObject) && other.gameObject.GetComponent<BonusFruit>())
else if (other.gameObject.GetComponent<BonusFruit>())
{
gameController.GotFruit();
}
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.PacManTurn || kinematic || frozen || !enabled)
{
return;
}
data.Append(targetDirection, ref index);
base.CollectSyncedData(data, ref index, eventType);
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.PacManTurn || kinematic || frozen || !enabled)
{
return true;
}
SetTargetDirection(data.ReadVector2(ref index));
return base.WriteSyncedData(data, ref index, eventType);
}
}
}

View File

@@ -85,13 +85,7 @@ MonoBehaviour:
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 5|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:
@@ -112,13 +106,13 @@ MonoBehaviour:
Data: pelletRenderer
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletRenderer
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
Data: 6|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Renderer, UnityEngine.CoreModule
@@ -127,7 +121,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 6
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -142,7 +136,7 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 7|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0

View File

@@ -3,9 +3,10 @@
using UdonSharp;
using UnityEngine;
[RequireComponent(typeof(Renderer))]
public class Pellet : UdonSharpBehaviour
{
[SerializeField] public bool isPowerPellet = false;
public bool isPowerPellet = false;
public Renderer pelletRenderer;
void Start()

View File

@@ -43,25 +43,25 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 8
Data: 9
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: pellets
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pellets
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Pellet[], Assembly-CSharp
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
@@ -70,7 +70,7 @@ MonoBehaviour:
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Component[], UnityEngine.CoreModule
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
@@ -91,13 +91,7 @@ MonoBehaviour:
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:
@@ -115,25 +109,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: pelletPool
Data: <PelletCollectedCount>k__BackingField
- Name: $v
Entry: 7
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletPool
Data: <PelletCollectedCount>k__BackingField
- Name: <UserType>k__BackingField
Entry: 7
Data: 8|System.RuntimeType, mscorlib
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCObjectPool, VRCSDK3
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -148,7 +142,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -169,25 +163,31 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: pelletRenderers
Data: pellets
- Name: $v
Entry: 7
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletRenderers
Data: pellets
- Name: <UserType>k__BackingField
Entry: 7
Data: 11|System.RuntimeType, mscorlib
Data: 10|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Renderer[], UnityEngine.CoreModule
Data: Marro.PacManUdon.Pellet[], Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
Entry: 7
Data: 11|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Component[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -476,6 +476,60 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: syncedPelletsCollected
- Name: $v
Entry: 7
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: syncedPelletsCollected
- Name: <UserType>k__BackingField
Entry: 7
Data: 27|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Byte[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 27
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:

View File

@@ -1,61 +1,43 @@
namespace Marro.PacManUdon
using System;
using UnityEngine;
namespace Marro.PacManUdon
{
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Components;
using VRC.SDKBase;
using VRC.Udon;
public class PelletManager : UdonSharpBehaviour
public class PelletManager : SyncedObject
{
[SerializeField] Pellet[] pellets;
VRCObjectPool pelletPool;
Renderer[] pelletRenderers;
Animator[] powerPellets;
public int PelletCount => pellets.Length;
public int PelletCollectedCount { get; private set; }
Pellet[] pellets;
Animator[] powerPellets;
bool powerPelletBlinkEnabled;
float powerPelletBlinkToggleInterval;
float powerPelletBlinkProgress;
bool powerPelletBlinkCurrentlyVisible;
public void Initialize(VRCObjectPool pelletPool)
{
gameObject.SetActive(true);
this.pelletPool = pelletPool;
pelletRenderers = new Renderer[pelletPool.Pool.Length];
for (int i = 0; i < pelletRenderers.Length; i++)
{
pelletRenderers[i] = pelletPool.Pool[i].GetComponent<Renderer>();
}
powerPellets = GetComponentsInChildren<Animator>(true);
// Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}");
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
SetPowerPelletsBlink(false);
}
byte[] syncedPelletsCollected;
public void Initialize()
{
pelletRenderers = new Renderer[pellets.Length];
for (int i = 0; i < pelletRenderers.Length; i++)
{
pelletRenderers[i] = pellets[i].GetComponent<Renderer>();
}
gameObject.SetActive(true);
pellets = GetComponentsInChildren<Pellet>(includeInactive: true);
powerPellets = GetComponentsInChildren<Animator>(true);
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
SetPowerPelletsBlink(false);
RestoreAllPellets();
}
void Update()
public override void SyncedUpdate()
{
if (!powerPelletBlinkEnabled)
{
return;
}
powerPelletBlinkProgress += Time.deltaTime;
powerPelletBlinkProgress += networkManager.SyncedDeltaTime;
if (powerPelletBlinkProgress >= powerPelletBlinkToggleInterval)
{
// Debug.Log($"{gameObject} PowerPelletBlink toggle");
@@ -89,20 +71,63 @@
powerPelletBlinkEnabled = !frozen;
}
public void RestoreAllPellets()
public int PelletCollected(Pellet pellet)
{
foreach (GameObject pellet in pelletPool.Pool)
pellet.gameObject.SetActive(false);
var index = pellet.transform.GetSiblingIndex();
syncedPelletsCollected[index/8] |= (byte)(1 << index%8);
PelletCollectedCount++;
return PelletCollectedCount;
}
public int RestoreAllPellets()
{
foreach (var pellet in pellets)
{
if (pelletPool.TryToSpawn() == false)
{
break;
}
pellet.gameObject.SetActive(true);
}
foreach (Renderer pelletRenderer in pelletRenderers)
syncedPelletsCollected = new byte[pellets.Length/8 + 1];
PelletCollectedCount = 0;
return PelletCount;
}
private void SetPelletsCollectedFromSync()
{
for (int i = 0; i < pellets.Length; i++)
{
pelletRenderer.enabled = true;
var active = (syncedPelletsCollected[i/8] & (byte)(1 << i%8)) == 0;
pellets[i].gameObject.SetActive(active);
}
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.SyncPellets)
{
return;
}
data.Append((byte)PelletCollectedCount, ref index);
data.Append(syncedPelletsCollected, ref index);
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType != NetworkEventType.SyncPellets)
{
return true;
}
PelletCollectedCount = data.ReadByte(ref index);
Array.Copy(data, index, syncedPelletsCollected, 0, syncedPelletsCollected.Length);
index += syncedPelletsCollected.Length;
SetPelletsCollectedFromSync();
return true;
}
}
}

View File

@@ -43,7 +43,67 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 3
Data: 4
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
@@ -52,13 +112,13 @@ MonoBehaviour:
Data: animator
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: animator
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
@@ -67,7 +127,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -82,7 +142,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -106,13 +166,13 @@ MonoBehaviour:
Data: countdownSeconds
- Name: $v
Entry: 7
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: countdownSeconds
- Name: <UserType>k__BackingField
Entry: 7
Data: 6|System.RuntimeType, mscorlib
Data: 10|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
@@ -121,7 +181,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 6
Data: 10
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -136,7 +196,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 7|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -160,13 +220,13 @@ MonoBehaviour:
Data: countingDown
- Name: $v
Entry: 7
Data: 8|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: countingDown
- Name: <UserType>k__BackingField
Entry: 7
Data: 9|System.RuntimeType, mscorlib
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
@@ -175,7 +235,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 9
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -190,7 +250,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 10|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0

View File

@@ -1,11 +1,9 @@
namespace Marro.PacManUdon
{
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using UnityEngine;
public class ScoreBonusDisplay : UdonSharpBehaviour
namespace Marro.PacManUdon
{
[RequireComponent(typeof(Animator))]
public class ScoreBonusDisplay : SyncedObject
{
private Animator animator;
private float countdownSeconds;
@@ -18,11 +16,11 @@
gameObject.SetActive(false);
}
void Update()
public override void SyncedUpdate()
{
if (countingDown)
{
countdownSeconds -= Time.deltaTime;
countdownSeconds -= networkManager.SyncedDeltaTime;
if (countdownSeconds <= 0)
{
Hide();
@@ -48,5 +46,15 @@
countingDown = false;
gameObject.SetActive(false);
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
return true;
}
}
}

View File

@@ -92,7 +92,7 @@ namespace Marro.PacManUdon
pacMan.SetPosition(attractScreenElements[16].transform.localPosition);
pacMan.SetDirection(Vector2.left);
ghostManager.Reset();
ghostManager.RestartLevel();
ghostManager.SetLevel(2);
ghostManager.SetKinematic(true);
ghostManager.SetActive(true);

View File

@@ -19,6 +19,7 @@ namespace Marro.PacManUdon
case 1:
// Show pole
SetIntermissionScreenVisible(true);
intermission2Pole.SetActive(true);
intermission2Pole.Reset();
break;
case 2:

View File

@@ -13,7 +13,7 @@ namespace Marro.PacManUdon
break;
case 1:
// Make maze visible
RestartLevel();
RestartLevel(afterLifeLost: true);
SetMazeVisible(true);
break;
case 2:
@@ -42,7 +42,7 @@ namespace Marro.PacManUdon
SetFrozen(false);
soundManager.SuppressSound(false);
soundManager.StartGhostSound();
soundManager.UpdatePelletCount(pelletCountRemaining);
soundManager.UpdatePelletCount(pelletManager.PelletCount - pelletManager.PelletCollectedCount);
}
}
}

View File

@@ -1,5 +1,3 @@
using UnityEngine;
namespace Marro.PacManUdon
{
public partial class GameManager

View File

@@ -18,6 +18,7 @@ namespace Marro.PacManUdon
// Increment level, show ready, show pellets, show lives indicators
IncrementLevel();
statusDisplay.SetExtraLivesDisplayVisible(true);
statusDisplay.SetLevelDisplayVisible(true);
statusDisplay.SetReadyTextVisible(true);
SetPelletsActive(true);
break;

View File

@@ -1,7 +1,4 @@
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.SDK3.Data;
namespace Marro.PacManUdon
{
@@ -15,7 +12,7 @@ namespace Marro.PacManUdon
bool waitingForTimeSequenceFinalize;
bool jumpingToTimeSequence;
PacManTimeSequence currentTimeSequence;
[UdonSynced] float timeSequenceSecondsPassed;
float timeSequenceSecondsPassed;
int timeSequenceProgress;
float[] timeSequenceKeyframeTimes;
@@ -42,6 +39,7 @@ namespace Marro.PacManUdon
{
jumpingToTimeSequence = true;
TimeSequenceProgressToTime(100000f);
Debug.LogWarning($"{gameObject} TimeSequenceEndCurrent");
TryFinalizeTimeSequence();
jumpingToTimeSequence = false;
}
@@ -58,7 +56,7 @@ namespace Marro.PacManUdon
private void TimeSequenceSkipToNextStep()
{
// Debug.Log($"{gameObject} TimeSequenceSkipToNextStep");
Debug.Log($"{gameObject} TimeSequenceSkipToNextStep");
if (timeSequenceProgress < timeSequenceKeyframeTimes.Length)
{
TimeSequenceProgressToTime(timeSequenceKeyframeTimes[timeSequenceProgress]);
@@ -89,18 +87,19 @@ namespace Marro.PacManUdon
private void TimeSequencePrepareForFinish(PacManTimeSequence timeSequence)
{
if (Networking.IsOwner(gameObject))
//if (networkManager.IsOwner)
//{
Debug.LogWarning($"{gameObject} TimeSequencePrepareForFinish");
TimeSequenceExecuteFinalize(timeSequence);
if (!jumpingToTimeSequence)
{
TimeSequenceExecuteFinalize(timeSequence);
if (!jumpingToTimeSequence)
{
TimeSequenceExecuteFinished(timeSequence);
}
}
else
{
waitingForTimeSequenceFinalize = true;
TimeSequenceExecuteFinished(timeSequence);
}
//}
//else
//{
// waitingForTimeSequenceFinalize = true;
//}
}
private void TryFinalizeTimeSequence()
@@ -114,29 +113,29 @@ namespace Marro.PacManUdon
waitingForTimeSequenceFinalize = false;
}
private void TimeSequenceSyncWithRemote(bool currentlyInTimeSequence, PacManTimeSequence currentTimeSequence, float timeSequenceProgress)
{
// If the remote is in a time sequence but we're not, or we're in a different time sequence, jump to the remote's time sequence.
if (currentlyInTimeSequence && (!this.currentlyInTimeSequence || currentTimeSequence != this.currentTimeSequence))
{
StartTimeSequence(currentTimeSequence);
}
//private void TimeSequenceSyncWithRemote(bool currentlyInTimeSequence, PacManTimeSequence currentTimeSequence, float timeSequenceSecondsPassed)
//{
// // If the remote is in a time sequence but we're not, or we're in a different time sequence, jump to the remote's time sequence.
// if (currentlyInTimeSequence && (!this.currentlyInTimeSequence || currentTimeSequence != this.currentTimeSequence))
// {
// StartTimeSequence(currentTimeSequence);
// }
// If we're (now) in a time sequence, jump our progress to match the one on the remote
if (this.currentlyInTimeSequence)
{
TimeSequenceProgressToTime(timeSequenceProgress);
}
// // If we're (now) in a time sequence, jump our progress to match the one on the remote
// if (this.currentlyInTimeSequence)
// {
// TimeSequenceProgressToTime(timeSequenceSecondsPassed);
// }
// If the remote has finished it's time sequence and we have one waiting to be finalized, we can do so now
if (!currentlyInTimeSequence)
{
TryFinalizeTimeSequence();
}
}
// // If the remote has finished it's time sequence and we have one waiting to be finalized, we can do so now
// if (!currentlyInTimeSequence)
// {
// TryFinalizeTimeSequence();
// }
//}
#region Events
public void JumpToTimeSequenceAttractScreenIntroduction()
{
StartTimeSequence(PacManTimeSequence.AttractScreenIntroduction);
@@ -245,7 +244,7 @@ namespace Marro.PacManUdon
private void TimeSequenceExecuteStep(PacManTimeSequence timeSequence, int sequenceProgress)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
switch (timeSequence)
{
default:
@@ -299,7 +298,7 @@ namespace Marro.PacManUdon
private void TimeSequenceExecuteFinalize(PacManTimeSequence timeSequence)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
Debug.Log($"{gameObject} Triggered time sequence finalize for sequence {currentTimeSequence}");
switch (timeSequence)
{
default:
@@ -343,7 +342,7 @@ namespace Marro.PacManUdon
private void TimeSequenceExecuteFinished(PacManTimeSequence timeSequence)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
Debug.Log($"{gameObject} Triggered time sequence finished for sequence {currentTimeSequence}");
switch (timeSequence)
{
default:
@@ -447,16 +446,5 @@ namespace Marro.PacManUdon
}
#endregion
public int TimeSequenceProgress
{
get => timeSequenceProgress;
}
public float TimeSequenceSecondsPassed
{
get => timeSequenceSecondsPassed;
set => TimeSequenceProgressToTime(value);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,11 @@

using Marro.PacManUdon;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class SoundManager : UdonSharpBehaviour
public class SoundManager : SyncedObject
{
[SerializeField] private AudioSource audioSourcePacMan;
[SerializeField] private AudioSource audioSourceGhosts;
@@ -252,4 +253,14 @@ public class SoundManager : UdonSharpBehaviour
return siren0;
};
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
return true;
}
}

View File

@@ -49,25 +49,31 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: scoreDisplayGroup
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: scoreDisplayGroup
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Transform, UnityEngine.CoreModule
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -82,16 +88,10 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 5|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:
@@ -109,19 +109,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: label1UPText
Data: scoreDisplayGroup
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: label1UPText
Data: scoreDisplayGroup
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TMPro.TMP_Text, Unity.TextMeshPro
Data: UnityEngine.Transform, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -169,19 +169,79 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: score1UPText
Data: label1UPText
- Name: $v
Entry: 7
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: label1UPText
- Name: <UserType>k__BackingField
Entry: 7
Data: 11|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TMPro.TMP_Text, Unity.TextMeshPro
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 13|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: score1UPText
- Name: $v
Entry: 7
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: score1UPText
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -196,13 +256,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 12|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 16|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -226,16 +286,16 @@ MonoBehaviour:
Data: labelHighScoreText
- Name: $v
Entry: 7
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: labelHighScoreText
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -250,13 +310,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 15|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 19|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -280,16 +340,16 @@ MonoBehaviour:
Data: scoreHighScoreText
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: scoreHighScoreText
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -304,13 +364,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 18|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 22|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -334,16 +394,16 @@ MonoBehaviour:
Data: debugText
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: debugText
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -358,13 +418,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 21|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 25|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -388,16 +448,16 @@ MonoBehaviour:
Data: debugText2
- Name: $v
Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: debugText2
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -412,13 +472,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 24|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 28|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -442,16 +502,16 @@ MonoBehaviour:
Data: gameOverText
- Name: $v
Entry: 7
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 29|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: gameOverText
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -466,13 +526,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 27|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 31|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -496,16 +556,16 @@ MonoBehaviour:
Data: player1Text
- Name: $v
Entry: 7
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 32|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: player1Text
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -520,13 +580,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 33|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 30|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 34|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -550,16 +610,16 @@ MonoBehaviour:
Data: readyText
- Name: $v
Entry: 7
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: readyText
- Name: <UserType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 7
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -574,13 +634,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 36|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 33|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 37|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -604,16 +664,16 @@ MonoBehaviour:
Data: levelDisplayDigitsContainer
- Name: $v
Entry: 7
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: levelDisplayDigitsContainer
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -628,13 +688,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 36|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 40|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -658,16 +718,16 @@ MonoBehaviour:
Data: extraLifeIndicatorsContainer
- Name: $v
Entry: 7
Data: 37|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 41|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: extraLifeIndicatorsContainer
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -682,13 +742,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 38|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 42|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 39|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 43|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -712,13 +772,13 @@ MonoBehaviour:
Data: levelDisplayDigitAnimators
- Name: $v
Entry: 7
Data: 40|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 44|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: levelDisplayDigitAnimators
- Name: <UserType>k__BackingField
Entry: 7
Data: 41|System.RuntimeType, mscorlib
Data: 45|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator[], UnityEngine.AnimationModule
@@ -727,7 +787,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 41
Data: 45
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -742,7 +802,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 42|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 46|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -766,13 +826,13 @@ MonoBehaviour:
Data: levelDisplayDigitRenderers
- Name: $v
Entry: 7
Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 47|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: levelDisplayDigitRenderers
- Name: <UserType>k__BackingField
Entry: 7
Data: 44|System.RuntimeType, mscorlib
Data: 48|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Renderer[], UnityEngine.CoreModule
@@ -781,7 +841,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 44
Data: 48
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -796,7 +856,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 45|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 49|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -820,13 +880,13 @@ MonoBehaviour:
Data: extraLifeIndicators
- Name: $v
Entry: 7
Data: 46|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 50|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: extraLifeIndicators
- Name: <UserType>k__BackingField
Entry: 7
Data: 47|System.RuntimeType, mscorlib
Data: 51|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.GameObject[], UnityEngine.CoreModule
@@ -835,7 +895,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 47
Data: 51
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -850,7 +910,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 48|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 52|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -874,13 +934,13 @@ MonoBehaviour:
Data: label1UPVisible
- Name: $v
Entry: 7
Data: 49|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 53|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: label1UPVisible
- Name: <UserType>k__BackingField
Entry: 7
Data: 50|System.RuntimeType, mscorlib
Data: 54|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
@@ -889,7 +949,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 50
Data: 54
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -904,7 +964,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 51|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 55|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -928,16 +988,16 @@ MonoBehaviour:
Data: label1UPTextBlinking
- Name: $v
Entry: 7
Data: 52|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 56|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: label1UPTextBlinking
- Name: <UserType>k__BackingField
Entry: 9
Data: 50
Data: 54
- Name: <SystemType>k__BackingField
Entry: 9
Data: 50
Data: 54
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -952,7 +1012,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 53|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 57|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -973,16 +1033,16 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: labelBlinkToggleInterval
Data: labelBlinkTimer
- Name: $v
Entry: 7
Data: 54|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 58|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: labelBlinkToggleInterval
Data: labelBlinkTimer
- Name: <UserType>k__BackingField
Entry: 7
Data: 55|System.RuntimeType, mscorlib
Data: 59|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
@@ -991,7 +1051,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 55
Data: 59
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1006,55 +1066,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 56|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: labelBlinkTimer
- Name: $v
Entry: 7
Data: 57|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: labelBlinkTimer
- Name: <UserType>k__BackingField
Entry: 9
Data: 55
- Name: <SystemType>k__BackingField
Entry: 9
Data: 55
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 58|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 60|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0

View File

@@ -1,12 +1,9 @@
namespace Marro.PacManUdon
{
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using TMPro;
using UnityEngine;
using TMPro;
public class StatusDisplay : UdonSharpBehaviour
namespace Marro.PacManUdon
{
public class StatusDisplay : SyncedObject
{
[SerializeField] private Transform scoreDisplayGroup;
[SerializeField] private TMP_Text label1UPText;
@@ -28,7 +25,7 @@
private bool label1UPVisible;
private bool label1UPTextBlinking;
private float labelBlinkToggleInterval = 0.26666667f;
private const float labelBlinkToggleInterval = 0.26666667f;
private float labelBlinkTimer;
public void Initialize()
@@ -53,11 +50,11 @@
SetLabel1UPTextBlinking(false);
}
void Update()
public override void SyncedUpdate()
{
if (label1UPTextBlinking)
{
labelBlinkTimer += Time.deltaTime;
labelBlinkTimer += networkManager.SyncedDeltaTime;
if (labelBlinkTimer > labelBlinkToggleInterval)
{
labelBlinkTimer -= labelBlinkToggleInterval;
@@ -169,5 +166,15 @@
levelDisplayDigitAnimators[i].SetFloat("FruitType", PacManConstants.FruitTypeToValue(PacManConstants.GetFruitTypeForLevel(level - i)));
}
}
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
}
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
return true;
}
}
}

View File

@@ -6,8 +6,10 @@ namespace Marro.PacManUdon
{
public abstract class SyncedObject : UdonSharpBehaviour
{
public abstract void SyncedUpdate();
public abstract void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType);
public abstract bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType);
public NetworkManager networkManager;
public virtual void SyncedUpdate() { }
public abstract void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType);
public abstract bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType);
}
}

14
Assets/Scripts/Test.cs Normal file
View File

@@ -0,0 +1,14 @@
namespace Marro.PacManUdon
{
using UdonSharp;
using UnityEngine;
public class Test : UdonSharpBehaviour
{
[SerializeField] Pellet pellet;
public void Start()
{
Debug.Log(pellet.enabled);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0227a738d77ab0849bdc9047b5b27c78
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

118
Assets/Scripts/Test1.asset Normal file
View File

@@ -0,0 +1,118 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: Test1
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 6457f9f1332ac0742bdff23291631f30, type: 2}
udonAssembly:
assemblyError:
sourceCsScript: {fileID: 11500000, guid: 0227a738d77ab0849bdc9047b5b27c78, type: 3}
scriptVersion: 2
compiledVersion: 2
behaviourSyncMode: 0
hasInteractEvent: 0
scriptID: -4571266787425106669
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes:
- Name: fieldDefinitions
Entry: 7
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
UdonSharp.Editor]], mscorlib
- Name: comparer
Entry: 7
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
mscorlib]], mscorlib
- Name:
Entry: 8
Data:
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: pellet
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pellet
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Pellet, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 184e93443ec1bb24fa4e1db8b51405da
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -49,16 +49,76 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: start
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: start
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: start
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: start
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Transform, UnityEngine.CoreModule
@@ -67,7 +127,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -82,13 +142,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 5|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 9|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -112,16 +172,16 @@ MonoBehaviour:
Data: end
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: end
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -136,13 +196,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 7|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 8|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 12|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -166,13 +226,13 @@ MonoBehaviour:
Data: mode
- Name: $v
Entry: 7
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: mode
- Name: <UserType>k__BackingField
Entry: 7
Data: 10|System.RuntimeType, mscorlib
Data: 14|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: TestBallMode, Assembly-CSharp
@@ -181,7 +241,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 11|System.RuntimeType, mscorlib
Data: 15|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
@@ -202,13 +262,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 13|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 17|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -227,66 +287,6 @@ MonoBehaviour:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: networkManager
- Name: $v
Entry: 7
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 15|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: sumOfDt
@@ -400,10 +400,10 @@ MonoBehaviour:
Data: loopOffset
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
Data: 19
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
Data: 19
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -502,10 +502,10 @@ MonoBehaviour:
Data: jumpsIndex
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
Data: 15
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
Data: 15
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib

View File

@@ -22,17 +22,15 @@ public class TestBall : SyncedObject
[SerializeField] private TestBallMode mode;
private NetworkManager networkManager;
private const int LoopTimeMs = 1000;
private const float LoopTime = 1f;
private const float MaxUp = 0.7f;
private const float UpPerPress = 0.4f;
private const float DownPerSecond = 1;
private const float DownPerSecond = 1f;
private float sumOfDt;
private float amountUp = 0;
private int loopOffset = 0;
private float loopOffset = 0;
private float[] jumps;
private int jumpsIndex;
@@ -40,16 +38,21 @@ public class TestBall : SyncedObject
public void Initialize(NetworkManager networkManager)
{
this.networkManager = networkManager;
sumOfDt = networkManager.SyncedTime;
amountUp = 0;
loopOffset = 0;
jumps = new float[10];
jumpsIndex = 0;
}
public override void SyncedUpdate()
{
SetProgress(GetProgress()); // A quick test that these methods work correctly
DeltaUp(-DownPerSecond * networkManager.Dt);
DeltaUp(-DownPerSecond * networkManager.SyncedDeltaTime);
UpdateProgress();
@@ -78,25 +81,25 @@ public class TestBall : SyncedObject
private void SetProgress(float progress)
{
var currentTimestamp = GetCurrentTimestamp();
loopOffset = (int)(currentTimestamp - progress * LoopTimeMs);
loopOffset = (currentTimestamp - progress) * LoopTime;
}
private float GetProgress()
{
var currentTimestamp = GetCurrentTimestamp();
//Debug.Log($"CurrentTimeStamp for mode {mode}: {currentTimestamp}");
return ((int)currentTimestamp - loopOffset) % LoopTimeMs / (float)LoopTimeMs; // "uint % int" is not exposed, I love working in Udon
return (currentTimestamp - loopOffset) % LoopTime / LoopTime;
}
private uint GetCurrentTimestamp()
private float GetCurrentTimestamp()
{
switch (mode)
{
case TestBallMode.UseNetworkTime:
return NetworkManager.TimeToTimestamp(networkManager.SyncedTime);
return networkManager.SyncedTime;
case TestBallMode.UseNetworkDt:
case TestBallMode.UseUnityDt:
return NetworkManager.TimeToTimestamp(sumOfDt);
return sumOfDt;
default:
Debug.LogError($"({nameof(TestBall)}) Unknown mode {mode}!");
return 0;
@@ -108,7 +111,7 @@ public class TestBall : SyncedObject
switch (mode)
{
case TestBallMode.UseNetworkDt:
sumOfDt += networkManager.Dt;
sumOfDt += networkManager.SyncedDeltaTime;
break;
case TestBallMode.UseUnityDt:
if (!networkManager.IsEventUpdate)
@@ -125,29 +128,31 @@ public class TestBall : SyncedObject
Debug.Log($"({nameof(TestBall)}) Up button pressed, jumped up at {GetProgress()} to {amountUp}.");
}
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType)
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType == 0)
if (eventType == NetworkEventType.FullSync
|| eventType == NetworkEventType.FullSyncForced)
{
Debug.Log($"({nameof(TestBall)}) Sending sync data at progress {GetProgress()} and amountUp {amountUp}.");
data[index++] = BitConverter.GetBytes(amountUp);
data[index++] = BitConverter.GetBytes(GetProgress());
data.Append(amountUp, ref index);
data.Append(GetProgress(), ref index);
}
}
public override bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType)
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType == 0)
if (eventType == NetworkEventType.FullSync
|| eventType == NetworkEventType.FullSyncForced)
{
amountUp = BitConverter.ToSingle(data, index);
SetProgress(BitConverter.ToSingle(data, index + 4));
Debug.Log($"({nameof(TestBall)}) Received sync event, synced to progress {GetProgress()} and amountUp {amountUp}.");
index += 8;
amountUp = data.ReadFloat(ref index);
SetProgress(data.ReadFloat(ref index));
//Debug.Log($"({nameof(TestBall)}) Received sync event, synced to progress {GetProgress()} and amountUp {amountUp}.");
}
else
{
//Debug.Log($"({nameof(TestBall)}) Received up event, jumped up at {GetProgress()} from {amountUp}.");
Jump();
Debug.Log($"({nameof(TestBall)}) Received up event, jumped up at {GetProgress()} to {amountUp}.");
//Debug.Log($"({nameof(TestBall)}) Received up event, jumped up at {GetProgress()} to {amountUp}.");
}
return true;

View File

@@ -49,18 +49,22 @@ public class TestBallManager : UdonSharpBehaviour
testBall.UpButtonPressed();
}
networkManager.SendEvent((NetworkEventType)1);
networkManager.SendEventSoon(NetworkEventType.PacManTurn);
}
public void SyncButtonPressed()
{
if (VRCPlayerApi.GetPlayerCount() == 1)
{
networkManager.SimulateSyncToTimestamp(NetworkManager.TimeToTimestamp(networkManager.SyncedTime - 0.5f));
networkManager.SimulateSyncToTimestamp(networkManager.SyncedTime - 0.5f);
}
else if (networkManager.IsOwner)
{
networkManager.SendEventSoon(NetworkEventType.FullSync);
}
else
{
networkManager.SendEvent((NetworkEventType)0);
networkManager.RequestEvent(NetworkEventType.FullSync);
}
}
}

View File

@@ -207,4 +207,6 @@ QualitySettings:
excludedTargetPlatforms:
- Standalone
m_TextureMipmapLimitGroupNames: []
m_PerPlatformDefaultQuality: {}
m_PerPlatformDefaultQuality:
Server: 0
Standalone: 0