public new bool InitializeSound(CameraListenerBase listener, FreeSL.FSL_SOUND_SYSTEM ss) { if (Instance.Initialized && ss == soundSystem) { this.SetListener(listener); return(true); } if (Instance.Initialized) { this.ambientSounds.Clear(); Instance.Destroy(); } bool ok = base.InitializeSound(listener, ss); //InitializeSound sound system if (ok) { soundSystem = ss; StopAmbientMusic(); currentMusic = null; ambientSound = null; SoundManager3D.Instance.UpdaterRunning = true; return(true); } return(false); }
public override void Destroy() { base.Destroy(); if (engineSound != null) { SoundManager3D.Instance.RemoveSound(engineSound.Name); //engineSound.Destroy(); engineSound = null; } if (warCrySound != null) { SoundManager3D.Instance.RemoveSound(warCrySound.Name); // warCrySound.Destroy(); warCrySound = null; } if (warCrySound2 != null) { SoundManager3D.Instance.RemoveSound(warCrySound2.Name); // warCrySound2.Destroy(); warCrySound2 = null; } if (gunSound != null) { SoundManager3D.Instance.RemoveSound(gunSound.Name); // gunSound.Destroy(); gunSound = null; } }
public void PlayMainTheme() { FSLSoundObject obj = SoundManager3D.Instance.PlayAmbientMusic("music/themesong.ogg", EngineConfig.MusicVolume, false, true, EngineConfig.AudioStreaming); if (obj != null && obj is FSLAmbientSoundMusic) { (obj as FSLAmbientSoundMusic).IsOnPlaylist = false; } // Play(mainTheme); }
protected virtual void initOnScene() { if (EngineConfig.SoundEnabled) { planePassSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_PLANE_PASS, this.planeNode, false, false); } initBlade(); initWheels(); initAnimationManager(); animationState = PlaneEntity.GetAnimationState("manual"); }
public void StopAmbientMusic() { if (ambientSound != null) { ambientSound.Stop(); if (EngineConfig.AudioStreaming) // streaming nie pozwala na pauzowanie { RemoveSound(ambientSound.Name); ambientSounds.Remove(ambientSound.SoundFile); ambientSound = null; } } }
public void OnSoundPreloaded(string sound, FSLSoundObject obj, bool loop) { LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "Sound preloaded: " + sound); ambientSounds[sound] = obj; while (!readyToPlayPreloadedMusic) { Thread.Sleep(100); } LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "Playback of sound: " + sound); PlayAmbientMusic(sound, EngineConfig.MusicVolume, false, loop, false); readyToPlayPreloadedMusic = false; }
public void Dispose() { if (dieSound != null) { SoundManager3D.Instance.RemoveSound(dieSound.Name); //dieSound.Destroy(); dieSound = null; } if (prepareToFireSound != null) { SoundManager3D.Instance.RemoveSound(prepareToFireSound.Name); // prepareToFireSound.Destroy(); prepareToFireSound = null; } GC.SuppressFinalize(this); }
public virtual void Destroy() { if (LogManager.Singleton != null) { LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "Destroying plane view: " + Name); } isDestroyed = true; if (EngineConfig.SoundEnabled) { if (planePassSound != null) { SoundManager3D.Instance.RemoveSound(planePassSound.Name); // planePassSound.Destroy(); planePassSound = null; } } }
private void NextScreen() { lastChange = DateTime.Now; currentScreen++; if (currentScreen > 1) { if (currentMaterialName != null && animation != null && currentAd != null) { AdManager.Singleton.CloseAd(currentAd); AdManager.Singleton.Work(null); // wyslij, na wszelki wypadek MaterialManager.Singleton.Unload(currentMaterialName); EffectsManager.Singleton.RemoveAnimation(animation); } } if (currentScreen > maxScreens) { hideAdText(); if (EngineConfig.SoundEnabled) { ravenSound.Destroy(); ravenSound = null; } GotoStartScreen(); return; } if (!initScreen(currentScreen)) { // nie udalo sie? NextScreen(); } else { overlay.Show(); } }
public override void CreateScene() { base.sceneMgr.AmbientLight = new ColourValue(0.0f, 0.0f, 0.0f); base.sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE; //position of camara camera.Position = new Vector3(500, 500, 500); camera.LookAt(new Vector3(0, 200, -300)); soundManager = FSLSoundManager.Instance; soundManager.InitializeSound(base.camera); //Init sound system Light l; Entity ent; SceneNode nodo2; FSLSoundObject sonido1; //testing streaming with this sound FSLSoundObject sonido2 = soundManager.CreateAmbientSound("../media/sound/windy1.ogg", "Ambiente1", true, true); //Create Ambient sound sonido2.Play(); SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("nodoBlender", new Vector3(50, 0, 0)); ent = sceneMgr.CreateEntity("Suzanne1", "Suzanne.mesh"); ent.CastShadows = true; nodo2 = node.CreateChildSceneNode("nodoSuzanne1", new Vector3(800, 60, 0)); nodo2.AttachObject(ent); nodo2.Pitch(new Degree(-12)); //testing zip loading with this sound sonido1 = soundManager.CreateSoundEntity("../media/sound/chime.zip", "chime1.ogg", nodo2, nodo2.Name, true); sonido1.Play(); l = sceneMgr.CreateLight("Luz1"); l.Type = Light.LightTypes.LT_POINT; l.Position = new Vector3( nodo2.WorldPosition.x, nodo2.WorldPosition.y + 120, nodo2.WorldPosition.z + 20); l.CastShadows = true; l.DiffuseColour = new ColourValue(0.8f, 0.8f, 0.1f); l.SpecularColour = new ColourValue(0.9f, 0.9f, 0.2f); l.SetAttenuation(500f, 1f, 0.0005f, 0f); ent = sceneMgr.CreateEntity("Suzanne2", "Suzanne.mesh"); ent.CastShadows = true; nodo2 = node.CreateChildSceneNode("nodoSuzanne2", new Vector3(0, 60, -1000)); nodo2.AttachObject(ent); nodo2.Pitch(new Degree(-12)); sonido1 = soundManager.CreateSoundEntity("../media/sound/bell1.ogg", nodo2, nodo2.Name, true, false); sonido1.Play(); l = sceneMgr.CreateLight("Luz2"); l.Type = Light.LightTypes.LT_POINT; l.Position = new Vector3( nodo2.WorldPosition.x, nodo2.WorldPosition.y + 120, nodo2.WorldPosition.z + 20); l.CastShadows = true; l.DiffuseColour = new ColourValue(0.7f, 0.3f, 0.3f); l.SpecularColour = new ColourValue(0.75f, 0.35f, 0.35f); l.SetAttenuation(500f, 1f, 0.0005f, 0f); ent = sceneMgr.CreateEntity("Suzanne3", "Suzanne.mesh"); ent.CastShadows = true; nodo2 = node.CreateChildSceneNode("nodoSuzanne3", new Vector3(-2000, 60, -400)); nodo2.AttachObject(ent); nodo2.Pitch(new Degree(-12)); sonido1 = soundManager.CreateSoundEntity("../media/sound/boo1.ogg", nodo2, nodo2.Name, true, false); sonido1.Play(); l = sceneMgr.CreateLight("Luz3"); l.Type = Light.LightTypes.LT_POINT; l.Position = new Vector3( nodo2.WorldPosition.x, nodo2.WorldPosition.y + 120, nodo2.WorldPosition.z + 20); l.CastShadows = true; l.DiffuseColour = new ColourValue(0.35f, 0.67f, 0.41f); l.SpecularColour = new ColourValue(0.4f, 0.72f, 0.46f); l.SetAttenuation(500f, 1f, 0.0005f, 0f); ent = sceneMgr.CreateEntity("Suzanne4", "Suzanne.mesh"); ent.CastShadows = true; nodo2 = node.CreateChildSceneNode("nodoSuzanne4", new Vector3(1600, 60, -800)); nodo2.AttachObject(ent); nodo2.Pitch(new Degree(-12)); sonido1 = soundManager.CreateSoundEntity("../media/sound/policesiren1.ogg", nodo2, nodo2.Name, true, false); sonido1.Play(); l = sceneMgr.CreateLight("Luz4"); l.Type = Light.LightTypes.LT_POINT; l.Position = new Vector3(nodo2.WorldPosition.x, nodo2.WorldPosition.y + 120, nodo2.WorldPosition.z + 20); l.CastShadows = true; l.DiffuseColour = new ColourValue(0.24f, 0.22f, 0.71f); l.SpecularColour = new ColourValue(0.29f, 0.27f, 0.76f); l.SetAttenuation(500f, 1f, 0.0005f, 0f); ent = sceneMgr.CreateEntity("Suzanne5", "Suzanne.mesh"); ent.CastShadows = true; nodo2 = node.CreateChildSceneNode("nodoSuzanne5", new Vector3(-1800, 60, -2100)); nodo2.AttachObject(ent); nodo2.Pitch(new Degree(-12)); sonido1 = soundManager.CreateSoundEntity("../media/sound/phone1.ogg", nodo2, nodo2.Name, true, false); sonido1.Play(); l = sceneMgr.CreateLight("Luz5"); l.Type = Light.LightTypes.LT_POINT; l.Position = new Vector3(nodo2.WorldPosition.x, nodo2.WorldPosition.y + 120, nodo2.WorldPosition.z + 20); l.CastShadows = true; l.DiffuseColour = new ColourValue(0.5f, 0.5f, 0.5f); l.SpecularColour = new ColourValue(1, 1, 1); l.SetAttenuation(500f, 1f, 0.0005f, 0f); //Scenario ent = sceneMgr.CreateEntity("escenario", "ScenaMuestra.mesh"); nodo2 = node.CreateChildSceneNode("nodoescenario", new Vector3(0, -2, 0)); nodo2.AttachObject(ent); nodo2.Pitch(new Degree(-90)); ent.CastShadows = false; }
/// <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); }
public void Work() { FSLSoundObject obj = Instance.CreateAmbientSoundMusic(sound, sound + "_Ambient", loop, false); Instance.OnSoundPreloaded(sound, obj, loop); }
private bool initScreen(int i) { MaterialPtr overlayMaterial = null; TextureUnitState unit; animation = null; currentMaterialName = null; if (isScreenAnAd[i - 1]) // poczatkowo i = 1 { if (Mogre.Math.RangeRandom(0, 1) < (1 - C_INTRO_AD_PROBABILITY)) { return(false); } //if(adIds.Count == 0) return false; AdManager.AdStatus status = AdManager.Singleton.GetAd(C_AD_ZONE, 1.0f, out currentAd); //AdManager.AdStatus status = AdManager.Singleton.GatherAsyncResult(adIds.Dequeue(), AdManager.C_AD_DOWNLOAD_TIMEOUT, out currentAd); if (status == AdManager.AdStatus.OK) { // pobieranie OK. currentMaterialName = C_AD_MATERIAL; string path = AdManager.Singleton.LoadAdTexture(currentAd); if (path == null) { return(false); } showAdText(viewport); overlayMaterial = MaterialManager.Singleton.GetByName(currentMaterialName); overlayMaterial.Load(); unit = overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0); unit.SetTextureName(path); AdManager.Singleton.RegisterImpression(currentAd); // int count; // count = adAction.Get_Ad_Impression_Counter(currentAd.id); // Console.WriteLine("Pobrañ: " + count); } else { hideAdText(); return(false); } } else { string matName = EngineConfig.IsEnhancedVersion ? C_TEXTURE_NAME_ENHANCED : C_TEXTURE_NAME; currentMaterialName = matName + currentScreen; overlayMaterial = MaterialManager.Singleton.GetByName(currentMaterialName); unit = overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0); hideAdText(); } if (i == 1) { if (EngineConfig.SoundEnabled) { if (ravenSound == null || !ravenSound.HasSound()) { ravenSound = SoundManager3D.Instance.CreateAmbientSound(SoundManager3D.C_RAVEN, "ravenSound", false, false); // destroyed together with SoundManager3D singleton } ravenSound.Play(); } } textureDimensions = unit.GetTextureDimensions(); // Console.WriteLine(textureDimensions.first); PointD scale = new PointD(1, 1); // skaluj overlay tak aby tekstury nie zmienia³y swoich proporcji float prop = 1.0f; if (isScreenAnAd[currentScreen - 1]) { // reklamy maja zachowac oryginalna rozdzielczosc scale = AdSizeUtils.ScaleAdToDisplay(textureDimensions, new PointD(Viewport.ActualWidth, Viewport.ActualHeight), true); scale = 0.65f * scale; } else { textureDimensions = new Pair <uint, uint>(1280, 1024); // scale = AdSizeUtils.ScaleAdToDisplay(textureDimensions, new PointD(Viewport.ActualWidth, Viewport.ActualHeight), false); prop = 1.0f / ((1.0f * textureDimensions.first / textureDimensions.second) / (1.0f * Viewport.ActualWidth / Viewport.ActualHeight)); // wychodzimy poza ekran if (scale.Y * prop > 1.0f) { float scalingFactor = 1.0f / (scale.Y * prop); scale.X *= scalingFactor; scale.Y *= scalingFactor; } if (scale.X * prop > 1.0f) { float scalingFactor = 1.0f / (scale.X * prop); scale.X *= scalingFactor; scale.Y *= scalingFactor; } // scale.X *= 0.5f; scale.Y *= 0.5f; } overlay.SetScale(scale.X, scale.Y * prop); animation = new EffectTextureAnimation(null, unit, screenTimes[i - 1], "IntroAnimation", VisibilityNodeAnimation.VisibilityType.VISIBLE, VisibilityNodeAnimation.VisibilityType.VISIBLE); animation.Enabled = true; animation.Looped = true; OverlayContainer container = overlay.GetChild("Wof/IntroScreen"); container.MaterialName = currentMaterialName; EffectsManager.Singleton.AddCustomEffect(animation); lastChange = DateTime.Now; return(true); }