/// <summary> /// Checks collisions between the meteors and an alien ship /// </summary> /// <param name="Lmeteor">list of meteors</param> /// <param name="ship">alien ship</param> public void DidCollisionOccur(List <Meteor> Lmeteor, AlienBase ship) { for (int i = Lmeteor.Count - 1; i >= 0; i--) { if (!Lmeteor[i].IsDying) { if (Check(Lmeteor[i].Bounds, ship.Bounds)) { if (Settings.debug) { Lmeteor[i].isCollided = true; ship.isCollided = true; } if (Settings.useFancyCollisions) { if (Settings.debug) { Lmeteor[i].isCollidedFoReal = false; ship.isCollidedFoReal = false; } if (FancyCollisions.isColliding(Lmeteor[i], ship)) { if (Settings.debug) { Lmeteor[i].isCollidedFoReal = true; ship.isCollidedFoReal = true; } ship.IsDying = true; DestroyedAliens.Add(ship); } } else { ship.IsDying = true; DestroyedAliens.Add(ship); } } else if (Check(Lmeteor[i].Bounds, ship.Aware)) { ship.Visibles.Add(Lmeteor[i]); } } } }
/// <summary> /// checks collisions between the player's bullets and the alien ships /// </summary> /// <param name="Lbullet">player's bullets</param> /// <param name="ship">alien ship</param> public void DidCollisionOccur(List <Weapon> Lbullet, AlienBase ship) { for (int i = Lbullet.Count - 1; i >= 0; i--) { if (!Lbullet[i].IsDying) { if (Check(Lbullet[i].Bounds, ship.Bounds)) { if (Settings.debug) { Lbullet[i].isCollided = true; ship.isCollided = true; } if (Settings.useFancyCollisions) { if (Settings.debug) { Lbullet[i].isCollidedFoReal = false; ship.isCollidedFoReal = false; } if (FancyCollisions.isColliding(Lbullet[i], ship)) { if (Settings.debug) { Lbullet[i].isCollidedFoReal = true; ship.isCollidedFoReal = true; } bulletHitAlien(ship, Lbullet[i]); } } else { bulletHitAlien(ship, Lbullet[i]); } } else if (Check(Lbullet[i].Bounds, ship.Aware)) { ship.Visibles.Add(Lbullet[i]); } } } }
/// <summary> /// Handles the collision between a player's bullet and an alien ship /// </summary> /// <param name="alien">the alien</param> /// <param name="bullet">the bullet</param> private void bulletHitAlien(AlienBase alien, Weapon bullet) { bullet.IsDying = true; UsedBullets.Add(bullet); alien.ShieldLevel -= 1; if (alien.ShieldLevel < 0) { alien.IsDying = true; DestroyedAliens.Add(alien); MainGame.score += alien.PointValue; MainGame.extraLivesCounter += alien.PointValue; if (MainGame.extraLivesCounter > Settings.scoreToNextLife) { MainGame.lives++; MainGame.extraLivesCounter = 0; MainGame.extraLifeAdded = true; } } else { try { GameSounds.effect(GameMedia.getDir["shieldsDownSND"]); } catch { } } }