public override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { _manager.NextGameState(GameStateManager.GameStates.MainMenu); } if (Keyboard.GetState().IsKeyDown(Keys.F1)) { _collide = !_collide; _hit.Play(0.5f, 1, 1); } _ship.Update(gameTime); _camera.Update(gameTime); _plane.Update(gameTime); _asteroids.Update(gameTime); if (_collide) { Collide(gameTime); } if (_ammo > 0) { _shootTime = _shootTime.Subtract(gameTime.ElapsedGameTime); if (_shootTime.TotalSeconds <= 0) { if (Keyboard.GetState().IsKeyDown(Keys.Space)) { SpawnBullet(gameTime); _ammo--; _laser.Play(0.2f, 0f, 0); _shootTime = TimeSpan.FromMilliseconds(150); } } } if (_ammo <= 0) { _reloadTime = _reloadTime.Subtract(gameTime.ElapsedGameTime); if (_reloadTime.TotalSeconds <= 0) { _reloadTime = TimeSpan.FromSeconds(3); _ammo = 20; } } foreach (var bullet in _bulletList) { bullet.Update(gameTime); } if (_health <= 0) { _manager.NextGameState(GameStateManager.GameStates.GameOver); } }
public void Update(float deltaTime) { ShipController.Update(deltaTime); AsteroidField.Update(deltaTime); }