public virtual void ResumeSound() { if (cue != null && cue.IsPaused) { cue.Resume(); } }
/// <summary> /// Begins playback of this sound, or resumes playback (if it has been paused) /// </summary> #endregion public void Play() { if (mCue.IsDisposed || mCue.IsStopped) { // Get the cue again, since it has gone out of scope mCue = AudioManager.GetCue(mCueName, mSoundBankFile); // Setting this will reset the variables. Variables.Cue = mCue; if (OnCueRetrieved != null) { OnCueRetrieved(); } } if (mCue.IsPaused) { mCue.Resume(); } else if (!mCue.IsPlaying && mCue.IsPrepared) { if (OnCueRetrieved != null) { OnCueRetrieved(); } mCue.Play(); } }
public void EndBossEvent() { mBossEvent = false; mMusicName = mMusic.Name; mBossMusic.Stop(AudioStopOptions.Immediate); mMusic.Resume(); }
public void resume() { if (cue.IsPaused) { cue.Resume(); } }
/// <summary> /// Resume background music /// </summary> public static void ResumeBackgroundMusic() { if (backgroundMusic.IsPaused) { backgroundMusic.Resume(); } }
public void Toggle(string cueName) { if (cues.ContainsKey(cueName)) { Cue cue = cues[cueName]; if (cue.IsPaused) { cue.Resume(); } else if (cue.IsPlaying) { cue.Pause(); } else //played but stopped { //need to reget cue if stopped Play(cueName); } } else //never played, need to reget cue { Play(cueName); } }
protected void UpdateInput() { KeyboardState key = Keyboard.GetState(); if (key.IsKeyDown(Keys.Up)) { if (engineSound == null) { engineSound = soundBank.GetCue("engine_2"); engineSound.Play(); } else if (engineSound.IsPaused) { engineSound.Resume(); } } viper.Update(key); // In case you get lost, press A to warp back to the center. if (key.IsKeyDown(Keys.Space)) { viper.position = Vector3.Zero; viper.velocity = Vector3.Zero; viper.Rotation = 0.0f; } }
//resumes a paused 2D cue public void ResumeCue(string cueName) { Cue cue = this.soundBank.GetCue(cueName); if ((cue != null) && (cue.IsPaused)) { cue.Resume(); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } //Блок управления проигрыванием по нажатию клавиш //При нажатии клавиши A приостанавливаем проигрывание KeyboardState kbState = Keyboard.GetState(); if (kbState.IsKeyDown(Keys.A)) { musicCue.Pause(); } //При нажатии клавиши S продолжаем проигрывание музыки if (kbState.IsKeyDown(Keys.S)) { musicCue.Resume(); } //При нажатии клавиши D переходим на следующую песню if (kbState.IsKeyDown(Keys.D)) { countDPress++; if (countDPress == 1) //Для того, чтобы переключение происходило только 1 раз при нажатии { if (curSong < numberOfSongs) { curSong++; } else { curSong = 1; } musicCue.Stop(AudioStopOptions.Immediate); musicCue = soundBank.GetCue(curSong.ToString()); musicCue.Play(); } } if (kbState.IsKeyUp(Keys.D)) { countDPress = 0; } if (!isGameRun) { musicCue.Stop(AudioStopOptions.Immediate); } audioEngine.Update(); base.Update(gameTime); }
public void Resume() { if (modMusic != null) { modMusic.Resume(); } else { cue.Resume(); } }
public override void UnpauseRoom() { foreach (var current in m_rainFG) { current.ResumeAnimation(); } if (m_rainSFX != null && m_rainSFX.IsPaused) { m_rainSFX.Resume(); } }
/// <summary> /// Unpauses the sound cue if it is pause. If it is not paused, it starts the sound /// cue from the beginning. /// </summary> public void Unpause() { if (Cue.IsPaused) { Cue.Resume(); } else { Play(); } }
public void PlayEngineSound() { if (engineSound == null || engineSound.IsStopped) { engineSound = game.soundBank.GetCue(engineSoundName); engineSound.Play(); } else if (engineSound.IsPaused) { engineSound.Resume(); } }
/// <summary> /// Resume Background Music /// </summary> public void ResumeBgMusic() { if (!isInitialized) { MessageBox.Show("Audio System Not Initialized !", "Error !"); } if (bgMusic != null && bgMusic.IsPaused) { bgMusic.Resume(); } }
/// <summary> /// Plays the cue with a fade in effect. If it is pause, it will resume the cue. /// </summary> public void Play() { _FadeTimer = 0f; _FadeState = FadeStates.FadeIn; if (IsPaused) { Cue.Resume(); } else { Cue.Play(); } }
/*************************************************************************************************************************/ /// <summary> /// Plays the sound of the ship moving. /// </summary> void PlayEngineSound() { if (engineSound == null) { engineSound = soundBank.GetCue("engine_2"); engineSound.Play(); } else if (engineSound.IsPaused) { engineSound.Resume(); } }
/// <summary> /// Allows the unit to update itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param>> public override void Update(GameTime gameTime) { KeyboardState keyboard = Keyboard.GetState(); musicCountdown -= gameTime.ElapsedGameTime.Milliseconds; if (musicCountdown <= 0) { if (keyboard.IsKeyDown(Keys.M)) { if (trackCue.IsPaused) { trackCue.Resume(); } else { trackCue.Pause(); } musicCountdown = musicDelay; } else { musicCountdown = 0; } } foreach (Event ev in events) { switch (ev.EventId) { case (int)MyEvent.C_ATTACK_BULLET_END: soundBank.PlayCue("shot"); break; case (int)MyEvent.G_NextLevel: levelCompleteCue.Play(); levelCompleteRunning = true; break; case (int)MyEvent.M_HIT: soundBank.PlayCue("monsterHit"); break; case (int)MyEvent.M_BITE: soundBank.PlayCue("Bite"); break; case (int)MyEvent.G_GameOver: soundBank.PlayCue("ScreamAndDie"); break; } } if (levelCompleteRunning && levelCompleteCue.IsStopped) { levelCompleteRunning = false; myGame.mediator.fireEvent(MyEvent.G_NextLevel_END_OF_MUSIC); } events.Clear(); base.Update(gameTime); }
public override void UnpauseRoom() { foreach (var current in m_rainFG) { current.ResumeAnimation(); } if (m_rainSFX != null && m_rainSFX.IsPaused) { m_rainSFX.Resume(); } m_enchantress.ResumeAnimation(); m_blacksmith.ResumeAnimation(); m_architect.ResumeAnimation(); m_tollCollector.ResumeAnimation(); base.UnpauseRoom(); }
public void Pause(Cue cue) { if (cue.IsPaused) { cue.Resume(); } else if (cue.IsPlaying) { cue.Pause(); } else { // If stopped, create a new cue. cue = soundBank.GetCue(cue.Name); cue.Play(); } }
private void PlayBGM() { if (bgm != null && !bgm.IsStopped) { if (!bgm.IsPlaying && !bgm.IsStopping) { bgm.Play(); } if (bgm.IsPaused) { bgm.Resume(); } } else { ChangeBgm(bgmNames[PublicRandom.Next(3)]); } }
protected void UpdateInput() { // Get the game pad state. GamePadState currentState = GamePad.GetState(PlayerIndex.One); if (currentState.IsConnected) { ship.Update(currentState); // Set some audio based on whether we're pressing a trigger. if (currentState.Triggers.Right > 0) { if (engineSound == null) { engineSound = soundBank.GetCue("engine_2"); engineSound.Play(); } else if (engineSound.IsPaused) { engineSound.Resume(); } } else { if (engineSound != null && engineSound.IsPlaying) { engineSound.Pause(); } } // In case you get lost, press B to warp back to the center. if (currentState.Buttons.B == ButtonState.Pressed) { ship.Position = Vector3.Zero; ship.Velocity = Vector3.Zero; ship.Rotation = 0.0f; ship.isActive = true; // Make a sound when we warp. soundBank.PlayCue("hyperspace_activate"); } } }
public void Play() { if (cue.IsPaused) { cue.Resume(); return; } if (cue.IsPlaying) { return; } if (cue.IsStopped) { cue = sb.GetCue(cueName); Volume = vol; } cue.Play(); }
public override void Update(GameTime gameTime) { KeyboardState keyboard = Keyboard.GetState(); musicCountdown -= gameTime.ElapsedGameTime.Milliseconds; if (musicCountdown <= 0) { if (keyboard.IsKeyDown(Keys.M)) { if (trackCue.IsPaused) { trackCue.Resume(); } else { trackCue.Pause(); } musicCountdown = musicDelay; } else { musicCountdown = 0; } } foreach (Event ev in events) { switch (ev.EventId) { case (int)MyEvent.C_ATTACK_BULLET_END: soundBank.PlayCue("shot"); break; case (int)MyEvent.M_BITE: soundBank.PlayCue("Bite"); break; case (int)MyEvent.G_GameOver: soundBank.PlayCue("ScreamAndDie"); break; } } events.Clear(); base.Update(gameTime); }
private void PlayBeamSound() { if (turretWeapon.firetype != Weapon.fireType.Beam) { return; } if (!turretWeapon.beamIsFiring()) { return; } try { if (laserCue == null) { laserCue = FrameworkCore.audiomanager.Play3DCue(sounds.Weapon.laser, parentShip.audioEmitter); } // a sound can be paused and playing at the same time........ UGH! if (laserCue.IsPaused) { laserCue.Resume(); return; } if (laserCue.IsPlaying) { return; } laserCue.Play(); } catch { } }
public void ResumeCue(Cue cue) { cue.Resume(); }
protected void UpdateInput() { //Obtener el estado del keyboard KeyboardState currentKeyState = Keyboard.GetState(); // Get the game pad state. GamePadState currentState = GamePad.GetState(PlayerIndex.One); //if (currentState.IsConnected) //{ ship.Update2(currentKeyState); // Set some audio based on whether we're pressing a trigger. if (currentState.Triggers.Right > 0) { if (engineSound == null) { engineSound = soundBank.GetCue("engine_2"); engineSound.Play(); } else if (engineSound.IsPaused) { engineSound.Resume(); } } else { if (engineSound != null && engineSound.IsPlaying) { engineSound.Pause(); } } // In case you get lost, press B to warp back to the center. if (currentState.Buttons.B == ButtonState.Pressed && lastState.Buttons.B == ButtonState.Released) { ship.Position = Vector3.Zero; ship.Velocity = Vector3.Zero; ship.Rotation = 0.0f; ship.isActive = true; score -= GameConstants.WarpPenalty; // Make a sound when we warp. soundBank.PlayCue("hyperspace_activate"); } //} //are we shooting? if (ship.isActive && currentState.Buttons.A == ButtonState.Pressed && lastState.Buttons.A == ButtonState.Released) { //add another bullet. Find an inactive bullet slot and use it //if all bullets slots are used, ignore the user input for (int i = 0; i < GameConstants.NumBullets; i++) { if (!bulletList[i].isActive) { bulletList[i].direction = ship.RotationMatrix.Forward; bulletList[i].speed = GameConstants.BulletSpeedAdjustment; bulletList[i].position = ship.Position + (200 * bulletList[i].direction); bulletList[i].isActive = true; score -= GameConstants.ShotPenalty; soundBank.PlayCue("tx0_fire1"); break; //exit the loop } } } lastState = currentState; }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { GamePadState newpadState = GamePad.GetState(PlayerIndex.One); KeyboardState keyboardState = Keyboard.GetState(); //setting the getstate to keyboardstate previousMouseState = Mouse.GetState(); //setting the getstate to the previousMousestate mouseState = Mouse.GetState(); //setting the getstate to the mousestate mouseX = mouseState.X; //setting the mouse X position mouseY = mouseState.Y; //setting the mouse Y position // if (keyboardState.IsKeyDown(Keys.Enter) || (mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Pressed || (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed))) // { if (game == 1) { //play if (Keyboard.GetState().IsKeyDown(Keys.Enter) || (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed)) { Sonya.playerPosition = new Vector2(100f, 400f); SubZero.playerPosition = new Vector2(1050f, 400f); selection.Play(1f, .1f, .5f); timer = 99; SonyaHealth = 550; SubZHealth = 550; SonyaGreenBar.update(SonyaHealth); SubZGreenBar.update(SonyaHealth); Sonya.playerAnimation.playerPos = new Vector2(100f, 400f); SubZero.playerAnimation.playerPos = new Vector2(1050f, 400f); Sonya.looping = true; SubZero.looping = true; Sonya.playerAnimation.flipHorizontal = false; SubZero.playerAnimation.flipHorizontal = true; endMenuTimer = 100; drawBars = true; gameEnded = false; Sonya.gameEnded = false; SubZero.gameEnded = false; Sonya.playerAnimation.currentFrame = Vector2.Zero; SubZero.playerAnimation.currentFrame = Vector2.Zero; game = 2; } } if (game == 2) { //return if ((GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)) { selection.Play(1f, .1f, .5f); game = 3; } } if (game == 4) { //play if ((GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)) { selection.Play(1f, .1f, .5f); game = 3; } } if (game == 5) { //play if (Keyboard.GetState().IsKeyDown(Keys.Enter) || (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)) { selection.Play(1f, .1f, .5f); player1 = 0; player2 = 0; SonyaHealth = 550; SubZHealth = 550; musicCue.Resume(); game = 1; } //quit if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)) { selection.Play(1f, .1f, .5f); this.Exit(); } } // } if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } if (game == 3) { Sonya.Update(gameTime); SubZero.Update(gameTime); if (Sonya.playerAnimation.playerPos.X > SubZero.playerAnimation.playerPos.X && Sonya.currentState == (int)Sprite.Idle) { Sonya.playerAnimation.flipHorizontal = true; } if (Sonya.playerAnimation.playerPos.X < SubZero.playerAnimation.playerPos.X && Sonya.currentState == (int)Sprite.Idle) { Sonya.playerAnimation.flipHorizontal = false; } if (SubZero.playerAnimation.playerPos.X < Sonya.playerAnimation.playerPos.X && SubZero.currentState == (int)Sprite.Idle) { SubZero.playerAnimation.flipHorizontal = false; } if (SubZero.playerAnimation.playerPos.X > Sonya.playerAnimation.playerPos.X && SubZero.currentState == (int)Sprite.Idle) { SubZero.playerAnimation.flipHorizontal = true; } // clock start and update if (clock.isRunning == false) { //count 10 seconds down clock.start(timer); } else { clock.checkTime(gameTime); } } //keyboard controls //if (game == 3 || game == 4) //{ // if (keyboardState.IsKeyDown(Keys.P)) // { // game = 4; // } // if (keyboardState.IsKeyDown(Keys.R)) // { // game = 3; // } //} if (game == 3) { if ((GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed)) { game = 4; } } // Test if Sonya Gets Attacked // SonyaHealthEffect = collision.TestCollision(Sonya.sonyaHitBox.playerHB, SubZero.subZAttackHB.playerHB, Sonya.currentState, SubZero.currentState); if (SonyaHealthEffect > 10) { Sonya.beenHit = true; } if (SonyaHealthEffect != 0 && SonyaHealth != 0) { if (Sonya.playerPosition.X > SubZero.playerPosition.X) { Sonya.playerAnimation.playerPos.X += pushBack; Sonya.playerPosition.X += pushBack;//Sonya.playerAnimation.playerPos; if (Sonya.playerPosition.X >= graphics.PreferredBackBufferWidth - 135) { Sonya.playerAnimation.playerPos.X = graphics.PreferredBackBufferWidth - 135; Sonya.playerPosition.X = graphics.PreferredBackBufferWidth - 135; } } else { Sonya.playerAnimation.playerPos.X -= pushBack; Sonya.playerPosition.X -= pushBack;//Sonya.playerAnimation.playerPos; if (Sonya.playerPosition.X <= 0) { Sonya.playerAnimation.playerPos.X = 0; Sonya.playerPosition.X = 0; } } if (game == 3) { S_hurt.Play(1f, .1f, .5f); } SonyaHealth -= SonyaHealthEffect; SonyaGreenBar.update(SonyaHealth); } // Test is Sub Gets Attacked // SubZeroHealthEffect = collision.TestCollision(SubZero.subZeroHitBox.playerHB, Sonya.sonyaAttackHB.playerHB, SubZero.currentState, Sonya.currentState); if (SubZeroHealthEffect > 10) { SubZero.beenHit = true; } if (SubZeroHealthEffect != 0 && SubZHealth != 0) { if (Sonya.playerPosition.X > SubZero.playerPosition.X) { SubZero.playerAnimation.playerPos.X -= pushBack; SubZero.playerPosition.X -= pushBack; if (SubZero.playerPosition.X <= 0) { SubZero.playerAnimation.playerPos.X = 0; SubZero.playerPosition.X = 0; } } else { SubZero.playerAnimation.playerPos.X += pushBack; SubZero.playerPosition.X += pushBack; if (SubZero.playerPosition.X >= graphics.PreferredBackBufferWidth - 140) { SubZero.playerAnimation.playerPos.X = graphics.PreferredBackBufferWidth - 140; SubZero.playerPosition.X = graphics.PreferredBackBufferWidth - 140; } } if (game == 3) { SZ_hurt.Play(1f, .1f, .5f); } SubZHealth -= SubZeroHealthEffect; SubZGreenBar.update(SubZHealth); } if (game == 3) { //clock runs out if (clock.isFinished) { Sonya.gameEnded = true; SubZero.gameEnded = true; if (SonyaHealth > SubZHealth) { player1 = 1; Sonya.winGame = true; SubZero.winGame = false; } if (SubZHealth > SonyaHealth) { player2 = 1; Sonya.winGame = false; SubZero.winGame = true; } musicCue.Pause(); game = 5; } if (SonyaHealth <= 0 || SubZHealth <= 0) { Sonya.gameEnded = true; SubZero.gameEnded = true; if (SonyaHealth <= 0) { player2 = 1; Sonya.winGame = false; SubZero.winGame = true; } if (SubZHealth <= 0) { player1 = 1; Sonya.winGame = true; SubZero.winGame = false; } musicCue.Pause(); clock.reset(); timer = 0; drawBars = false; endMenuTimer -= (int)gameTime.ElapsedGameTime.TotalMilliseconds / 15; if (endMenuTimer <= 0) { game = 5; } } } base.Update(gameTime); }
public override void Resume() => cue.Resume();
public void Resume() { cue.Resume(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } KeyboardState keyboard = Keyboard.GetState(); if (gameState == GameState.Menu) { menuScreen.Update(gameTime); } if (gameState == GameState.NextLevelScreen && nextLevelScreen.IsDone) { gameState = GameState.Play; nextLevelScreen.IsDone = false; scoreScreen.IsDone = false; InitNewLevel(); } if (gameState == GameState.Menu && keyboard.IsKeyDown(Keys.Enter)) { gameState = GameState.NextLevelScreen; } if (gameState == GameState.Play || gameState == GameState.End) { if (!pauseIsActive) { GamePlayUpdate(gameTime, keyboard); } } if (gameState == GameState.Play && !prevEnterState && keyboard.IsKeyDown(Keys.Enter)) { if (pauseIsActive) { pauseIsActive = false; pauseBlinkTime = 0; if (cueEnemyMove.IsPaused) { cueEnemyMove.Resume(); } else if (!cueEnemyMove.IsPlaying && !cueEnemyMove.IsPaused) { cueEnemyMove.Play(); } } else { pauseIsActive = true; if (!cueEnemyMove.IsPaused) { cueEnemyMove.Pause(); } soundBank.PlayCue("w5_pause"); } } prevEnterState = keyboard.IsKeyDown(Keys.Enter); if (gameState == GameState.NextLevelScreen) { nextLevelScreen.Update(gameTime); if (nextLevelScreen.IsDone && keyboard.IsKeyDown(Keys.Enter)) { gameState = GameState.Play; } } if (gameState == GameState.End) { if (gameOverDrawRectangle.Y > GameConstants.GAME_OVER_Y_POSITION) { gameOverDrawRectangle.Y -= 4; } else { gameOverScoreDelay += gameTime.ElapsedGameTime.Milliseconds; if (gameOverScoreDelay > 3000) { if (!cueEnemyMove.IsPaused) { cueEnemyMove.Pause(); } if (!cuePlayerMove.IsPaused) { cuePlayerMove.Pause(); } scoreScreen.UpdateData(currentLevel); gameState = GameState.ScoreScreen; } } } if (gameState == GameState.ScoreScreen) { if (scoreScreen.IsDone) { enemyTanks.Clear(); bullets.Clear(); explosions.Clear(); gameOverScoreDelay = 0; gameOverDrawRectangle.Y = GameConstants.FIELD_HEIGHT; if (globalGameState == GameState.Play) { // adding level currentLevel += 1; currentLevel = currentLevel < levelData.Count() ? currentLevel : 0; nextLevelScreen.ChangeStage(currentLevel); gameState = GameState.NextLevelScreen; } else { nextLevelScreen.ChangeStage(1); gameState = GameState.EndGameScreen; soundBank.PlayCue("w11_gameOver"); } } else { scoreScreen.Updade(gameTime); } } if (gameState == GameState.EndGameScreen) { if (endGameScreenDelay < 3000) { endGameScreenDelay += gameTime.ElapsedGameTime.Milliseconds; } else { endGameScreenDelay = 0; currentLevel = 1; gameState = GameState.Menu; globalGameState = GameState.Play; } } base.Update(gameTime); }