Exemplo n.º 1
0
        private void RemoveSFXObject(SFXPoolInfo info, int index)
        {
            GameObject gO = info.ownedAudioClipPool[index];

            info.ownedAudioClipPool.RemoveAt(index);
            info.timesOfDeath.RemoveAt(index);

            if (info.currentIndexInPool >= index)
            {
                info.currentIndexInPool = 0;
            }

            Destroy(gO);
        }
        private GameObject GetNextInactiveSFXObject(AudioClip clip)
        {
            if (!ownedPools.ContainsKey(clip) || ownedPools[clip].ownedAudioClipPool.Count == 0)
            {
                return(AddOwnedSFXObject(clip));
            }
            SFXPoolInfo info = ownedPools[clip];

            for (int i = (info.currentIndexInPool + 1) % info.ownedAudioClipPool.Count; i != info.currentIndexInPool; i = (i + 1) % info.ownedAudioClipPool.Count)
            {
                if (!info.ownedAudioClipPool[i].activeSelf)
                {
                    ownedPools[clip].currentIndexInPool = i;
                    ResetSFXObject(info.ownedAudioClipPool[i]);
                    return(info.ownedAudioClipPool[i]);
                }
            }
            return(AddOwnedSFXObject(clip));
        }