Esempio n. 1
0
    internal static AudioClip GetSound(FXSound type)
    {
        if (!Instance.FXReferences.Any(s => s.Type == type))
        {
            Debug.LogWarning("No sound for " + type);
            return(null);
        }

        return(Rnd(Instance.FXReferences.First(s => s.Type == type).Audio));
    }
Esempio n. 2
0
    public void Play(string sound)
    {
        FXSound s = Array.Find(fxSounds, item => item.name == sound);

        if (s == null)
        {
            Debug.LogWarning("Sound: " + name + " not found!");
            return;
        }

        s.source.volume = s.volume * (1f + UnityEngine.Random.Range(-s.volumeVariance / 2f, s.volumeVariance / 2f)) * overallFXVolume;
        s.source.pitch  = s.pitch * (1f + UnityEngine.Random.Range(-s.pitchVariance / 2f, s.pitchVariance / 2f));

        s.source.Play();
    }