public void DetectColl() { List <Entity> dead_Badguy = new List <Entity>(); List <Entity> dead_playerBullet = new List <Entity>(); //loop through //Entities vs. player foreach (Entity enemy in current_Enemies) { if (enemy.hitbox.IntersectsWith(player.hitbox)) { if (player.HitPlayer(enemy)) { var sound = new MediaPlayer(); sound.Open(new Uri(System.Environment.CurrentDirectory.Substring(0, System.Environment.CurrentDirectory.Length - 9) + "Resources\\hurtplayer.wav", UriKind.Absolute)); Application.Current.Dispatcher.BeginInvoke(new Action(() => sound.Play())); } if (enemy.Hit()) { dead_Badguy.Add(enemy); } if (enemy is Powerup) { player.powerup = (enemy as Powerup).type; // Added by Jo if ((enemy as Powerup).type == PowerUp.ExtraLife || (enemy as Powerup).type == PowerUp.ExtraBomb) { player.Activate_powerup(); } dead_Badguy.Add(enemy); } } } //Player Bullets vs. entities foreach (Entity bullet in player_fire) { foreach (Entity enemy in current_Enemies) { if (bullet.hitbox.IntersectsWith(enemy.hitbox)) { dead_playerBullet.Add(bullet); bullet.Hit(); if (enemy.Hit()) { var sound = new MediaPlayer(); sound.Open(new Uri(System.Environment.CurrentDirectory.Substring(0, System.Environment.CurrentDirectory.Length - 9) + "Resources\\damage.wav", UriKind.Absolute)); Application.Current.Dispatcher.BeginInvoke(new Action(() => sound.Play())); dead_Badguy.Add(enemy); score += 50 * 1; // TODO: Based on DIff if (enemy is Powerup) { player.powerup = (enemy as Powerup).type; // Added by Jo // copyed Noah if ((enemy as Powerup).type == PowerUp.ExtraLife) { player.Activate_powerup(); } } } } } } foreach (Entity e in dead_Badguy) { current_Enemies.Remove(e); } foreach (Bullet b in dead_playerBullet) { player_fire.Remove(b); } }