/// <summary> /// Called when a collision is detected between an AlienSprite and a Projectile from the /// LaserFactory. /// </summary> /// <param name="killedAlien">The killed Alien from which the collision was detected on.</param> private void killAlien(DrawableGameComponent killedAlien, int points) { AlienSprite alien = ((AlienSprite)killedAlien); // remove a hit point from alien alien.SetHitPoints(alien.GetHitPoints() - 1); if (alien.GetHitPoints() <= 0) { alien.SetAlienState(AlienState.INACTIVE); alienKillSoundInstance.Play(); killedCount++; //Increases speed of squad once a certain number are killed if ((killedCount % 8) == 0) { Alien.IncreaseSpeed(); } //Resets squad if all are killed if (killedCount == alienSquad.Length) { level++; alienLevel++; resetAlienSquad(); } //Spawns mothership once a certain number are killed if (killedCount == (alienSquad.Length / 2)) { mothershipSprite.RandomizeMothershipSpawn(); mothershipSprite.SetAlienState(AlienState.ACTIVE); mothershipSprite.SetSpawnMother(true); } } else { // check what type of alien was hit, change texture to a hit sprite alien of that type if (alien.GetAlienType() == AlienType.SPACESHIP) { alien.SetTexture(hitAlienTexture1); } else if (alien.GetAlienType() == AlienType.BUG) { alien.SetTexture(hitAlienTexture2); } else if (alien.GetAlienType() == AlienType.FLYINGSAUCER) { alien.SetTexture(hitAlienTexture3); } } }