static void playLoop(ref Cue cue) { if (!cue.IsPlaying) { StopLoops(); InitCues(); cue.Play(); } }
public FieldPong() { graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services); graphics.PreferredBackBufferWidth = 1024; graphics.PreferredBackBufferHeight = 768; graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0; graphics.SynchronizeWithVerticalRetrace = true; physicsSimulator = new PhysicsSimulator(new Vector2(0)); physicsSimulator.AllowedPenetration = 0.3f; physicsSimulator.BiasFactor = 1.0f; Services.AddService(typeof(PhysicsSimulator), physicsSimulator); screenManager = new ScreenManager(this); Components.Add(screenManager); bloomProcessor = new BloomPostProcessor(this); Components.Add(bloomProcessor); // Uncomment this to monitor the FPS: //fpsCounter = new FrameRateCounter(this); //Components.Add(fpsCounter); audioEngine = new AudioEngine("Content\\Audio\\FieldPongAudio.xgs"); waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb"); backgroundMusic = soundBank.GetCue("GameSong0010 16 Bit"); backgroundMusic.Play(); }
/// <summary> /// Plays a cue with static 3D positional information. /// </summary> /// <remarks> /// Commonly used for short lived effects. To dynamically change the 3D /// positional information on a cue over time use <see cref="GetCue"/> and <see cref="Cue.Apply3D"/>.</remarks> /// <param name="name">The name of the cue to play.</param> /// <param name="listener">The listener state.</param> /// <param name="emitter">The cue emitter state.</param> public void PlayCue(string name, AudioListener listener, AudioEmitter emitter) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } XactSound[] sounds; if (!_sounds.TryGetValue(name, out sounds)) { throw new InvalidOperationException(); } float [] probs; if (!_probabilities.TryGetValue(name, out probs)) { throw new ArgumentException(); } IsInUse = true; var cue = new Cue(_audioengine, name, sounds, probs); cue.Prepare(); cue.Apply3D(listener, emitter); cue.Play(); }
public void PlayCue( string name, AudioListener listener, AudioEmitter emitter ) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (!INTERNAL_cueData.ContainsKey(name)) { throw new InvalidOperationException("name not found!"); } Cue newCue = new Cue( INTERNAL_baseEngine, INTERNAL_waveBankNames, name, INTERNAL_cueData[name], true ); newCue.Apply3D(listener, emitter); newCue.Play(); }
public void PlayBuzzer() { fxCat.SetVolume(10f); cue = soundBank.GetCue("Buzzer"); cue.Play(); fxCat.SetVolume(6f); }
public static void PlayMusic(string name) { StopMusic(); cue = soundBank.GetCue(name); cue.Play(); }
/// <summary> /// Plays a cue. /// </summary> /// <param name="name">Name of the cue to play.</param> public void PlayCue(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } XactSound[] sounds; if (!_sounds.TryGetValue(name, out sounds)) { throw new ArgumentException(); } float [] probs; if (!_probabilities.TryGetValue(name, out probs)) { throw new ArgumentException(); } IsInUse = true; var cue = new Cue(_audioengine, name, sounds, probs); cue.Prepare(); cue.Play(); }
public void TriggerBossEvent() { mBossEvent = true; mMusic.Pause(); mBossMusic = mSounds.GetCue( "boss_music" ); mMusicName = mBossMusic.Name; mBossMusic.Play(); }
void Tower_ZeroHealth(object sender, EventArgs e) { if(heartbeatCue.IsPlaying) heartbeatCue.Stop(AudioStopOptions.Immediate); audioEngine.GetCategory("Drums").Stop(AudioStopOptions.Immediate); outroCue = soundBank.GetCue("Outro"); outroCue.Play(); }
public static void StartMainTheme() { if (mainTheme == null) { mainTheme = soundBank.GetCue("space"); mainTheme.Play(); } }
public DefenderMusic( SoundBank sounds, AudioEngine engine ) { mSounds = sounds; mEngine = engine; mMusic = sounds.GetCue( "stage_music" ); mMusicName = mMusic.Name; mVolume = 1.0f; mMusic.Play(); }
public PlayerShip(Game game, Vector2 position) { Game = game; _soundBank = Game.Services.GetService<SoundBank[]>(); _world = Game.Services.GetService<World>(); krypton = Game.Services.GetService<KryptonEngine>(); thrustLR = _soundBank[0].GetCue("thrust01"); thrustLR.Play(); thrustLR.Pause(); thrustUD = _soundBank[0].GetCue("thrust01"); thrustUD.Play(); thrustUD.Pause(); Position = position; _particleRenderer = Game.Services.GetService<SpriteBatchRenderer>(); //_textures = Game.Services.GetService<Textures>(); //Loadcontentstuff _shiptxture = Game.Content.Load<Texture2D>("player_ship"); _turretTxture = Game.Content.Load<Texture2D>(".\\guns\\turret01"); _centreVect = new Vector2(_shiptxture.Width / 2, _shiptxture.Height / 2); ProximityBox = new Rectangle(0, 0, _shiptxture.Width+Globals.PhysBuffer, _shiptxture.Height + Globals.PhysBuffer); //make ship fixture in for farseer box = BodyFactory.CreateCircle(_world, ConvertUnits.ToSimUnits(_shiptxture.Width / 2), 7.0f); box.BodyType = BodyType.Dynamic; box.Restitution = 0.5f; box.Friction = 0.2f; box.FixedRotation = true; box.LinearDamping = 0.4f; box.Position = ConvertUnits.ToSimUnits(Position.X + _centreVect.X, Position.Y + _centreVect.Y); box.UserData = "player"; //box.OnCollision += Collide; box.OnSeparation += Collide; //make light in krypton var mLightTexture = LightTextureBuilder.CreateConicLight(Game.GraphicsDevice, 256, 2.0f); light = CreateLights(mLightTexture,400); var mLightTexture2 = LightTextureBuilder.CreatePointLight(Game.GraphicsDevice, 64); light2 = CreateLights(mLightTexture2,200); //set up thruster particle _thrustparticle = Game.Content.Load<ParticleEffect>(".\\mercury\\thruster"); _thrustparticle.LoadContent(Game.Content); _thrusterEmitter = (ConeEmitter)_thrustparticle[0]; //_thrusterEmitter.Initialise(); _thrusterEmitter.ParticleTexture = Game.Content.Load<Texture2D>(".\\mercury\\Particle004"); _thrustparticle.Initialise(); _particleRenderer.LoadContent(Game.Content); //_centerVect = new Vector2(_shiptxture.Width / 2,_shiptxture.Width / 2); currentWeapon = new Gun(Game, true, BulletsStats.Plasma01); }
public Music(SoundBank sounds, AudioEngine engine) { this.sounds = sounds; this.engine = engine; music = sounds.GetCue("stage_music"); musicName = music.Name; volume = 1.0f; music.Play(); }
internal void LoadContent() { //Loads the audioengine, wavebank and soundbank engine = new AudioEngine(@"Content/Audio/GameAudio.xgs"); sound = new SoundBank(engine, @"Content/Audio/Sound Bank.xsb"); wave = new WaveBank(engine, @"Content/Audio/Wave Bank.xwb"); trackCue = sound.GetCue(songTitle); trackCue.Play(); }
public void Update() { if( mMusic.IsStopped ) { mMusic = mSounds.GetCue( "stage_music" ); mMusic.Play(); } if( mBossEvent && mBossMusic.IsStopped ) { mBossEvent = false; } }
public override void Activate(bool instancePreserved) { if (!instancePreserved) { if (bgm == null) { bgm = ((GameMain)ScreenManager.Game).AudioEM.GetCue("menuBg1"); bgm.Play(); } } }
public void PlayMusic(string musicName) { if (string.IsNullOrEmpty(musicName)) { musicName = "m_Silence"; } if (musicName != _currentMusic.Name) { _currentMusic = _soundBank.GetCue(musicName); _currentMusic.Play(); } }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { //set gameplay mode theGame.versus = true; //start playing background music backgroundMusic = theGame.GameSoundBank.GetCue("H-Pizzle - Danger Zone (Kenny Loggins)"); if (theGame.soundOn) backgroundMusic.Play(); base.Initialize(); }
public static void Play(String _musicStr) { if (musicStr != _musicStr) { musicStr = _musicStr; if (musicCue != null) musicCue.Dispose(); musicCue = sound.GetCue(musicStr); musicCue.Play(); } }
/// <summary> /// Set the current music track, stopping any existing music track if necessary. /// </summary> /// <param name="trackName">New track name</param> public void MusicTrack(string trackName) { if (currentMusicTrack != null) { if (!(currentMusicTrack.IsStopping || currentMusicTrack.IsStopped)) { currentMusicTrack.Stop(AudioStopOptions.AsAuthored); } } currentMusicTrack = musicSoundBank.GetCue(trackName); currentMusicTrack.Play(); }
public static void Play(String musicName) { if (musicString != musicName) { musicString = musicName; if (musicCue != null) musicCue.Dispose(); // always crashes for unknown reasons musicCue = soundBank.GetCue(musicString); //soundBank.PlayCue(musicString); musicCue.Play(); } }
public void Initialize() { audioEngine = new AudioEngine(@"Content\Audio\FoodFightNow.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Audio\GameMusic.xsb"); _GameOver = soundBank.GetCue("GameOver"); _Background = soundBank.GetCue("Background"); _Background.Play(); _EndPlay = false; _NextLevel = soundBank.GetCue("NextLevel"); _NextLevelSound = false; _Victory = soundBank.GetCue("Victory"); _VictorySound = false; }
public override void Initialize() { base.Initialize(); m_AudioEngine = new AudioEngine(@"Content\Audio\GameSounds.xgs"); m_WaveBank = new WaveBank(m_AudioEngine, @"Content\Audio\Wave Bank.xwb"); m_SoundBank = new SoundBank(m_AudioEngine, @"Content\Audio\Sound Bank.xsb"); m_MusicCategory = m_AudioEngine.GetCategory("Music"); m_EffectsCategory = m_AudioEngine.GetCategory("Default"); // r_Factory.SetSoundBank(m_SoundBank); m_Music = m_SoundBank.GetCue("BGMusic"); m_Music.Play(); }
public AudioManager(Game1 game) : base(game) { myGame = game; events = new List<Event>(); game.mediator.register(this, MyEvent.C_ATTACK_BULLET_END, MyEvent.M_BITE, MyEvent.G_GameOver); audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb"); trackCue = soundBank.GetCue("Cowboy"); trackCue.Play(); trackCue.Pause(); }
/// <summary> /// Loads graphics contents for press start screen. /// </summary> public override void Activate(bool instancePreserved) { if (!instancePreserved) { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "main"); title = content.Load<Texture2D>(@"textures\menu\title"); font = content.Load<SpriteFont>(@"fonts\menuEntry"); if (bgm == null || !bgm.IsPlaying) { bgm = ((GameMain)ScreenManager.Game).AudioEM.GetCue("introBg1"); bgm.Play(); } } }
public static void Play(string musicCueName) { while(!Wave.IsPrepared) Audio.Sound.Update(); if (string.Compare(_musicStr, musicCueName, true, CultureInfo.InvariantCulture) != 0) { _musicStr = musicCueName; if (_musicCue != null) _musicCue.Dispose(); _musicCue = Sound.GetCue(_musicStr); _musicCue.Play(); } }
public EffectPlayer(AudioEngine audioEngine, TowerAudioEngine tae) { this.towerAudioEngine = tae; this.audioEngine = audioEngine; soundBank = new SoundBank(audioEngine, "Content/Effect Sound.xsb"); App.Instance.Model.AddPlayer += new EventHandler<SurfaceTower.Model.EventArguments.PlayerArgs>(OnAddPlayer); App.Instance.Model.RemovePlayer += new EventHandler<SurfaceTower.Model.EventArguments.PlayerArgs>(OnRemovePlayer); App.Instance.Model.NewEnemy += new EventHandler<SurfaceTower.Model.EventArguments.EnemyArgs>(OnNewEnemy); App.Instance.Model.Tower.ZeroHealth += new EventHandler(Tower_ZeroHealth); heartbeatCue = soundBank.GetCue("Hearbeat"); introCue = soundBank.GetCue("Intro"); introCue.Play(); firstPlayerHasJoined = false; }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Load the XACT data audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb"); // Start the soundtrack audio trackCue = soundBank.GetCue("track"); trackCue.Play(); // Play the start sound soundBank.PlayCue("start"); }
public World(Game1 game, ScreenManager screenManager, DeviceManager dev, int level) : base(game, screenManager, dev) { points = 0; currentDistance = 0; GameLib.getInstance().loadGameTextures(); objs = new List<PhysicsObject>(); setVariables(level); mountains = new MountainCtrl(worldLength, horizontalVel); waters = new WaterCtrl(worldLength, horizontalVel); bMountain = new BackMountain(new Vector2(0, 0f)); monster = new Monster(player, this); gameState = GameState.playing; bg = GameLib.getInstance().get(TextureE.bg); bgPos = new Vector2(0, -bg.Height + Game1.height); song = GameLib.getInstance().playCue(SoundE.diez); song.Play(); }
public Menu(Game1 game, ScreenManager screenManager, DeviceManager dev) : base(game, screenManager, dev) { logo = GameLib.getInstance().get(TextureE.logo); buttons = new Button[] { new Button(new Vector2(10, Game1.height - 270), new Vector2(400, 400),TextureE.about), new Button(new Vector2(Game1.width/2 - 500/2 , Game1.height - 330), new Vector2(500, 500),TextureE.start), new Button(new Vector2(Game1.width-390, Game1.height - 270), new Vector2(400, 400),TextureE.exit) }; buttons[1].LayerDepth = 0f; buttons[selected].Focus = true; foreach (Button b in buttons) { b.addAlpha((byte)0); } sound = GameLib.getInstance().playCue(SoundE.once); sound.Play(); }
/// <summary> /// Loads graphics contents for splash screen. /// </summary> public override void Activate(bool instancePreserved) { if (!instancePreserved) { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "main"); bgm = ((GameMain)ScreenManager.Game).AudioEM.GetCue("introBg1"); bgm.Play(); splash1 = content.Load<Texture2D>(@"textures\menu\splash1"); //introVideo = content.Load<Video>(@"movies\LOGO_5M"); //videoPlayer = new VideoPlayer(); //videoPlayer.Play(introVideo); DisplayHoldTime = 3500; //DisplayHoldTime = (int)introVideo.Duration.TotalMilliseconds; } }
public void PlayCue(string name) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } if (!INTERNAL_cueData.ContainsKey(name)) { throw new InvalidOperationException("name not found!"); } Cue newCue = new Cue( INTERNAL_baseEngine, INTERNAL_waveBankNames, name, INTERNAL_cueData[name], true ); newCue.Play(); }
public override void Update(GameTime gameTime) { if (state_ != camera_.CurrentCamera.State) { state_ = camera_.CurrentCamera.State; defaultCategory.SetVolume(50); switch (state_) { case CameraState.Chase: cameraCue = soundBank.GetCue("chase"); cameraCue.Play(); break; case CameraState.Reverse: cameraCue = soundBank.GetCue("reverse"); cameraCue.Play(); break; case CameraState.Dynamic: cameraCue = soundBank.GetCue("dynamic"); cameraCue.Play(); break; case CameraState.TopDown: cameraCue = soundBank.GetCue("top_down"); cameraCue.Play(); break; } } for (int i = 0; i < cueArray.Length; i++) cueArray[i].Apply3D(listener_, CarSoundEmitters.AudioEmitters[i]); if (car_.LinearVelocity.LengthSquared() <= 400) musicCategory.SetVolume(car_.LinearVelocity.LengthSquared() / 16); else if (car_.LinearVelocity.LengthSquared() > 1650) musicCategory.SetVolume(0); else musicCategory.SetVolume(25); base.Update(gameTime); }
public void LoadContent() { engine = new AudioEngine("Content\\Audio\\ButterflyAudio.xgs"); waveBank = new WaveBank(engine, "Content\\Audio\\Waves.xwb"); soundBank = new SoundBank(engine, "Content\\Audio\\Sounds.xsb"); BackgroundMusic = soundBank.GetCue("478503_PlayfulStrollJoyfulOboeMorganCut"); Birdsong = soundBank.GetCue("157536__juskiddink__woodland-birdsong-june"); BackgroundMusic.Play(); Birdsong.Play(); Butterfly.ButterflyTextures = new Texture2D[Enum.GetNames(typeof(Butterfly.ButterflyColors)).Length]; for (int i = 0; i < Butterfly.ButterflyTextures.Length; i++) { Butterfly.ButterflyTextures[i] = SingleColorTextureCreator.Create(myGame.GraphicsDevice, 256, 256, (Butterfly.ButterflyColors)(i)); } player.LoadContent(content); currentLevel.LoadContent(content, myGame.GraphicsDevice.Viewport); //debug code sb = myGame.Services.GetService(typeof(SpriteBatch)) as SpriteBatch; }