private void UpdateSprites(GameTime gameTime) { for (int i = 0; i < sprites.Count; i++) { sprites[i].Update(gameTime, sprites); if (sprites[i] is Player) { foreach (var sprite in sprites) { if (sprite is Enemy) { if (sprite.Rectangle.Intersects(sprites[i].Rectangle)) { player.TakeDamage(); (sprite as Enemy).playerCollision(); } } if (sprite is Powerup) { if (sprite.Rectangle.Intersects(sprites[i].Rectangle)) { player.powerUp((sprite as Powerup).returnPattenParameters()); } } if (sprite is hpUp) { if (sprite.Rectangle.Intersects(sprites[i].Rectangle)) { player.hpUp(); (sprite as hpUp).Remove(); } } } } if (sprites[i] is Enemy) { if ((sprites[i] as Enemy).ReachedBottom) { player.TakeDamage(); } if (sprites[i].isRemoved) //check to release powerup { currentElimintaions++; if (currentElimintaions >= powerUpElimintaions) { spawnPowerUp(sprites[i].Rectangle.Center.ToVector2()); currentElimintaions = 0; powerUpElimintaions = rnd.Next(3, 7); } } } if (sprites[i].isRemoved) { sprites.RemoveAt(i--); } } if (player.isRemoved) { inMenu = true; sprites.Clear(); player.Reset(new Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 100)); spawnManager.Reset(); sprites.Add(player); background.Reset(); sprites.Add(background); } }