public void LoopEngineSound()
 {
     if (EngineConfig.SoundEnabled && !engineSound.IsPlaying())
     {
         engineSound.SetBaseGain(0.3f);
         engineSound.Play();
         //SoundManager3D.Instance.UpdateSoundObjects();
     }
 }
 public void PlayGunSound()
 {
     //LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "START");
     if (EngineConfig.SoundEnabled && !gunSound.IsPlaying())
     {
         // LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, " -NEW LOOP");
         gunSound.SetBaseGain(1.0f);
         gunSound.Play();
         //SoundManager3D.Instance.UpdateSoundObjects();
     }
 }
示例#3
0
 public void PlayPlanePass()
 {
     if (EngineConfig.SoundEnabled && !planePassSound.IsPlaying())
     {
         //planePassSound.SetGain(soundObject.GetBaseGain() * volume / 100.0f);
         //planePassSound.SetGain(EngineConfig.SoundVolume / 100.0f);
         planePassSound.SetBaseGain(2.5f);
         planePassSound.Play();
         //     Console.WriteLine("PLAYING :"+planePassSound.Name);
     }
 }
 public void PlayWarcry()
 {
     if (random.Next(0, 101) > 50)
     {
         if (EngineConfig.SoundEnabled && !warCrySound.IsPlaying())
         {
             warCrySound.Play();
         }
     }
     else
     {
         if (EngineConfig.SoundEnabled && !warCrySound2.IsPlaying())
         {
             warCrySound2.Play();
         }
     }
 }
示例#5
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);
        }