public override void Update(GameTime gameTime) { // Get rid of unneeded objects. RemoveObjectsOutsideScreen(); currentGameTime = (float)gameTime.TotalGameTime.TotalSeconds; foreach (GameObject go in gameObjects.FindAll(x => x.FlaggedForRemoval)) { scriptManager.AbortObjectScripts(go); gameObjects.Remove(go); } foreach (GameObject go in gameObjects.FindAll(x => x.IsNewObject)) { go.IsNewObject = false; } foreach (Animation a in animations.FindAll(x => x.FlaggedForRemoval)) { animations.Remove(a); } // Populate the quadtree in preparation for collision checking. quadtree.Clear(); foreach (GameObject go in gameObjects.FindAll(x => !x.IsNewObject)) { go.Update(gameTime); } foreach (GameObject go in gameObjects.FindAll(x => !x.IsNewObject)) { quadtree.Insert(go); } foreach (Animation a in animations) { a.Update(gameTime); } scriptManager.Update(gameTime); collisionDetection.BroadphaseCollisionDetection(); levelManager.Update(gameTime); if (Experience > 0) { if (!ExperienceDecayPaused) { Experience -= ExperienceDecay * (float)gameTime.ElapsedGameTime.TotalSeconds; if (Experience <= 0) { ResetRank(); } } else if (ExperienceDecayPaused && ExperienceDecayPauseDuration > 0) { ExperienceDecayPauseDuration -= (float)gameTime.ElapsedGameTime.TotalSeconds; if (ExperienceDecayPauseDuration <= 0) { ExperienceDecayPaused = false; } } } CheckExtend(); AudioManager.PlayQueuedSoundEffects(); }