public override void Update(GameTime gameTime) { _playerRespawnTimer.Update(gameTime); if (_gameOver) { _gameOverTimer.Update(gameTime); if (_gameOverTimer.Completed) { GameOverWaitFinished?.Invoke(this, null); return; } } else if (_player.IsDestroyed && _playerRespawnTimer.Completed && _shotManager.ShotCount == 0 /* && _enemyManager.EnemyCount == 0*/) { //StartGame(); SpawnPlayer(); } _starField.Update(gameTime); _asteroidManager.Update(gameTime); _player.Update(gameTime); _shotManager.Update(gameTime); _enemyManager.Update(gameTime); _pieceExplosionManager.Update(gameTime); _pointExplosionManager.Update(gameTime); // needs to come after everything has updated as this is responsible for providing // input for next Update routine _collisionEngine.Update(gameTime); }
/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { BringMainMenu(); } // Exit(); // TODO: Add your update logic here switch (gameState) { case GameState.MainMenu: menuManager.Update(ref gameState, this); audioManager.pauseBGM(); break; case GameState.Gameplay: sunManager.Update(gameTime, scoreManager); orbitManager.Update(GraphicsDevice, planetManager, audioManager); planetManager.Update(GraphicsDevice, gameTime); asteroidManager.Update(gameTime, GraphicsDevice, sunManager, scoreManager, planetManager, audioManager); scoreManager.Update(gameTime, sunManager, planetManager, GraphicsDevice); audioManager.resumeBGM(); break; case GameState.Credits: audioManager.pauseBGM(); break; } base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (!gameOver) { gameOver = (player.Health.Value <= 0); if (gameOver) { MediaPlayer.Stop(); } player.Update(gameTime); tunnel.Update(gameTime); bulletManager.Update(gameTime); asteroidManager.Update(gameTime); pgen.Update(gameTime); if (tunnel.getColliding(player.Position, 1.0f)) { player.damage(100); } asteroidManager.checkCollisions(gameTime); bulletManager.CheckCollisions(asteroidManager.AllAsteroids); // Update all other game components base.Update(gameTime); } }
public void Update(GameTime gameTime) { playerManager.Update(gameTime); eventManager.Update(gameTime); starManager.Update(gameTime); itemManager.Update(gameTime); crateManager.Update(gameTime); asteroidManager.Update(gameTime); strandedManager.Update(gameTime); particleManager.Update(gameTime); cloudManager.Update(gameTime); projectileManager.Update(gameTime); guiManager.Update(gameTime); debugManager.Update(gameTime); }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } switch (gameState) { case GameStates.TitleScreen: titleScreenTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (titleScreenTimer >= titleScreenDelayTime) { if ((Keyboard.GetState().IsKeyDown(Keys.Space)) || (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed)) { playerManager.LivesRemaining = playerStartingLives; playerManager.PlayerScore = 0; ResetGame(); gameState = GameStates.Playing; } } break; case GameStates.Playing: starField.Update(gameTime); asteroidManager.Update(gameTime); playerManager.Update(gameTime); enemyManager.Update(gameTime); explosionManager.Update(gameTime); collisionManager.CheckCollisions(); if (playerManager.Destroyed) { playerDeathTimer = 0f; enemyManager.Active = false; playerManager.LivesRemaining--; if (playerManager.LivesRemaining < 0) { gameState = GameStates.GameOver; } else { gameState = GameStates.PlayerDead; } } break; case GameStates.PlayerDead: playerDeathTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; starField.Update(gameTime); asteroidManager.Update(gameTime); enemyManager.Update(gameTime); playerManager.PlayerShotManager.Update(gameTime); explosionManager.Update(gameTime); if (playerDeathTimer >= playerDeathDelayTime) { ResetGame(); gameState = GameStates.Playing; } break; case GameStates.GameOver: playerDeathTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; starField.Update(gameTime); asteroidManager.Update(gameTime); enemyManager.Update(gameTime); playerManager.PlayerShotManager.Update(gameTime); explosionManager.Update(gameTime); if (playerDeathTimer >= playerDeathDelayTime) { gameState = GameStates.TitleScreen; } break; } base.Update(gameTime); }