//################################# // Sound //################################# protected void PlayExplosionSound(Vector3D pos) { var curListenerPos = new Vector3D(Global.Camera.Target.X, Global.Camera.Target.Y, Global.Camera.Target.Z); _engine.SetListenerPosition(curListenerPos, new Vector3D(0, 0, 1)); Random _rand = new Random();; switch (_rand.Next(0, 3)) { case 0: var _explosionSound = _engine.Play3D(_explosionSource, pos.X, pos.Y, pos.Z, false, true, true); _explosionSound.Volume = Global.SpeakerVolume / 10; _explosionSound.Paused = false; break; case 1: var _explosionSound1 = _engine.Play3D(_explosionSource1, pos.X, pos.Y, pos.Z, false, true, true); _explosionSound1.Volume = Global.SpeakerVolume / 10; _explosionSound1.Paused = false; break; case 2: var _explosionSound2 = _engine.Play3D(_explosionSource2, pos.X, pos.Y, pos.Z, false, true, true); _explosionSound2.Volume = Global.SpeakerVolume / 10; _explosionSound2.Paused = false; break; case 3: var _explosionSound3 = _engine.Play3D(_explosionSource3, pos.X, pos.Y, pos.Z, false, true, true); _explosionSound3.Volume = Global.SpeakerVolume / 10; _explosionSound3.Paused = false; break; } }
//################################# // LoadContent //################################# public override void LoadContent() { _stationSymbol = new UIItem(); _enemySymbol = new UIItem(); _stationSymbol.LoadContent("Images/station_icon", 4); _enemySymbol.LoadContent("Images/hit_marker", 4); _droneFleet.replaceOldDrone(new Vector3(150, 0, 100)); Global.Camera = new Camera(Global.GraphicsManager.GraphicsDevice.DisplayMode.AspectRatio, 10000f, MathHelper.ToRadians(45), 1f, Global.CameraPosition, _droneFleet.GetActiveDrone().Position, Vector3.Up); _station.LoadContent(); _sphere.LoadContent(); _asteroidField.LoadContent(); _ui.LoadContent(_droneFleet); _frame.LoadContent(); _waveBuilder.LoadContent(); _planet.LoadContent(); //Effects _stationEffect = Global.ContentManager.Load <Effect>("Effects/stationEffect"); //Sounds //playing the sound _soundEngine.setListenerPosToCameraTarget(); _soundEngine.AddSoundSourceFromFile("openShop", "Content/Media/Effects/OpenShop.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource", "Content/Media/Effects/Objects/Explosion4.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource1", "Content/Media/Effects/Objects/Explosion1.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource2", "Content/Media/Effects/Objects/Explosion2.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource3", "Content/Media/Effects/Objects/Explosion3.wav"); _soundEngine.AddSoundSourceFromFile("astexplosionSource1", "Content/Media/Effects/Objects/ExplosionAst1.wav"); _soundEngine.AddSoundSourceFromFile("astexplosionSource2", "Content/Media/Effects/Objects/ExplosionAst2.wav"); _soundEngine.AddSoundSourceFromFile("astexplosionSource3", "Content/Media/Effects/Objects/ExplosionAst3.wav"); _soundEngine.AddSoundSourceFromFile("hitSound", "Content/Media/Effects/Objects/GetHitShips.wav"); //Global.Music = _soundEngine.Play2D("explosionSource3", Global.MusicVolume / 10, false); captainDialog.LoadContent(); captain.LoadContent("Images/captain", 4); // X = left/right _soundEngine.setListenerPosToCameraTarget(); var pos = Global.Camera.Target; Global.Music = _soundEngine.Play3D("explosionSource3", Global.MusicVolume / 10, Global.Camera.Target, false); }
//################################# // LoadContent //################################# public override void LoadContent() { _stationSymbol = new UIItem(); _enemySymbol = new UIItem(); _stationSymbol.LoadContent("Images/station_icon", 4); _enemySymbol.LoadContent("Images/hit_marker", 4); _asteroid1 = Global.ContentManager.Load <Model>("Models/asteroid"); _asteroid2 = Global.ContentManager.Load <Model>("Models/asteroid2"); _asteroid3 = Global.ContentManager.Load <Model>("Models/asteroid3"); _astList.Add(new Asteroid(_asteroid1, new Vector3(250, 0, 150), 0, Vector3.Zero, 0, false)); _astList.Add(new Asteroid(_asteroid2, new Vector3(350, 0, 150), 0, Vector3.Zero, 0, false)); _astList.Add(new Asteroid(_asteroid3, new Vector3(450, 0, 150), 0, Vector3.Zero, 0, false)); foreach (Asteroid ast in _astList) { ast.LoadContent(); } _effectList.Add("Simple Explosion"); _effectList.Add("Ship Explosion"); _effectList.Add("Bomb Explosion"); _dialog = new Dialog(Global.GraphicsManager.GraphicsDevice.Viewport.Width - 380, Global.GraphicsManager.GraphicsDevice.Viewport.Height - 100, 70, 360, 8, false, true); _dialog.LoadContent(); _droneFleet.replaceOldDrone(new Vector3(150, 0, 100)); Global.Camera = new Camera(Global.GraphicsManager.GraphicsDevice.DisplayMode.AspectRatio, 10000f, MathHelper.ToRadians(45), 1f, Global.CameraPosition, _droneFleet.GetActiveDrone().Position, Vector3.Up); _station.LoadContent(); _sphere.LoadContent(); _asteroidField.LoadContent(); _ui.LoadContent(_droneFleet); _frame.LoadContent(); _waveBuilder.LoadContent(); _boidBuilder.LoadContent(); _planet.LoadContent(); //Effects _stationEffect = Global.ContentManager.Load <Effect>("Effects/stationEffect"); //Sounds //playing the sound _soundEngine.setListenerPosToCameraTarget(); _soundEngine.AddSoundSourceFromFile("openShop", "Content/Media/Effects/OpenShop.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource", "Content/Media/Effects/Objects/Explosion4.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource1", "Content/Media/Effects/Objects/Explosion1.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource2", "Content/Media/Effects/Objects/Explosion2.wav"); _soundEngine.AddSoundSourceFromFile("explosionSource3", "Content/Media/Effects/Objects/Explosion3.wav"); _soundEngine.AddSoundSourceFromFile("astexplosionSource1", "Content/Media/Effects/Objects/ExplosionAst1.wav"); _soundEngine.AddSoundSourceFromFile("astexplosionSource2", "Content/Media/Effects/Objects/ExplosionAst2.wav"); _soundEngine.AddSoundSourceFromFile("astexplosionSource3", "Content/Media/Effects/Objects/ExplosionAst3.wav"); _soundEngine.AddSoundSourceFromFile("hitSound", "Content/Media/Effects/Objects/GetHitShips.wav"); //Global.Music = _soundEngine.Play2D("explosionSource3", Global.MusicVolume / 10, false); captainDialog.LoadContent(); captain.LoadContent("Images/captain", 4); // X = left/right _soundEngine.setListenerPosToCameraTarget(); var pos = Global.Camera.Target; Global.Music = _soundEngine.Play3D("explosionSource3", Global.MusicVolume / 10, Global.Camera.Target, false); }