Cleaning up

This commit is contained in:
2025-12-26 18:14:48 +01:00
parent 16b0a348e4
commit f53a41f70c
13 changed files with 66 additions and 52 deletions

View File

@@ -44,14 +44,14 @@
public void Spawn()
{
Debug.Log($"{gameObject} Spawned");
// Debug.Log($"{gameObject} Spawned");
SetActive(true);
activeCountdown = Random.Range(9, 10);
}
public void Despawn()
{
Debug.Log($"{gameObject} Despawned");
// Debug.Log($"{gameObject} Despawned");
SetActive(false);
}

View File

@@ -558,10 +558,10 @@ namespace Marro.PacManUdon
}
}
void UpdateSpeed()
public void UpdateSpeed()
{
speed = ghostManager.GetTargetSpeed(this, ghostState, isScared, inTunnel);
Debug.Log($"Ghost updated speed to {speed}, level: {ghostManager.elroyLevel}");
// Debug.Log($"Ghost with type {ghostType} updated speed to {speed}, ghostState: {ghostState}, isScared: {isScared}, inTunnel: {inTunnel}, elroyLevel: {ghostManager.elroyLevel}");
}
public void ResetHousePelletCounter()
@@ -695,14 +695,10 @@ namespace Marro.PacManUdon
}
animator.speed = frozen && !keepAnimating ? 0 : 1; // This would cause issues if the returning sprite was animated, luckily it isn't :)
if (frozen == false)
if (frozen == false && faceInStartingDirectionUntilUnfrozen)
{
if (faceInStartingDirectionUntilUnfrozen)
{
faceInStartingDirectionUntilUnfrozen = false;
UpdateAnimator();
}
faceInStartingDirectionUntilUnfrozen = false;
UpdateAnimator();
}
}

View File

@@ -190,14 +190,14 @@
gameController.GhostCaught(0);
return;
}
Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
// Debug.Log($"{gameObject} GhostCaughtQueue with ghost {ghost}");
ghostScaredQueue.Add(ghost);
GhostCaughtExecute(ghost);
}
public void GhostCaughtContinue()
{
Debug.Log($"{gameObject} GhostCaughtContinue with ghost queue length {ghostScaredQueue.Count}");
// 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!");
@@ -326,9 +326,10 @@
pelletTimeoutLimit = PacManConstants.GetGhostHousePelletTimeoutLimitForLevel(level);
int[] privatePelletCounterReleaseValues = PacManConstants.GetGhostHousePrivatePelletCounterLimitForLevel(level);
for (int i = 0; i < Math.Min(sharedPelletCounterReleaseValues.Length, ghosts.Length); i++)
for (int i = 0; i < ghosts.Length; i++)
{
ghosts[i].SetHousePelletCounterLimit(privatePelletCounterReleaseValues[i]);
ghosts[i].Reset(); // Reset needed to properly apply level
}
}

View File

@@ -8,18 +8,18 @@ namespace Marro.PacManUdon
{
public virtual Vector2 GetPosition()
{
Debug.LogWarning($"{gameObject} does not implement GetPosition");
Debug.LogError($"{gameObject} does not implement GetPosition");
return Vector2.zero;
}
public virtual void SetPosition(Vector2 position)
{
Debug.LogWarning($"{gameObject} does not implement SetPosition");
Debug.LogError($"{gameObject} does not implement SetPosition");
}
public virtual Vector2 GetDirection()
{
Debug.LogWarning($"{gameObject} does not implement GetDirection");
Debug.LogError($"{gameObject} does not implement GetDirection");
return Vector2.zero;
}
}

View File

@@ -101,14 +101,12 @@ namespace Marro.PacManUdon
if (level == PoleStrechLevels.Strech1 || level == PoleStrechLevels.Separated) // Step forward timed procedure
{
Debug.Log($"Intermission2Pole Intermission2PoleUpdate");
_gameManager.Intermission2PoleUpdate();
}
}
public void SetStrechLevel(PoleStrechLevels level)
{
Debug.Log($"Intermission2Pole SetStrechLevel {level}");
_animator.SetFloat("Strech", GetAnimatorValueForStrechLevel(level));
}

View File

@@ -30,7 +30,7 @@
}
powerPellets = GetComponentsInChildren<Animator>(true);
Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}");
// Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}");
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
SetPowerPelletsBlink(false);
}

View File

@@ -21,7 +21,7 @@ namespace Marro.PacManUdon
soundManager.PlayDeathSound();
break;
case 3:
// Hide pacman, start next state
// Hide pacman
SetPacManActive(false);
break;
}

View File

@@ -25,22 +25,12 @@ namespace Marro.PacManUdon
break;
case 1:
// Show maze, lives indicator, level indicator, player 1 and ready text
// SOMEWHERE IN HERE UNITY (EDITOR) APPEARS TO HAVE A SMALL RANDOM CHANCE OF CRASHING !!
Debug.Log("Log dump in case of crash");
Debug.Log("Setting pellets visible");
SetPelletsActive(true);
Debug.Log("Setting maze visible");
SetMazeVisible(true);
Debug.Log("Setting extra lives display visible");
statusDisplay.SetExtraLivesDisplayVisible(true);
Debug.Log("Setting level display visible");
statusDisplay.SetLevelDisplayVisible(true);
Debug.Log("Setting player 1 text visible");
statusDisplay.SetPlayer1TextVisible(true);
Debug.Log("Setting ready text visible");
statusDisplay.SetReadyTextVisible(true);
Debug.Log("Starting 1UP blink");
statusDisplay.SetLabel1UPTextBlinking(true);
break;
case 2:

View File

@@ -12,7 +12,6 @@ namespace Marro.PacManUdon
RestartLevel();
SetMazeVisible(true);
statusDisplay.SetScoreDisplayVisible(true);
soundManager.SuppressSound(false);
break;
case 1:
// Increment level, show ready, show pellets, show lives indicators
@@ -39,6 +38,7 @@ namespace Marro.PacManUdon
{
// Unfreeze
SetFrozen(false);
soundManager.SuppressSound(false);
soundManager.StartGhostSound();
}
}

View File

@@ -25,9 +25,11 @@ namespace Marro.PacManUdon
if (currentlyInTimeSequence)
{
PrepareToStartTimeSequence(timeSequence);
TimeSequenceEndCurrent();
}
TimeSequencePrepareForStart(timeSequence);
currentlyInTimeSequence = true;
currentTimeSequence = timeSequence;
timeSequenceProgress = 0;
@@ -36,7 +38,7 @@ namespace Marro.PacManUdon
TimeSequenceProgressToTime(timeSequenceSecondsPassed);
}
private void PrepareToStartTimeSequence(PacManTimeSequence timeSequence)
private void TimeSequenceEndCurrent()
{
jumpingToTimeSequence = true;
TimeSequenceProgressToTime(100000f);
@@ -72,26 +74,26 @@ namespace Marro.PacManUdon
timeSequenceSecondsPassed = seconds;
while (timeSequenceSecondsPassed >= timeSequenceKeyframeTimes[timeSequenceProgress])
{
TimeSequenceExecuteStep(timeSequenceProgress);
TimeSequenceExecuteStep(currentTimeSequence, timeSequenceProgress);
timeSequenceProgress += 1;
if (timeSequenceProgress >= timeSequenceKeyframeTimes.Length)
{
currentlyInTimeSequence = false;
TimeSequencePrepareForFinish();
TimeSequencePrepareForFinish(currentTimeSequence);
break;
}
}
}
private void TimeSequencePrepareForFinish()
private void TimeSequencePrepareForFinish(PacManTimeSequence timeSequence)
{
if (Networking.IsOwner(gameObject))
{
TimeSequenceExecuteFinalize();
TimeSequenceExecuteFinalize(timeSequence);
if (!jumpingToTimeSequence)
{
TimeSequenceExecuteFinished();
TimeSequenceExecuteFinished(timeSequence);
}
}
else
@@ -181,10 +183,37 @@ namespace Marro.PacManUdon
#region Jump tables
private void TimeSequenceExecuteStep(int sequenceProgress)
private void TimeSequencePrepareForStart(PacManTimeSequence timeSequence)
{
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence start known for sequence {currentTimeSequence}");
break;
case PacManTimeSequence.AttractScreenIntroduction:
case PacManTimeSequence.AttractScreenDemo:
case PacManTimeSequence.StartNewGame:
case PacManTimeSequence.WaitForStart:
case PacManTimeSequence.StartNewLevel:
case PacManTimeSequence.Intermission1:
case PacManTimeSequence.Intermission2:
case PacManTimeSequence.Intermission3:
case PacManTimeSequence.AttractScreenWaitToRestart:
case PacManTimeSequence.WaitForStartTimeout:
case PacManTimeSequence.GhostCaught:
case PacManTimeSequence.GameOver:
case PacManTimeSequence.PacManCaught:
case PacManTimeSequence.BoardClear:
case PacManTimeSequence.RestartLevel:
// These don't have start logic
break;
}
}
private void TimeSequenceExecuteStep(PacManTimeSequence timeSequence, int sequenceProgress)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
switch (currentTimeSequence)
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence keyframes known for sequence {currentTimeSequence}");
@@ -235,10 +264,10 @@ namespace Marro.PacManUdon
}
}
private void TimeSequenceExecuteFinalize()
private void TimeSequenceExecuteFinalize(PacManTimeSequence timeSequence)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
switch (currentTimeSequence)
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence finalize known for sequence {currentTimeSequence}");
@@ -279,10 +308,10 @@ namespace Marro.PacManUdon
}
}
private void TimeSequenceExecuteFinished()
private void TimeSequenceExecuteFinished(PacManTimeSequence timeSequence)
{
// Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}");
switch (currentTimeSequence)
switch (timeSequence)
{
default:
Debug.LogError($"{gameObject} No time sequence finish known for sequence {currentTimeSequence}");

View File

@@ -188,17 +188,17 @@ public class SoundManager : UdonSharpBehaviour
return;
}
if (!audioSource.isPlaying || audioSource.clip == null)
{
PlaySound(audioSource, audioClip, loop);
}
if (audioSource.clip == audioClip)
{
// No need to switch
return;
}
if (!audioSource.isPlaying || audioSource.clip == null)
{
PlaySound(audioSource, audioClip, loop);
}
var newTimeSamples = (int)(audioSource.timeSamples / (double)audioSource.clip.samples * audioClip.samples);
audioSource.clip = audioClip;

View File

@@ -44,7 +44,7 @@
{
extraLifeIndicators[i - 1] = extraLifeIndicatorTransforms[i].gameObject;
}
Debug.Log($"{gameObject} extraLifeIndicators.Length: {extraLifeIndicators.Length}");
// Debug.Log($"{gameObject} extraLifeIndicators.Length: {extraLifeIndicators.Length}");
}

View File

@@ -511,7 +511,7 @@ PlayerSettings:
m_Automatic: 0
- m_BuildTarget: iOSSupport
m_APIs: 10000000
m_Automatic: 1
m_Automatic: 0
- m_BuildTarget: WindowsStandaloneSupport
m_APIs: 02000000
m_Automatic: 0