private void UpdatePotions(GameTime dt) { for (int i = 0; i < potions.Count; ++i) { HealthPotion health = potions[i]; health.Update(dt); if (health.BoundingCircle.Intersects(Player.BoundingRect)) { potions.RemoveAt(i--); CollectHealthPot(health, Player); } } }
/// <summary> /// Animates each HealthPotion and checks to allows the player to collect them. /// </summary> public void UpdateHealthPotions(GameTime gameTime, LevelPlayer player) { UpdateKnives(gameTime); for (int i = 0; i < healthPotions.Count; ++i) { HealthPotion healthPotion = healthPotions[i]; healthPotion.Update(gameTime); if (healthPotion.BoundingCircle.Intersects(player.BoundingRectangle)) { healthPotions.RemoveAt(i--); OnHealthPotionCollected(healthPotion, player); } } }