/// <summary> /// Handles collisions between asteroids and the players bullets. /// </summary> public void CollideAsteroidsBullets() { //get the asteroids and the players bullets List <GameObject> asteroids = asteroidManager.AsteroidsList; List <GameObject> bullets = bulletManager.BulletsList; //loop through the asteroids for (int i = asteroids.Count - 1; i >= 0; i--) { //get the asteroids collision circle then loop through the bullets CollisionCircle curr = asteroids [i].GetComponent <CollisionCircle> (); for (int j = bullets.Count - 1; j >= 0; j--) { //check for collision if (curr.TestCollisionCircle(bullets[j].GetComponent <CollisionCircle>())) { //if there is a collision destroy both the asteroid and the bullet then and stop looping through bullets asteroidManager.DestroyAsteroid(asteroids[i]); bulletManager.DestroyBullet(j); j = -1; } } } }