예제 #1
0
    public AudioSauce GetNextSauce()
    {
        // Gets the next available audio sauce.
        // Or creates a new one if possible.

        foreach (AudioSauce s in Sauces)
        {
            if (s == null)
            {
                continue;
            }
            if (!s.IsPlaying)
            {
                return(s);
            }
        }

        if (Sauces.Count < MAX_SAUCES)
        {
            AudioSauce s = NewSauce();
            Sauces.Add(s);
            return(s);
        }

        return(null);
    }
예제 #2
0
    public AudioSauce PlayOneShot(Vector2 position, AudioClip clip, float volume, float pitch, float range, float minPanRange, float maxPanRange, float lowPassStart)
    {
        AudioSauce s = GetNextSauce();

        if (s == null)
        {
            Debug.LogError("All audio sauces have been used up! (" + Sauces.Count + ", max " + MAX_SAUCES + ")");
            return(s);
        }

        s.Clip               = clip;
        s.Volume             = volume;
        s.Pitch              = pitch;
        s.Range              = range;
        s.FullPanDistance    = maxPanRange;
        s.NoPanDistance      = minPanRange;
        s.transform.position = position;
        s.LowPassStart       = lowPassStart;

        s.Play();

        return(s);
    }
예제 #3
0
    public AudioSauce NewSauce()
    {
        AudioSauce s = Instantiate(Prefab, Parent).GetComponent <AudioSauce>();

        return(s);
    }