Exemplo n.º 1
0
 public void StopEngineSound()
 {
     if (EngineConfig.SoundEnabled)
     {
         engineSound.Stop();
     }
 }
Exemplo n.º 2
0
 public void StopGunSound()
 {
     LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "STOP");
     if (EngineConfig.SoundEnabled)
     {
         gunSound.Stop();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Odgrywa dŸwiêk/muzykê jako ambient (slychaæ z tak¹ sam¹ g³oœnoœci¹ bez wzglêdu na po³o¿enie kamery)
        /// </summary>
        /// <param name="sound">plik z muzyk¹/dŸwiêkiem</param>
        /// <param name="volume">0-100</param>
        /// <param name="preloadOnly">czy tylko preloadowaæ muzykê</param>
        /// <param name="loop">zapêtlenie dziêku</param>
        /// <param name="streaming"></param>
        public FSLSoundObject PlayAmbientMusic(String sound, int volume, bool preloadOnly, bool loop, bool streaming)
        {
            // streaming = false;

            if (EngineConfig.SoundSystem == FreeSL.FSL_SOUND_SYSTEM.FSL_SS_NOSYSTEM)
            {
                return(null);
            }

            try
            {
                if (ambientSound == null || (ambientSound != null && !ambientSound.Name.Equals(sound + "_Ambient")))
                {
                    // stop old sound
                    if (!preloadOnly && (ambientSound != null && !ambientSound.Name.Equals(sound + "_Ambient") && ambientSound.IsPlaying()))
                    {
                        ambientSound.Stop();
                    }

                    if (ambientSound != null)
                    {
                        RemoveSound(ambientSound.Name);
                        ambientSounds.Remove(ambientSound.SoundFile);
                    }


                    if (ambientSounds.ContainsKey(sound))
                    {
                        ambientSound = ambientSounds[sound];
                    }
                    else
                    {
                        ambientSound         = CreateAmbientSoundMusic(sound, sound + "_Ambient", loop, streaming);
                        ambientSounds[sound] = ambientSound;
                    }

                    ambientSound.SetBaseGain(1.0f * volume / 100.0f);
                    // ambientSound.ApplyGain();
                    //Create Ambient sound
                    if (!preloadOnly)
                    {
                        ambientSound.Play();
                    }
                }
                else
                {
                    if (ambientSound != null)
                    {
                        ambientSound.SetBaseGain(1.0f * volume / 100.0f);

                        if (!ambientSound.IsPlaying() && !preloadOnly)
                        {
                            ambientSound.Play();
                        }
                    }
                }


                currentMusic = sound;
            }
            catch (Exception ex) {
                LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "Error while trying to play ambient music:" + ex.ToString());
            }

            return(ambientSound);
        }