private void CollisionDetection(Ship s, Ship e, int index) { //check cannon balls for (int j = s.getCBA().Count - 1; j >= 0; j--) { CannonBall cB = s.getCBA().ElementAt(j); if (cB.BoundingBox.Intersects(e.BoundingBox)) { Console.WriteLine("\nCOLLISION CB "+ j + ": \n" + cB.BoundingBox.Print() + "\nAGAINST: \n" + e.BoundingBox.Print()+"\n"); //deal damage to enemy e.takeDamage(cB.getDamage()); //remove cannon ball //if the ship is not a player frigate, remove the cannon ball upon contact if (s.GetType() != typeof(Player_Frigate)) s.getCBA().Remove(cB); //if it is a player frigate, check to see if it's ability is activated, if not, then remove the cannon ball upon contact. Else, leave the cannon balls alone else { if (((Player)(s)).getShipState() != Ship.ShipState.AbilityActivated) s.getCBA().Remove(cB); } }//end if collision //check if the ship should be sunk }//end for j //if s is the player, then check if it is a brig and has its ability activated if (s == player) { if (player.GetType() == typeof(Player_Brig) && player.getShipState() == Ship.ShipState.AbilityActivated) if (s.BoundingBox.Intersects(e.BoundingBox)) { e.takeDamage(s.getDamage()); } } //check if the ship should be sunk if (e.getHealth() <= 0) { if (e.GetType() == typeof(Player_Brig) || e.GetType() == typeof(Player_Frigate) || e.GetType() == typeof(Player_ManOfWar)) { UnloadContent(); EndRun(); } } }