예제 #1
0
 public void Volume(float value, TypeSound type)
 {
     if (this.type == type)
     {
         source.volume = value;
     }
 }
예제 #2
0
    public void ExecuteAmbient(TypeSound audioAmbient, float fadeoutVolumeSpeed)
    {
        if (actualAmbientSound == TypeSound.None)
        {
            if (audioAmbient != TypeSound.None)
            {
                actualAmbientSound = audioAmbient;
                ambient.clip       = listAudios.Find(audio => audio.name == audioAmbient.ToString()).audioClip;
                ambient.Play();
            }
            return;
        }

        if (actualAmbientSound == audioAmbient && ambient.isPlaying)
        {
            return;
        }

        if (audioAmbient == TypeSound.None)
        {
            actualAmbientSound = TypeSound.None;
            ambient.Stop();
            ambient.clip = null;

            ExecuteEffect(TypeSound.None);
            return;
        }

        actualAmbientSound = audioAmbient;
        StartCoroutine(Fadeout(audioAmbient, fadeoutVolumeSpeed));
    }
예제 #3
0
    public AudioSource ExecuteEffect(TypeSound audioEffect)
    {
        AudioStruct clip = listAudios.Find(audio => audio.name == audioEffect.ToString());

        audioSourceCurrent      = EffectsFree();
        audioSourceCurrent.clip = clip.audioClip;
        audioSourceCurrent.loop = clip.isLoop;
        audioSourceCurrent.Play();

        return(audioSourceCurrent);
    }
예제 #4
0
        public void PlaySound(TypeSound typeSound)
        {
            if (!IsPlaySound)
            {
                return;
            }

            AudioClip audioClip = _listDataAudioClipTypeSounds.Find(item => item.Type == typeSound).AudioClip;

            if (audioClip != null)
            {
                _audioSourceSound.PlayOneShot(audioClip);
            }
        }
예제 #5
0
    IEnumerator Fadeout(TypeSound audioAmbient, float fadeoutVolumeSpeed)
    {
        float vol = ambient.volume;

        while (ambient.volume > 0.01f)
        {
            ambient.volume -= fadeoutVolumeSpeed;
            yield return(new WaitForSeconds(fadeoutVolumeSpeed));
        }

        ambient.clip = listAudios.Find(audio => audio.name == audioAmbient.ToString()).audioClip;
        ambient.Play();
        ambient.volume = vol;
    }