Esempio n. 1
0
        public BlendSoundInstance Fetch(ISoundPool soundPool)
        {
            if (!IsPlayable())
            {
                return(null);
            }

            BlendSoundInstance sound = soundPool.FetchFromPool <BlendSoundInstance>();

            sound.name = name;

            for (int i = 0; i < _layers.Length; i++)
            {
                if (!_layers[i].Sound.IsEmpty)
                {
                    sound.AddLayer(_layers[i]);
                }
            }


            if (_outputMixer != null)
            {
                sound.SetMixerGroup(_outputMixer);
            }

            AddFilters(sound);

            return(sound);
        }
Esempio n. 2
0
        public SequenceSoundInstance Fetch(ISoundPool soundPool)
        {
            if (!IsPlayable())
            {
                return(null);
            }

            SequenceSoundInstance sound = soundPool.FetchFromPool <SequenceSoundInstance>();

            sound.name = name;

            for (int i = 0; i < _sections.Length; i++)
            {
                if (!_sections[i].Sound.IsEmpty)
                {
                    sound.AddSection(_sections[i]);
                }
            }

            if (_outputMixer != null)
            {
                sound.SetMixerGroup(_outputMixer);
            }

            AddFilters(sound);

            return(sound);
        }
Esempio n. 3
0
        public EffectSoundInstance Fetch(ISoundPool soundPool)
        {
            EffectSoundInstance sound = soundPool.FetchFromPool <EffectSoundInstance>();

            sound.name = name;
            sound.SetClip(GetNextClip());
            sound.SetRolloffDistance(_rolloffDistance.Min, _rolloffDistance.Max);
            sound.SetMixerGroup(_outputMixer);
            sound.SetBaseVolume(_volumeRange.ChooseRandom());
            sound.SetBasePitch(_pitchRange.ChooseRandom());

            AddFilters(sound);

            return(sound);
        }
Esempio n. 4
0
        public ImpactSoundInstance Fetch(ISoundPool soundPool, float impactVelocity)
        {
            ImpactSoundInstance sound = soundPool.FetchFromPool <ImpactSoundInstance>();

            sound.name = name;
            sound.SetClip(GetNextClip());
            sound.SetImpactVelocity(impactVelocity);
            sound.SetVelocityRange(_velocityRange.Min, _velocityRange.Max);
            sound.SetRolloffDistance(_rolloffDistance.Min, _rolloffDistance.Max);
            sound.SetMixerGroup(_outputMixer);
            sound.SetBaseVolume(_volumeRange.ChooseRandom());
            sound.SetBasePitch(_pitchRange.ChooseRandom());

            AddFilters(sound);

            return(sound);
        }
Esempio n. 5
0
        public SoundInstance Fetch(ISoundPool pool)
        {
            if (IsEmpty)
            {
                return(null);
            }

            if (_isBank)
            {
                Type type = _soundBank.GetType();
                if (type == typeof(AmbienceSoundBank))
                {
                    return((_soundBank as AmbienceSoundBank).Fetch(pool));
                }
                if (type == typeof(BlendSoundBank))
                {
                    return((_soundBank as BlendSoundBank).Fetch(pool));
                }
                if (type == typeof(EffectSoundBank))
                {
                    return((_soundBank as EffectSoundBank).Fetch(pool));
                }
                if (type == typeof(ImpactSoundBank))
                {
                    return((_soundBank as ImpactSoundBank).Fetch(pool, 0f));
                }
                if (type == typeof(SequenceSoundBank))
                {
                    return((_soundBank as SequenceSoundBank).Fetch(pool));
                }

                throw new NotImplementedException("SoundBank type not implemented: " + type);
            }

            EffectSoundInstance sound = pool.FetchFromPool <EffectSoundInstance>();

            sound.SetClip(_audioClip);

            return(sound);
        }
Esempio n. 6
0
        public AmbienceSoundInstance Fetch(ISoundPool soundPool)
        {
            if (!IsPlayable())
            {
                return(null);
            }

            AmbienceSoundInstance sound = soundPool.FetchFromPool <AmbienceSoundInstance>();

            sound.name = name;

            for (int i = 0; i < _effects.Length; i++)
            {
                if (!_effects[i].Sound.IsEmpty)
                {
                    sound.AddEffect(_effects[i]);
                }
            }

            for (int i = 0; i < _loops.Length; i++)
            {
                if (!_loops[i].Sound.IsEmpty)
                {
                    sound.AddLoop(_loops[i]);
                }
            }

            if (_outputMixer != null)
            {
                sound.SetMixerGroup(_outputMixer);
            }

            AddFilters(sound);


            return(sound);
        }