diff --git a/Assets/Scripts/BonusFruit.cs b/Assets/Scripts/BonusFruit.cs index 4c6cef8..ab49fd2 100644 --- a/Assets/Scripts/BonusFruit.cs +++ b/Assets/Scripts/BonusFruit.cs @@ -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); } diff --git a/Assets/Scripts/Ghost.cs b/Assets/Scripts/Ghost.cs index 8e3e79d..a3f5c35 100644 --- a/Assets/Scripts/Ghost.cs +++ b/Assets/Scripts/Ghost.cs @@ -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(); } } diff --git a/Assets/Scripts/GhostManager.cs b/Assets/Scripts/GhostManager.cs index 5b664c5..7c487fd 100644 --- a/Assets/Scripts/GhostManager.cs +++ b/Assets/Scripts/GhostManager.cs @@ -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 } } diff --git a/Assets/Scripts/GridMover.cs b/Assets/Scripts/GridMover.cs index 84e66db..8924c01 100644 --- a/Assets/Scripts/GridMover.cs +++ b/Assets/Scripts/GridMover.cs @@ -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; } } diff --git a/Assets/Scripts/Intermission2Pole.cs b/Assets/Scripts/Intermission2Pole.cs index 630baf3..6720161 100644 --- a/Assets/Scripts/Intermission2Pole.cs +++ b/Assets/Scripts/Intermission2Pole.cs @@ -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)); } diff --git a/Assets/Scripts/PelletManager.cs b/Assets/Scripts/PelletManager.cs index 0b1269a..05c8f82 100644 --- a/Assets/Scripts/PelletManager.cs +++ b/Assets/Scripts/PelletManager.cs @@ -30,7 +30,7 @@ } powerPellets = GetComponentsInChildren(true); - Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}"); + // Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}"); powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval(); SetPowerPelletsBlink(false); } diff --git a/Assets/Scripts/Sequences/PacManCaught.cs b/Assets/Scripts/Sequences/PacManCaught.cs index da89d79..2477201 100644 --- a/Assets/Scripts/Sequences/PacManCaught.cs +++ b/Assets/Scripts/Sequences/PacManCaught.cs @@ -21,7 +21,7 @@ namespace Marro.PacManUdon soundManager.PlayDeathSound(); break; case 3: - // Hide pacman, start next state + // Hide pacman SetPacManActive(false); break; } diff --git a/Assets/Scripts/Sequences/StartNewGame.cs b/Assets/Scripts/Sequences/StartNewGame.cs index 82f58c7..18ec0cb 100644 --- a/Assets/Scripts/Sequences/StartNewGame.cs +++ b/Assets/Scripts/Sequences/StartNewGame.cs @@ -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: diff --git a/Assets/Scripts/Sequences/StartNewLevel.cs b/Assets/Scripts/Sequences/StartNewLevel.cs index eda2bcf..2c4a8eb 100644 --- a/Assets/Scripts/Sequences/StartNewLevel.cs +++ b/Assets/Scripts/Sequences/StartNewLevel.cs @@ -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(); } } diff --git a/Assets/Scripts/Sequences/TimeSequenceShared.cs b/Assets/Scripts/Sequences/TimeSequenceShared.cs index bcc49c2..fbb4a08 100644 --- a/Assets/Scripts/Sequences/TimeSequenceShared.cs +++ b/Assets/Scripts/Sequences/TimeSequenceShared.cs @@ -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}"); diff --git a/Assets/Scripts/SoundManager.cs b/Assets/Scripts/SoundManager.cs index 590f5f4..1c82d7f 100644 --- a/Assets/Scripts/SoundManager.cs +++ b/Assets/Scripts/SoundManager.cs @@ -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; diff --git a/Assets/Scripts/StatusDisplay.cs b/Assets/Scripts/StatusDisplay.cs index 3c53355..23f4c00 100644 --- a/Assets/Scripts/StatusDisplay.cs +++ b/Assets/Scripts/StatusDisplay.cs @@ -44,7 +44,7 @@ { extraLifeIndicators[i - 1] = extraLifeIndicatorTransforms[i].gameObject; } - Debug.Log($"{gameObject} extraLifeIndicators.Length: {extraLifeIndicators.Length}"); + // Debug.Log($"{gameObject} extraLifeIndicators.Length: {extraLifeIndicators.Length}"); } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 02a073d..6d2f274 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -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