예제 #1
0
        public bool PlaySound(FlaiSoundEffectInstance soundEffect)
        {
            int index = this.GetAvailableSoundIndex();
            if (index != -1)
            {
                _playingSoundEffects[index] = soundEffect;

                if (_enabled)
                {
                    soundEffect.Play();
                }

                return true;
            }

            return false;
        }
예제 #2
0
        private FlaiSoundEffectInstance InnerPlaySound(string name, float volume, float pitch, float pan, bool isLooping, TimeSpan fadeInTime)
        {
            int index = this.GetAvailableSoundIndex();
            if (index != -1)
            {
                SoundEffect soundEffect = this.GetSoundEffect(name);
                FlaiSoundEffectInstance instance = new FlaiSoundEffectInstance(soundEffect.CreateInstance(), volume, pitch, pan, isLooping);
                _playingSoundEffects[index] = instance;

                if (_enabled)
                {
                    instance.Play(fadeInTime);
                }
                // If manager is not enabled, pause the sound effect. By default sound effect is stopped and to get it paused, it has to be played first. Thus, always start playing the instance and pause if manager is not enabled
                else
                {
                    instance.Volume = 0;
                    instance.Play();
                    instance.Pause();
                    instance.Volume = volume;
                }

                return instance;
            }

            return null;
        }
예제 #3
0
 public bool PlaySound(string name, float volume, float pitch, float pan, bool isLooping, TimeSpan fadeInTime, out FlaiSoundEffectInstance instance)
 {
     return (instance = this.InnerPlaySound(name, volume, pitch, pan, isLooping, fadeInTime)) != null;
 }
예제 #4
0
 public bool PlaySound(string name, float volume, float pitch, float pan, out FlaiSoundEffectInstance instance)
 {
     return (instance = this.InnerPlaySound(name, volume, pitch, pan, false, TimeSpan.Zero)) != null;
 }
예제 #5
0
 public bool PlaySound(string name, float volume, TimeSpan fadeInTime, out FlaiSoundEffectInstance instance)
 {
     return (instance = this.InnerPlaySound(name, volume, 0f, 0f, false, fadeInTime)) != null;
 }
예제 #6
0
 public bool PlaySound(string name, out FlaiSoundEffectInstance instance)
 {
     return (instance = this.InnerPlaySound(name, 1f, 0f, 0f, false, TimeSpan.Zero)) != null;
 }