Fixed ghost caught queue

This commit is contained in:
2026-06-22 13:11:00 +02:00
parent cb975c24b2
commit e431dab042
9 changed files with 199 additions and 228 deletions

View File

@@ -33,8 +33,6 @@ namespace Marro.PacManUdon
private float powerPelletCountdown;
private int powerPelletMultiplier;
private DataList ghostScaredQueue;
// Blink logic
private const float blinkCycleRate = 0.233333333f;
private bool blinkingActivated;
@@ -80,7 +78,6 @@ namespace Marro.PacManUdon
public void RestartLevel(bool afterLifeLost = false)
{
ghostScaredQueue = new DataList();
powerPelletActive = false;
scatterCounter = 0;
scatterPatternIndex = 0;
@@ -186,7 +183,7 @@ namespace Marro.PacManUdon
}
}
public void GhostCaughtQueue(Ghost ghost)
public void GhostCaught(Ghost ghost)
{
if (gameController.GameState == PacManGameState.AttractMode)
{
@@ -194,34 +191,6 @@ namespace Marro.PacManUdon
return;
}
// Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
//networkManager.SendEventSoon(NetworkEventType.TimeSequenceSync);
//networkManager.SendEventSoon(NetworkEventType.GhostUpdate);
ghostScaredQueue.Add(ghost);
GhostCaughtExecute(ghost);
}
public void GhostCaughtContinue()
{
// Debug.Log($"{gameObject} GhostCaughtContinue with ghost queue length {ghostScaredQueue.Count}");
if (!ghostScaredQueue.TryGetValue(0, out DataToken currentGhost))
{
Debug.LogError("Called GhostCaughtContinue without a ghost in the queue!");
return;
}
((Ghost)currentGhost.Reference).ReturnHome();
ghostScaredQueue.RemoveAt(0);
if (ghostScaredQueue.TryGetValue(0, out DataToken nextGhost))
{
GhostCaughtExecute((Ghost)nextGhost.Reference);
}
}
void GhostCaughtExecute(Ghost ghost)
{
int scoreBonus = 200 * (int)Math.Pow(2, powerPelletMultiplier);
powerPelletMultiplier += 1;
ghost.Caught(scoreBonus);
@@ -518,20 +487,6 @@ namespace Marro.PacManUdon
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)
@@ -569,19 +524,6 @@ namespace Marro.PacManUdon
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;
}