public void tookPowerUp() { for (int i = PowerUps.Count - 1; i >= 0; i--) { double distance; distance = Math.Sqrt((PowerUps[i].Location.X - CurrentPlayer.Location.X) * (PowerUps[i].Location.X - CurrentPlayer.Location.X) + (PowerUps[i].Location.Y - CurrentPlayer.Location.Y) * (PowerUps[i].Location.Y - CurrentPlayer.Location.Y)); if (distance < 100) { if (PowerUps[i].Type == PowerUpType.Health) { if (CurrentPlayer.Health + PowerUps[i].Boost > CurrentPlayer.MaxHealth) { CurrentPlayer.Health = CurrentPlayer.MaxHealth; } else { CurrentPlayer.Health += (int)PowerUps[i].Boost; } } if (PowerUps[i].Type == PowerUpType.Speed) { CurrentPlayer.Buffs.Add(new Buff(BuffType.SpeedEffect, PowerUps[i].Boost, PowerUps[i].Duration_Ammo)); } if (PowerUps[i].Type == PowerUpType.PidgeonHeavy) { CurrentPlayer.AddAmmo(PowerUps[i].Duration_Ammo, ProjectileType.PidgeonHeavy); CurrentPlayer.SelectWeapon(1); } if (PowerUps[i].Type == PowerUpType.PidgeonLaser) { CurrentPlayer.AddAmmo(PowerUps[i].Duration_Ammo, ProjectileType.PidgeonLaser); CurrentPlayer.SelectWeapon(2); } if (PowerUps[i].Type == PowerUpType.PidgeonPlazma) { CurrentPlayer.AddAmmo(PowerUps[i].Duration_Ammo, ProjectileType.PidgeonPlazma); CurrentPlayer.SelectWeapon(3); } PowerUps.RemoveAt(i); } } }