public void Update(Vector3 direction, CollisionEngine collisionEngine, SoundEngine soundEngine, ParticleEngine particleEngine,List<Asteroid> asteroids, List<Powerup> powerups, MouseState originalMouseState, GameTime gameTime, GraphicsDevice device) { if (this.Shrink != null) { if (this.Shrink.Activated) { this.Shrink.Update(gameTime); if (this.Shrink.Timer <= 0) { this.Shrink = null; this.BoundingSphere = new BoundingSphere( this.Position, this.BoundingSphere.Radius / 0.25f); soundEngine.Grow.Play(); } else { this.BoundingSphere = new BoundingSphere( this.Position, this.BoundingSphere.Radius * 0.25f); } } } CheckCollisions(collisionEngine, soundEngine, powerups, asteroids); if (this.Destroyed) { if (this.Lives == 0) return; else { particleEngine.AddParticle(gameTime, this.Position); UpdatePosition(new Vector3(0, 0, 0)); this.Destroyed = false; this.Speed = 0f; this.Velocity = Vector3.Zero; this.Rotation = Quaternion.Identity; } } ProcessKeyboard(direction, gameTime, soundEngine); ProcessMouse(originalMouseState, gameTime, device); }
private void CheckCollisions(CollisionEngine collisionEngine, SoundEngine soundEngine, ParticleEngine particleEngine, GameTime gameTime, List<Asteroid> asteroids) { // Destroy the torpedo if it hits the edge of the universe if (collisionEngine.CollidesWithEdge(this.Position, this.BoundingSphere)) { if (soundEngine.Explosion.State != SoundState.Playing) soundEngine.Explosion.Play(); this.Destroyed = true; particleEngine.AddParticle(gameTime, this.Position); } // Destroy the torpedo if it hits an asteroid foreach (Asteroid asteroid in asteroids) { if (collisionEngine.CollideTwoObjects(this.BoundingSphere, asteroid.BoundingSphere)) { particleEngine.AddParticle(gameTime, this.Position); this.Destroyed = true; break; } } }