Exemple #1
0
        /// <summary>
        /// Play a sound using pan and volume to positionate
        /// </summary>
        /// <param name="sound">Sound type</param>
        /// <param name="maxVolume">Max sound volume</param>
        /// <param name="loop">If the sound is repeated</param>
        /// <returns>A 3D instance sound wrapper</returns>
        public Sound3DInstance Play(SoundType sound, float maxVolume, bool loop)
        {
            var instance = this.soundManager.Play(sound, loop);

            Sound3DInstance newSound3DInstance = new Sound3DInstance()
            {
                MaxVolume = maxVolume,
                Loop = loop,
                Instance = instance
            };

            this.playingInstances.Add(newSound3DInstance);

            return newSound3DInstance;
        }
Exemple #2
0
        /// <summary>
        /// Play a sound using pan and volume to positionate
        /// </summary>
        /// <param name="sound">Sound type</param>
        /// <param name="maxVolume">Max sound volume</param>
        /// <param name="loop">If the sound is repeated</param>
        /// <returns>A 3D instance sound wrapper</returns>
        public Sound3DInstance Play(SoundType sound, float maxVolume, bool loop)
        {
            var instance = this.soundManager.Play(sound, loop);

            Sound3DInstance newSound3DInstance = new Sound3DInstance()
            {
                MaxVolume = maxVolume,
                Loop      = loop,
                Instance  = instance
            };

            this.playingInstances.Add(newSound3DInstance);

            return(newSound3DInstance);
        }
        /// <summary>
        /// Update visibility of the fighter
        /// </summary>
        /// <param name="gameTime">The current game time</param>
        protected override void Update(TimeSpan gameTime)
        {
            if (this.lastVisible != this.Owner.IsVisible)
            {
                if (this.Owner.IsVisible)
                {
                    this.engineInstance = this.engineSoundEmitter.Play(this.engineAudio, 1, true);
                }
                else if (this.engineInstance != null)
                {
                    this.engineInstance.Stop();
                }

                this.lastVisible = this.Owner.IsVisible;
            }
        }