public override void Update(GameTime gameTime) { base.Update(gameTime); if (InputHandler.PressedCancel()) { UnloadContent(); StateManager.ChangeState(GameRef.TitleScreen); } else if (InputHandler.KeyPressed(Keys.P)) { GameRef.Pause = !GameRef.Pause; } if (GameRef.Pause) { return; } HandleInput(); _player.Update(gameTime); _moverManager.Update(gameTime); _moverManager.FreeMovers(); }
public void Update(GameTime gameTime) { _endGameTimer.Update(gameTime); if (_endGame) { return; } foreach (var bullet in _bullets) { bullet.Update(gameTime); } foreach (var laser in _lasers) { laser.Update(gameTime); } MoverManager.Update(); CollisionWorld.Update(gameTime); ParticleManager.Update(gameTime); _bullets.RemoveAll(b => !b.Used); }
public void Update(GameTime gameTime) { if (!EndGame() || (GameIsFinished() || TransitioningToEndGame())) { MoverManager.Update(); } if (!_ready) { return; } _cameraZoomTimer.Update(gameTime); _explosionTimer.Update(gameTime); if (_boss != null && (!EndGame() || (GameIsFinished() || TransitioningToEndGame()))) { _boss.Update(gameTime); } if (!EndGame() || (GameIsFinished() || TransitioningToEndGame())) { foreach (var bullet in _bullets) { bullet.Update(gameTime); } _bullets.RemoveAll(b => !b.Used); foreach (var laser in _lasers) { laser.Update(gameTime); } ParticleManager.Update(gameTime); } if (GameIsFinished()) { return; } _playTime += gameTime.ElapsedGameTime; if (_boss != null && _boss.IsReady() && !EndGame()) { _timer += gameTime.ElapsedGameTime; } CollisionWorld.Update(gameTime); _player.Update(gameTime); }
public void Update(GameTime gameTime) { _timer -= gameTime.ElapsedGameTime; if (_timer < TimeSpan.Zero) { _timer = Config.BossInitialTimer; } // If the main part is destroyed, we destroy all parts // (or if the boss core is destroyed instead) if (!_core.IsAlive) { // Destroy all parts foreach (var part in Parts) { part.TakeDamage(9999); } _defeatCounter++; Reset(); } _core.Update(gameTime); if (!_mainPartIsDead && !_mainPart.IsAlive) { _mainPartIsDead = true; _core.Activate(); } for (int i = 0; i < _parts.Count; i++) { _parts[i].Update(gameTime); if (!_parts[i].IsAlive) { _parts.Remove(_parts[i]); } } // Check bullets to players collision for (int i = 0; i < MoverManager.movers.Count; i++) { foreach (var player in _players) { if (MoverManager.movers[i].Intersects(player)) { // Destroyed by shield? if (player.IsInvincible) { ParticleExplosion(MoverManager.movers[i].Position); MoverManager.RemoveBullet(MoverManager.movers[i]); } else { player.Hit(); } } } } if (Config.Debug) { /* * //check input to increment/decrement the current bullet pattern * if (InputHandler.KeyPressed(Keys.A)) * { * //decrement the pattern * if (0 >= _currentPatternIndex) * { * //if it is at the beginning, move to the end * _currentPatternIndex = _bulletPatterns.Count - 1; * } * else * { * _currentPatternIndex--; * } * * AddBullet(true); * } * else if (InputHandler.KeyPressed(Keys.X)) * { * //increment the pattern * if ((_bulletPatterns.Count - 1) <= _currentPatternIndex) * { * //if it is at the beginning, move to the end * _currentPatternIndex = 0; * } * else * { * _currentPatternIndex++; * } * * AddBullet(true); * } * else if (InputHandler.KeyPressed(Keys.LeftControl)) * { * AddBullet(false); * } * else */ if (_parts.Count > 0) { var currentBossPart = _parts[_currentPartIndex]; var dt = (float)gameTime.ElapsedGameTime.TotalSeconds * 100; if (InputHandler.KeyDown(Keys.Space)) { currentBossPart.GenerateStructure(); } else if (InputHandler.KeyPressed(Keys.OemPlus)) { currentBossPart.IterateStructure(); } else if (InputHandler.KeyDown(Keys.O)) { currentBossPart.IterateStructure(); } // Motion if (InputHandler.KeyPressed(Keys.N)) { _currentPartIndex = (_currentPartIndex + 1) % _parts.Count; } var acceleration = 0.1f; if (InputHandler.KeyDown(Keys.I)) { currentBossPart.ApplyImpulse(new Vector2(0, -1), new Vector2(acceleration)); } if (InputHandler.KeyDown(Keys.L)) { currentBossPart.ApplyImpulse(new Vector2(1, 0), new Vector2(acceleration)); } if (InputHandler.KeyDown(Keys.K)) { currentBossPart.ApplyImpulse(new Vector2(0, 1), new Vector2(acceleration)); } if (InputHandler.KeyDown(Keys.J)) { currentBossPart.ApplyImpulse(new Vector2(-1, 0), new Vector2(acceleration)); } // Left vector if (InputHandler.KeyDown(Keys.F)) { var direction = new Vector2( (float)-Math.Sin(currentBossPart.Rotation), (float)Math.Cos(currentBossPart.Rotation) ); currentBossPart.ApplyImpulse(direction, new Vector2(0.05f)); } // Right vector if (InputHandler.KeyPressed(Keys.G)) { var direction = new Vector2( (float)-Math.Cos(currentBossPart.Rotation) * -1, (float)Math.Sin(currentBossPart.Rotation) ); direction = new Vector2(-direction.Y, direction.X); currentBossPart.ApplyImpulse(direction, new Vector2(acceleration)); } if (InputHandler.KeyDown(Keys.PageUp)) { currentBossPart.ApplyAngularImpulse(.1f); } else if (InputHandler.KeyDown(Keys.PageDown)) { currentBossPart.ApplyAngularImpulse(-0.1f); } if (InputHandler.KeyPressed(Keys.H)) { currentBossPart.DisplayHpSwitch(); } } } MoverManager.Update(gameTime); MoverManager.FreeMovers(); }
public override void Update(GameTime gameTime) { float dt = (float)gameTime.ElapsedGameTime.TotalSeconds * 100; if (Position.Y < (75 + Sprite.Height / 2f)) { Position.Y += 1 * Speed * dt; if (Position.Y >= (75 + Sprite.Height / 2f)) { _ready = true; } } else { Rotation += _rotationIncrementor * dt; if (_rotationIncrementor < 1f) { _rotationIncrementor += 0.001f; } if (_health <= 0) { IsAlive = false; _deadSound.Play(); MoverManager.movers.Clear(); } if (Config.Debug) { //check input to increment/decrement the current bullet pattern if (InputHandler.KeyPressed(Keys.A)) { //decrement the pattern if (0 >= _currentPattern) { //if it is at the beginning, move to the end _currentPattern = _myPatterns.Count - 1; } else { _currentPattern--; } AddBullet(true); } else if (InputHandler.KeyPressed(Keys.X)) { //increment the pattern if ((_myPatterns.Count - 1) <= _currentPattern) { //if it is at the beginning, move to the end _currentPattern = 0; } else { _currentPattern++; } AddBullet(true); } else if (InputHandler.KeyPressed(Keys.LeftControl)) { AddBullet(false); } } _timer -= gameTime.ElapsedGameTime; if (_timer < TimeSpan.Zero) { _timer = Config.BossInitialTimer; /* * if (MoverManager.movers.Count < 10) * AddBullet(false); */ } if (MoverManager.movers.Count <= 1) { AddBullet(false); } MoverManager.Update(gameTime); MoverManager.FreeMovers(); } base.Update(gameTime); }