Sound updates

This commit is contained in:
2025-12-13 17:27:04 +01:00
parent 3bc8db347d
commit 42a32f5fe4
8 changed files with 86 additions and 13 deletions

View File

@@ -328,7 +328,7 @@ namespace Marro.PacManUdon
if (this.score < scoreToExtraLife && this.score + score >= scoreToExtraLife) if (this.score < scoreToExtraLife && this.score + score >= scoreToExtraLife)
{ {
IncrementLives(); BonusLifeReached();
} }
SetScore(this.score + score); SetScore(this.score + score);
@@ -379,6 +379,12 @@ namespace Marro.PacManUdon
statusDisplay.SetExtraLives(extraLives); statusDisplay.SetExtraLives(extraLives);
} }
void BonusLifeReached()
{
IncrementLives();
soundManager.PlayExtraLifeSound();
}
public void SetFrozen(bool frozen, bool ghostIgnoreIfCaught = false, bool ghostKeepAnimating = false) public void SetFrozen(bool frozen, bool ghostIgnoreIfCaught = false, bool ghostKeepAnimating = false)
{ {
// Debug.Log($"{gameObject} Set Frozen: {frozen}"); // Debug.Log($"{gameObject} Set Frozen: {frozen}");
@@ -481,6 +487,8 @@ namespace Marro.PacManUdon
return; return;
} }
Debug.Log($"StartTimeSequence: {timeSequence}");
currentlyInTimeSequence = true; currentlyInTimeSequence = true;
currentTimeSequence = timeSequence; currentTimeSequence = timeSequence;
timeSequenceProgress = 0; timeSequenceProgress = 0;
@@ -553,7 +561,7 @@ namespace Marro.PacManUdon
private void TimeSequenceExecuteStep(int sequenceProgress) 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) switch (currentTimeSequence)
{ {
default: default:
@@ -1308,6 +1316,7 @@ namespace Marro.PacManUdon
RestartLevel(); RestartLevel();
SetMazeVisible(true); SetMazeVisible(true);
statusDisplay.SetScoreDisplayVisible(true); statusDisplay.SetScoreDisplayVisible(true);
soundManager.SuppressSound(false);
break; break;
case 1: case 1:
// Increment level, show ready, show pellets, show lives indicators // Increment level, show ready, show pellets, show lives indicators
@@ -1430,6 +1439,7 @@ namespace Marro.PacManUdon
case 5: case 5:
// Unfreeze // Unfreeze
SetFrozen(false); SetFrozen(false);
soundManager.SuppressSound(false);
soundManager.StartGhostSound(false); soundManager.StartGhostSound(false);
break; break;
} }

View File

@@ -83,6 +83,7 @@
SetScattering(false, reverseDirection: false); SetScattering(false, reverseDirection: false);
sharedPelletCounter = 0; sharedPelletCounter = 0;
pelletTimeout = 0; pelletTimeout = 0;
elroyLevel = 0;
foreach (Ghost ghost in ghosts) foreach (Ghost ghost in ghosts)
{ {
@@ -226,6 +227,7 @@
public void GhostReturned() public void GhostReturned()
{ {
Debug.Log("Ghost returned");
foreach (var ghost in ghosts) foreach (var ghost in ghosts)
{ {
var state = ghost.GetGhostState(); var state = ghost.GetGhostState();

View File

@@ -67,7 +67,7 @@
void SetPowerPelletsVisible(bool visible) 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) foreach (Animator powerPellet in powerPellets)
{ {
powerPellet.SetBool("Visible", visible); powerPellet.SetBool("Visible", visible);

View File

@@ -6,8 +6,9 @@ using VRC.Udon;
public class SoundManager : UdonSharpBehaviour public class SoundManager : UdonSharpBehaviour
{ {
[SerializeField] private AudioSource audioSourcePlayer; [SerializeField] private AudioSource audioSourcePacMan;
[SerializeField] private AudioSource audioSourceGhosts; [SerializeField] private AudioSource audioSourceGhosts;
[SerializeField] private AudioSource audioSourceExtraLife;
[SerializeField] private AudioClip pacStart; [SerializeField] private AudioClip pacStart;
[SerializeField] private AudioClip pacDot1; [SerializeField] private AudioClip pacDot1;
@@ -19,6 +20,7 @@ public class SoundManager : UdonSharpBehaviour
[SerializeField] private AudioClip pacGhost1; [SerializeField] private AudioClip pacGhost1;
[SerializeField] private AudioClip pacGhostBlue; [SerializeField] private AudioClip pacGhostBlue;
[SerializeField] private AudioClip pacGhostRetreat; [SerializeField] private AudioClip pacGhostRetreat;
[SerializeField] private AudioClip pacExtraLife;
private AudioClip _nextDotSound; private AudioClip _nextDotSound;
private bool _isRetreating; private bool _isRetreating;
@@ -33,10 +35,12 @@ public class SoundManager : UdonSharpBehaviour
public void Reset() public void Reset()
{ {
StopAllSound();
_nextDotSound = pacDot2; _nextDotSound = pacDot2;
_isRetreating = false; _isRetreating = false;
_isBlue = false; _isBlue = false;
_suppress = false; _suppress = true;
} }
public void SuppressSound(bool suppress) public void SuppressSound(bool suppress)
@@ -51,37 +55,44 @@ public class SoundManager : UdonSharpBehaviour
public void PlayGameStartSound() public void PlayGameStartSound()
{ {
PlaySound(audioSourcePlayer, pacStart); PlaySound(audioSourcePacMan, pacStart);
} }
public void PlayPelletSound() public void PlayPelletSound()
{ {
PlaySound(audioSourcePlayer, _nextDotSound); PlaySound(audioSourcePacMan, _nextDotSound);
_nextDotSound = _nextDotSound == pacDot1 ? pacDot2 : pacDot1; _nextDotSound = _nextDotSound == pacDot1 ? pacDot2 : pacDot1;
} }
public void PlayDeathSound() public void PlayDeathSound()
{ {
PlaySound(audioSourcePlayer, pacDie1); PlaySound(audioSourcePacMan, pacDie1);
} }
public void PlayFruitSound() public void PlayFruitSound()
{ {
PlaySound(audioSourcePlayer, pacFruit); PlaySound(audioSourcePacMan, pacFruit);
} }
public void PlayCoinSound() public void PlayCoinSound()
{ {
PlaySound(audioSourcePlayer, pacCoin); PlaySound(audioSourcePacMan, pacCoin);
} }
public void PlayGhostEatSound() public void PlayGhostEatSound()
{ {
PlaySound(audioSourcePlayer, pacGhostEat); PlaySound(audioSourcePacMan, pacGhostEat);
}
public void PlayExtraLifeSound()
{
PlaySound(audioSourceExtraLife, pacExtraLife);
} }
public void StartGhostSound(bool isBlue) public void StartGhostSound(bool isBlue)
{ {
Debug.Log($"Start ghost sound, isBlue: {isBlue}, _isRetreating: {_isRetreating}, _suppress: {_suppress}");
_isBlue = isBlue; _isBlue = isBlue;
if (_isRetreating) if (_isRetreating)
@@ -102,6 +113,8 @@ public class SoundManager : UdonSharpBehaviour
public void EndGhostRetreat() public void EndGhostRetreat()
{ {
Debug.Log("End ghost retreating");
if (!_isRetreating) if (!_isRetreating)
{ {
return; return;
@@ -114,18 +127,20 @@ public class SoundManager : UdonSharpBehaviour
public void StopAllSound() public void StopAllSound()
{ {
audioSourcePlayer.Stop(); audioSourcePacMan.Stop();
audioSourceGhosts.Stop(); audioSourceGhosts.Stop();
// audioSourceExtraLife is not stopped on purpose, this sound is never interrupted
} }
private void PlaySound(AudioSource audioSource, AudioClip audioClip, bool loop = false) private void PlaySound(AudioSource audioSource, AudioClip audioClip, bool loop = false)
{ {
// Debug.Log($"PlaySound, audioSource: {audioSource}, audioClip: {audioClip}, loop: {loop}, suppress: {_suppress}");
if (_suppress) if (_suppress)
{ {
return; return;
} }
if (loop && audioSource.clip == audioClip) if (loop && audioSource.clip == audioClip && audioSource.isPlaying)
{ {
// Don't restart a looping sound // Don't restart a looping sound
return; return;

Binary file not shown.

View File

@@ -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:

BIN
Assets/Sounds/pacghost3.wav Normal file

Binary file not shown.

View File

@@ -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: