示例#1
0
        IEnumerator WaitForClip(CamSoundOptions clip, AudioSource source)
        {
            if (queued == false)
            {
                queued = true;
                yield return(new WaitWhile(() => source.isPlaying));

                if (mc.GetSwimState() == true)
                {
                    source.volume = clip.volume;
                    source.loop   = clip.loop;
                    source.clip   = clip.sound;
                    source.Play();
                }
                queued = false;
            }
        }
示例#2
0
        void PlayRandomSound(AudioClip[] inputSounds, AudioSource sSource, bool WaitToFinish = false)
        {
            if (inputSounds.Length < 1)
            {
                return;
            }
            CamSoundOptions selected = new CamSoundOptions();
            AudioClip       clip     = inputSounds[UnityEngine.Random.Range(0, inputSounds.Length)];

            selected.sound  = clip;
            selected.loop   = sSource.loop;
            selected.volume = sSource.volume;
            if (WaitToFinish == true)
            {
                StartCoroutine(WaitForClip(selected, sSource));
            }
            else
            {
                sSource.clip = clip;
                sSource.Play();
            }
        }
示例#3
0
        void PlayRandomSound(CamSoundOptions[] inputSounds, AudioSource overrideSource = null, bool WaitToFinish = false)
        {
            if (inputSounds.Length < 1)
            {
                return;
            }
            CamSoundOptions selected = inputSounds[UnityEngine.Random.Range(0, inputSounds.Length)];

            if (overrideSource != null)
            {
                if (WaitToFinish == true)
                {
                    StartCoroutine(WaitForClip(selected, overrideSource));
                }
                else
                {
                    overrideSource.volume = selected.volume;
                    overrideSource.loop   = selected.loop;
                    overrideSource.clip   = selected.sound;
                    overrideSource.Play();
                }
            }
            else
            {
                if (WaitToFinish == true)
                {
                    StartCoroutine(WaitForClip(selected, swimming.source));
                }
                else
                {
                    swimming.source.volume = selected.volume;
                    swimming.source.loop   = selected.loop;
                    swimming.source.clip   = selected.sound;
                    swimming.source.Play();
                }
            }
        }