71 lines
1.6 KiB
C#
71 lines
1.6 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
|
|
public class SoundManager : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private AudioSource audioSourcePlayer;
|
|
[SerializeField] private AudioSource audioSourceGhosts;
|
|
|
|
[SerializeField] private AudioClip pacStart;
|
|
[SerializeField] private AudioClip pacDot1;
|
|
[SerializeField] private AudioClip pacDot2;
|
|
[SerializeField] private AudioClip pacFruit;
|
|
[SerializeField] private AudioClip pacCoin;
|
|
[SerializeField] private AudioClip pacGhostEat;
|
|
[SerializeField] private AudioClip pacGhost1;
|
|
|
|
private AudioClip nextDotSound;
|
|
|
|
public void Initialize()
|
|
{
|
|
nextDotSound = pacDot2;
|
|
}
|
|
|
|
public void PlayGameStartSound()
|
|
{
|
|
PlaySound(audioSourcePlayer, pacStart);
|
|
}
|
|
|
|
public void PlayPelletSound()
|
|
{
|
|
PlaySound(audioSourcePlayer, nextDotSound);
|
|
nextDotSound = nextDotSound == pacDot1 ? pacDot2 : pacDot1;
|
|
}
|
|
|
|
public void PlayFruitSound()
|
|
{
|
|
PlaySound(audioSourcePlayer, pacFruit);
|
|
}
|
|
|
|
public void PlayCoinSound()
|
|
{
|
|
PlaySound(audioSourcePlayer, pacCoin);
|
|
}
|
|
|
|
public void PlayGhostEatSound()
|
|
{
|
|
PlaySound(audioSourcePlayer, pacGhostEat);
|
|
}
|
|
|
|
public void StartGhostSound()
|
|
{
|
|
PlaySound(audioSourceGhosts, pacGhost1, true);
|
|
}
|
|
|
|
public void StopAllSound()
|
|
{
|
|
audioSourcePlayer.Stop();
|
|
audioSourceGhosts.Stop();
|
|
}
|
|
|
|
private void PlaySound(AudioSource audioSource, AudioClip audioClip, bool loop = false)
|
|
{
|
|
audioSource.clip = audioClip;
|
|
audioSource.Play();
|
|
audioSource.loop = loop;
|
|
}
|
|
}
|