Cleaning a bit

This commit is contained in:
2026-01-14 19:37:37 +01:00
parent 65b153f97d
commit 4922a91a04
6 changed files with 34 additions and 46 deletions

View File

@@ -1,14 +1,15 @@
namespace Marro.PacManUdon using UdonSharp;
{ using UnityEngine;
using UdonSharp; using VRC.SDK3.Data;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDKBase;
using VRC.Udon;
namespace Marro.PacManUdon
{
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Renderer))]
[RequireComponent(typeof(Collider))]
public class BonusFruit : UdonSharpBehaviour public class BonusFruit : UdonSharpBehaviour
{ {
[SerializeField, UdonSynced, FieldChangeCallback(nameof(FruitType))] PacManFruitType fruitType; PacManFruitType fruitType;
Animator animator; Animator animator;
new Renderer renderer; new Renderer renderer;
@@ -67,7 +68,6 @@
this.fruitType = fruitType; this.fruitType = fruitType;
value = (int)fruitScoreValue[PacManConstants.FruitTypeToValue(fruitType)]; value = (int)fruitScoreValue[PacManConstants.FruitTypeToValue(fruitType)];
animator.SetFloat("FruitType", PacManConstants.FruitTypeToValue(fruitType)); animator.SetFloat("FruitType", PacManConstants.FruitTypeToValue(fruitType));
RequestSerialization();
} }
public void SetFrozen(bool frozen) public void SetFrozen(bool frozen)
@@ -80,7 +80,6 @@
renderer.enabled = active; renderer.enabled = active;
collider.enabled = active; collider.enabled = active;
this.active = active; this.active = active;
RequestSerialization();
} }
public PacManFruitType FruitType public PacManFruitType FruitType
@@ -101,7 +100,7 @@
get => active; get => active;
} }
private DataDictionary fruitScoreValue = new DataDictionary() private readonly DataDictionary fruitScoreValue = new DataDictionary()
{ {
{(int)PacManFruitType.None , 0}, {(int)PacManFruitType.None , 0},
{(int)PacManFruitType.Cherries , 100}, {(int)PacManFruitType.Cherries , 100},
@@ -113,6 +112,5 @@
{(int)PacManFruitType.Bell , 3000}, {(int)PacManFruitType.Bell , 3000},
{(int)PacManFruitType.Key , 5000} {(int)PacManFruitType.Key , 5000}
}; };
} }
} }

View File

@@ -315,10 +315,6 @@ namespace Marro.PacManUdon
{ {
// Debug.Log($"{gameObject} State transitioning from {gameState} to {newGameState}"); // Debug.Log($"{gameObject} State transitioning from {gameState} to {newGameState}");
gameState = newGameState; gameState = newGameState;
if (Networking.IsOwner(gameObject))
{
RequestSerialization();
}
} }
private void IncrementLevel() private void IncrementLevel()
@@ -348,7 +344,6 @@ namespace Marro.PacManUdon
} }
SetScore(this.score + score); SetScore(this.score + score);
RequestSerialization();
} }
void SetScore(int score) void SetScore(int score)

View File

@@ -145,7 +145,6 @@ namespace Marro.PacManUdon
faceInStartingDirectionUntilUnfrozen = true; faceInStartingDirectionUntilUnfrozen = true;
UpdateAnimator(); UpdateAnimator();
RequestSerialization();
// Debug.Log($"{gameObject} reset with state: {state}, target: {target}, offGrid: {offGrid}"); // Debug.Log($"{gameObject} reset with state: {state}, target: {target}, offGrid: {offGrid}");
} }
@@ -666,7 +665,6 @@ namespace Marro.PacManUdon
} }
this.scattering = scattering; this.scattering = scattering;
UpdateAnimator(); UpdateAnimator();
RequestSerialization();
} }
public void SetFrozen(bool frozen, bool ignoreIfCaught = false, bool keepAnimating = false) public void SetFrozen(bool frozen, bool ignoreIfCaught = false, bool keepAnimating = false)

View File

@@ -92,7 +92,6 @@
} }
SetScattering(true, reverseDirection: false); SetScattering(true, reverseDirection: false);
RequestSerialization();
} }
public void NewLevel() public void NewLevel()

View File

@@ -1,12 +1,12 @@
namespace Marro.PacManUdon using System;
{ using UnityEngine;
using System; using VRC.SDK3.Components;
using UdonSharp; using VRC.SDKBase;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using VRC.SDK3.Components;
namespace Marro.PacManUdon
{
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Renderer))]
public class PacMan : GridMover public class PacMan : GridMover
{ {
private GameManager gameController; private GameManager gameController;
@@ -28,12 +28,11 @@
private Vector2[] predefinedPath; private Vector2[] predefinedPath;
private int predefinedPathIndex; private int predefinedPathIndex;
private Vector2 syncedPosition;
private Vector2 targetDirection; private Vector2 targetDirection;
private float freezeSeconds; private float freezeSeconds;
private bool frozen; private bool frozen;
#region Animator constants #region Animator constants
private const string AnimatorKeyDead = "Dead"; private const string AnimatorKeyDead = "Dead";
private const string AnimatorKeyDirection = "Direction"; private const string AnimatorKeyDirection = "Direction";
private const float AnimatorDirectionNone = 0f; private const float AnimatorDirectionNone = 0f;
@@ -42,7 +41,7 @@
private const float AnimatorDirectionUp = 0.75f; private const float AnimatorDirectionUp = 0.75f;
private const float AnimatorDirectionDown = 1f; private const float AnimatorDirectionDown = 1f;
private const float AnimatorDirectionRightBig = 1.25f; private const float AnimatorDirectionRightBig = 1.25f;
#endregion #endregion
public void Initialize(PlayerInput input, VRCObjectPool pelletPool, GameManager gameController) public void Initialize(PlayerInput input, VRCObjectPool pelletPool, GameManager gameController)
@@ -62,8 +61,7 @@
public void Reset() public void Reset()
{ {
// Debug.Log($"{gameObject} Reset!"); // Debug.Log($"{gameObject} Reset!");
transform.localPosition = startPosition; transform.SetLocalPositionAndRotation(startPosition, startRotation);
transform.localRotation = startRotation;
transform.localScale = startScale; transform.localScale = startScale;
direction = Vector2.left; direction = Vector2.left;
targetDirection = Vector2.left; targetDirection = Vector2.left;

View File

@@ -15,7 +15,7 @@ namespace Marro.PacManUdon
bool waitingForTimeSequenceFinalize; bool waitingForTimeSequenceFinalize;
bool jumpingToTimeSequence; bool jumpingToTimeSequence;
PacManTimeSequence currentTimeSequence; PacManTimeSequence currentTimeSequence;
[UdonSynced] float timeSequenceSecondsPassed; float timeSequenceSecondsPassed;
int timeSequenceProgress; int timeSequenceProgress;
float[] timeSequenceKeyframeTimes; float[] timeSequenceKeyframeTimes;