Esempio n. 1
0
 public void RemoveSource(AudioPoolSource src)
 {
     if (_pool.Contains(src))
     {
         _pool.Remove(src);
         // Debug.Log("Added to the pool. Pool items: " + _pool.Count);
     }
 }
Esempio n. 2
0
 public void PutSource(AudioPoolSource src)
 {
     if (!_pool.Contains(src))
     {
         _pool.Add(src);
         // Debug.Log("Added to the pool. Pool items: " + _pool.Count);
     }
 }
Esempio n. 3
0
    public AudioPoolSource PlayAll(float msDelay, Transform parent = null)
    {
        AudioPoolSource src = AudioController.Instance.GetSource();

        for (int i = 0; i < clips.Count; i++)
        {
            src.PlayAfter((msDelay / clips.Count) * i, clips[i], pitch, volume, spatialBlend, loop, music, parent);
        }
        return(src);
    }
Esempio n. 4
0
    private IEnumerator PlaySound(AudioObject audioToPlay, int tempIndex)
    {
        PlayerController.Instance.SetPlayerLockInPlace(true);
        AudioPoolSource aps = audioToPlay.Play();

        yield return(null);

        while (aps.isPlaying)
        {
            yield return(null);
        }
        PlayerController.Instance.SetPlayerLockInPlace(false);
        if (cutsceneSequence[tempIndex].waitUntilActionFinishes)
        {
            moveToNextAction = true;
        }
    }
Esempio n. 5
0
    public AudioPoolSource GetSource()
    {
        AudioPoolSource output = null;

        if (_pool.Count > 0)   // grab a source and return it
        {
            output = _pool[0];
            _pool.RemoveAt(0);
            // Debug.Log("Removed from the pool. Pool items: " + _pool.Count);
            return(output);
        }
        else
        {
            // Debug.Log("Pool is empty, adding an audio source GameObject");
            GameObject go = new GameObject("Audio Source");
            go.tag = "Audio";
            return(go.AddComponent <AudioPoolSource>());
        }
    }
Esempio n. 6
0
    // returns the name of the last track that played or null if there wasn't one
    public string StopMusic(string nextTrack = null)
    {
        string lastTrack = null;

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Audio"))
        {
            AudioPoolSource aps = go.GetComponent <AudioPoolSource>();
            if (nextTrack == aps.clipName && aps.isPlaying)
            {
                lastTrack = nextTrack;
                continue;
            }
            if (aps.playsMusic && aps.isPlaying)
            {
                aps.Stop();
                return(aps.clipName);
            }
        }
        return(lastTrack);
    }