Exemplo n.º 1
0
        /// <summary>
        /// Fetches and then plays a sound at a specific position.
        /// </summary>
        /// <param name="position">The world-space position of the sound emission</param>
        public static EffectSoundInstance Play(this ImpactSoundBank soundBank, Vector3 position, float velocity)
        {
            if (soundBank != null && (soundBank.Cooldown <= 0 || soundBank.TimeSinceLastPlayed > soundBank.Cooldown))
            {
                EffectSoundInstance sound = soundBank.Fetch(RuntimeSoundPool.Instance, velocity);
                sound.Play3D(position);
                soundBank.OnPlayed(sound);

                return(sound);
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fetches and then plays a non-spatial sound, ie. one that does not emit from a specific location and rolloff.
        /// </summary>
        /// <param name="soundBank">The sound bank used to set-up the sound instance</param>
        public static EffectSoundInstance Play(this ImpactSoundBank soundBank, float velocity)
        {
            if (soundBank != null && soundBank.TimeSinceLastPlayed > soundBank.Cooldown)
            {
                EffectSoundInstance sound = soundBank.Fetch(RuntimeSoundPool.Instance, velocity);
                sound.Play2D();
                soundBank.OnPlayed(sound);

                return(sound);
            }

            return(null);
        }