Pellet sync

This commit is contained in:
2026-01-18 17:47:07 +01:00
parent eef7084e21
commit c3a19cc53e
12 changed files with 1933 additions and 747 deletions

View File

@@ -26,15 +26,11 @@ namespace Marro.PacManUdon
[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 Intermission2Pole intermission2Pole;
private Animator mazeSpriteAnimator;
private int pelletCountTotal;
private int pelletCountRemaining;
private GameObject[] attractScreenElements;
private GameObject[] intermissionScreenElements;
@@ -63,7 +59,7 @@ namespace Marro.PacManUdon
intermission2Pole = intermissionScreenElements[4].GetComponent<Intermission2Pole>();
networkManager.Initialize();
ghostManager.Initialize(maze.ghostStarts, maze.ghostTargets, pacMan, this);
ghostManager.Initialize(maze.ghostStarts, maze.ghostTargets, pacMan, pelletManager, this);
pacMan.Initialize(playerInput, maze.pacManStart, this);
bonusFruit.Initialize();
pelletManager.Initialize();
@@ -138,27 +134,20 @@ namespace Marro.PacManUdon
{
Debug.Log($"{gameObject} New level started!");
pelletCountTotal = pelletManager.PelletCount;
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.Reset(afterLifeLost);
pacMan.Reset();
bonusFruit.Despawn();
soundManager.Reset();
@@ -172,29 +161,31 @@ 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");
@@ -203,7 +194,7 @@ namespace Marro.PacManUdon
TimeSequenceSkipToNextStep();
return;
}
GotPellet(addScore: false);
GotPellet(pellet, addScore: false);
AddScore(50);
ghostManager.SetPowerPellet(true);
pacMan.SetPowerPellet(true);