} // end damageMe public void ApplyBonus(Bonus bonus) { switch (bonus.Category) { case (Bonus.BonusCategory.laserPowerBonus): { this.laser = Math.Min(this.laser + 1, maxLaser); break; } case (Bonus.BonusCategory.healthBonus): { this.currentMaxHealth += 1; this.health = Math.Min(this.health + 3, currentMaxHealth); break; } case(Bonus.BonusCategory.speedBonus): { this.speed = Math.Min(this.speed + 1, maxSpeed); break; } case(Bonus.BonusCategory.laserSpeedBonus): { this.laserSpeed = Math.Min(this.laserSpeed + 1, maxLaserSpeed); this.coolDown = Math.Max((int)(this.coolDown * .75), minCoolDown); // reduce cooldown by 25% break; } default: { MessageBox.Show("Bonus category not handled."); break; } } // end switch // play bonus sound Res.playSound("bonus.wav"); }
private void PositionBonus(Bonus b, int currentBonusIndex) { // set bonus speed according to the current bonus index. int speed = 1 * ((int)(currentBonusIndex / 8) + 1); // multiples cause higher speed explosion.; switch (currentBonusIndex % 8) { case 0: { // N b.vY = - (int)(speed * 1.25); b.vX = 0; break; } case 1: { //NE b.vY = - speed; b.vX = speed; break; } case 2: { //NW b.vY = - speed; b.vX = - speed; break; } case 3: { //E b.vY = 0; b.vX = (int)(speed * 1.25); break; } case 4: { //W b.vY = 0; b.vX = -(int)(speed * 1.25); break; } case 5: { //SE b.vY = speed; b.vX = speed; break; } case 6: { //SW b.vY = speed; b.vX = - speed; break; } case 7: { //S b.vY = (int)(speed * 1.25); b.vX = 0; break; } default: { break; } } }