Ejemplo n.º 1
0
 public void AddSfx(AudioClip clip)
 {
     if (!SFXPlaylist.Contains(clip))
     {
         SFXPlaylist.Add(clip);
     }
 }
Ejemplo n.º 2
0
 public void PlayRandomSFXFromSet(string setName, float volume)
 {
     if (!MuteAllSound && !MuteSfx)
     {
         AudioClip clip = SFXPlaylist.FindByName(_sfxSets["setName"][UnityEngine.Random.Range(0, _sfxSets["setName"].Length)]);
         PlaySFX(clip.name, volume);
     }
 }
Ejemplo n.º 3
0
        public void PlayPanoramaSound(string clipName, float pan)
        {
            AudioClip   audioClip = SFXPlaylist.FindClosestByName(clipName);
            AudioSource currSound = GetPlayingSFXSource(audioClip);

            if (currSound != null)
            {
                currSound.panStereo = pan; // pan from -1 to 1
            }
        }
Ejemplo n.º 4
0
        public void PlaySFX(string clipName, float volume, InterruptionType interruptType, string[] alsoInterrupt, bool loop = false)
        {
            if (string.IsNullOrEmpty(clipName))
            {
                return;
            }

            AudioClip clip = SFXPlaylist.FindByName(clipName);

            if (clip == SFXPlaylist.DefaultClip)
            {
                clip = SFXPlaylist.FindClosestByName(clipName);
                PlaySFX(clip, volume, interruptType, new List <string>(alsoInterrupt), loop);
            }
            else
            {
                PlaySFX(clip, volume, interruptType, new List <string>(alsoInterrupt), loop);
            }
        }
Ejemplo n.º 5
0
        private void StopPlayingSoundList(List <string> alsoInterrupt, string callingSoundName)
        {
            if (alsoInterrupt.Count > 0)
            {
                foreach (string soundName in alsoInterrupt)
                {
                    GDebug.Log(callingSoundName + " : " + soundName, this, LogCategory.SOUND_MANAGER);

                    if (callingSoundName.Contains(soundName)) //dont stop the same sound you just tried to play even if its in the list
                    {
                        continue;
                    }
                    else
                    {
                        AudioClip audioClip = SFXPlaylist.FindClosestByName(soundName);
                        if (SFXIsPlaying(audioClip))
                        {
                            GDebug.Log("stopping sound fx:" + audioClip.name, this, LogCategory.SOUND_MANAGER);
                            GetPlayingSFXSource(audioClip).Stop();
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public void FadeOutSfx(string sfxName, float duration = 1f, float delay = 0f)
        {
            AudioSource sfxSource = GetPlayingSFXSource(SFXPlaylist.FindByName(sfxName));

            FadeSfx(sfxSource, 0f, duration, delay);
        }