diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 68bbed6..ad03fa5 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -328,7 +328,7 @@ namespace Marro.PacManUdon if (this.score < scoreToExtraLife && this.score + score >= scoreToExtraLife) { - IncrementLives(); + BonusLifeReached(); } SetScore(this.score + score); @@ -379,6 +379,12 @@ namespace Marro.PacManUdon statusDisplay.SetExtraLives(extraLives); } + void BonusLifeReached() + { + IncrementLives(); + soundManager.PlayExtraLifeSound(); + } + public void SetFrozen(bool frozen, bool ghostIgnoreIfCaught = false, bool ghostKeepAnimating = false) { // Debug.Log($"{gameObject} Set Frozen: {frozen}"); @@ -481,6 +487,8 @@ namespace Marro.PacManUdon return; } + Debug.Log($"StartTimeSequence: {timeSequence}"); + currentlyInTimeSequence = true; currentTimeSequence = timeSequence; timeSequenceProgress = 0; @@ -553,7 +561,7 @@ namespace Marro.PacManUdon private void TimeSequenceExecuteStep(int sequenceProgress) { - Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}"); + // Debug.Log($"{gameObject} Triggered time sequence step for sequence {currentTimeSequence} with progress {sequenceProgress}"); switch (currentTimeSequence) { default: @@ -1308,6 +1316,7 @@ namespace Marro.PacManUdon RestartLevel(); SetMazeVisible(true); statusDisplay.SetScoreDisplayVisible(true); + soundManager.SuppressSound(false); break; case 1: // Increment level, show ready, show pellets, show lives indicators @@ -1430,6 +1439,7 @@ namespace Marro.PacManUdon case 5: // Unfreeze SetFrozen(false); + soundManager.SuppressSound(false); soundManager.StartGhostSound(false); break; } diff --git a/Assets/Scripts/GhostManager.cs b/Assets/Scripts/GhostManager.cs index 7523df9..a3e8ae0 100644 --- a/Assets/Scripts/GhostManager.cs +++ b/Assets/Scripts/GhostManager.cs @@ -83,6 +83,7 @@ SetScattering(false, reverseDirection: false); sharedPelletCounter = 0; pelletTimeout = 0; + elroyLevel = 0; foreach (Ghost ghost in ghosts) { @@ -226,6 +227,7 @@ public void GhostReturned() { + Debug.Log("Ghost returned"); foreach (var ghost in ghosts) { var state = ghost.GetGhostState(); diff --git a/Assets/Scripts/PelletManager.cs b/Assets/Scripts/PelletManager.cs index 9a445a5..0b1269a 100644 --- a/Assets/Scripts/PelletManager.cs +++ b/Assets/Scripts/PelletManager.cs @@ -67,7 +67,7 @@ void SetPowerPelletsVisible(bool visible) { - Debug.Log($"{gameObject} SetPowerPelletVisible {visible}, powerPellets.Length: {powerPellets.Length}"); + // Debug.Log($"{gameObject} SetPowerPelletVisible {visible}, powerPellets.Length: {powerPellets.Length}"); foreach (Animator powerPellet in powerPellets) { powerPellet.SetBool("Visible", visible); diff --git a/Assets/Scripts/SoundManager.cs b/Assets/Scripts/SoundManager.cs index d989912..b4e96ed 100644 --- a/Assets/Scripts/SoundManager.cs +++ b/Assets/Scripts/SoundManager.cs @@ -6,8 +6,9 @@ using VRC.Udon; public class SoundManager : UdonSharpBehaviour { - [SerializeField] private AudioSource audioSourcePlayer; + [SerializeField] private AudioSource audioSourcePacMan; [SerializeField] private AudioSource audioSourceGhosts; + [SerializeField] private AudioSource audioSourceExtraLife; [SerializeField] private AudioClip pacStart; [SerializeField] private AudioClip pacDot1; @@ -19,6 +20,7 @@ public class SoundManager : UdonSharpBehaviour [SerializeField] private AudioClip pacGhost1; [SerializeField] private AudioClip pacGhostBlue; [SerializeField] private AudioClip pacGhostRetreat; + [SerializeField] private AudioClip pacExtraLife; private AudioClip _nextDotSound; private bool _isRetreating; @@ -33,10 +35,12 @@ public class SoundManager : UdonSharpBehaviour public void Reset() { + StopAllSound(); + _nextDotSound = pacDot2; _isRetreating = false; _isBlue = false; - _suppress = false; + _suppress = true; } public void SuppressSound(bool suppress) @@ -51,37 +55,44 @@ public class SoundManager : UdonSharpBehaviour public void PlayGameStartSound() { - PlaySound(audioSourcePlayer, pacStart); + PlaySound(audioSourcePacMan, pacStart); } public void PlayPelletSound() { - PlaySound(audioSourcePlayer, _nextDotSound); + PlaySound(audioSourcePacMan, _nextDotSound); _nextDotSound = _nextDotSound == pacDot1 ? pacDot2 : pacDot1; } public void PlayDeathSound() { - PlaySound(audioSourcePlayer, pacDie1); + PlaySound(audioSourcePacMan, pacDie1); } public void PlayFruitSound() { - PlaySound(audioSourcePlayer, pacFruit); + PlaySound(audioSourcePacMan, pacFruit); } public void PlayCoinSound() { - PlaySound(audioSourcePlayer, pacCoin); + PlaySound(audioSourcePacMan, pacCoin); } public void PlayGhostEatSound() { - PlaySound(audioSourcePlayer, pacGhostEat); + PlaySound(audioSourcePacMan, pacGhostEat); + } + + public void PlayExtraLifeSound() + { + PlaySound(audioSourceExtraLife, pacExtraLife); } public void StartGhostSound(bool isBlue) { + Debug.Log($"Start ghost sound, isBlue: {isBlue}, _isRetreating: {_isRetreating}, _suppress: {_suppress}"); + _isBlue = isBlue; if (_isRetreating) @@ -102,6 +113,8 @@ public class SoundManager : UdonSharpBehaviour public void EndGhostRetreat() { + Debug.Log("End ghost retreating"); + if (!_isRetreating) { return; @@ -114,18 +127,20 @@ public class SoundManager : UdonSharpBehaviour public void StopAllSound() { - audioSourcePlayer.Stop(); + audioSourcePacMan.Stop(); audioSourceGhosts.Stop(); + // audioSourceExtraLife is not stopped on purpose, this sound is never interrupted } private void PlaySound(AudioSource audioSource, AudioClip audioClip, bool loop = false) { + // Debug.Log($"PlaySound, audioSource: {audioSource}, audioClip: {audioClip}, loop: {loop}, suppress: {_suppress}"); if (_suppress) { return; } - if (loop && audioSource.clip == audioClip) + if (loop && audioSource.clip == audioClip && audioSource.isPlaying) { // Don't restart a looping sound return; diff --git a/Assets/Sounds/pacextralife.wav b/Assets/Sounds/pacextralife.wav new file mode 100644 index 0000000..1f93379 Binary files /dev/null and b/Assets/Sounds/pacextralife.wav differ diff --git a/Assets/Sounds/pacextralife.wav.meta b/Assets/Sounds/pacextralife.wav.meta new file mode 100644 index 0000000..462e130 --- /dev/null +++ b/Assets/Sounds/pacextralife.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 03ba6352816f6af44985ed4b321226f8 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sounds/pacghost3.wav b/Assets/Sounds/pacghost3.wav new file mode 100644 index 0000000..0dcc9da Binary files /dev/null and b/Assets/Sounds/pacghost3.wav differ diff --git a/Assets/Sounds/pacghost3.wav.meta b/Assets/Sounds/pacghost3.wav.meta new file mode 100644 index 0000000..fed77cb --- /dev/null +++ b/Assets/Sounds/pacghost3.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: ee92fdc06c06f784a94df32751017393 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: