//Recrystalize Button private void brnRecrystalize_Click(object sender, EventArgs e) { if (dblWarpFactor <= 0) { time = 0.0; dblWarpFactor = 0.0; dblWarpCoreHealth = 100; dblPlasmaInjector = 0; dblInjectorMax = 100; intCoolantLevel = 20; dblContainment = 100; dblDilithiumIntegrity = 100; dblInjectorPercent = 0; dblPercent = 0; blnGameOver = false; blnStop = true; } else { blnGameOver = true; endGame(); this.Close(); frmGameOver gameover = new frmGameOver(); gameover.ShowDialog(); } }
//MAIN GAME LOOP / TIMER private void timGameClock_Tick(object sender, EventArgs e) { //Main Game Clock / Updates as Changes Made time += Convert.ToDouble(timGameClock.Interval) / 1000; lblGameClock.Text = String.Format("{0:f1}", time); lblGameClock.Refresh(); //Update Warp Factor From Radio Buttons andChange Radio Button Selected if Warp Power Changes Warp //Warp Zero is Selected Via Radio Button if (blnGameOver == false) { if (blnStop == false) { if (radWarp0.Checked == true) { if (dblWarpFactor > 0) { dblWarpFactor = dblWarpFactor - 0.2; btnPlasmaIncrease.Enabled = false; btnPlasmaDecrease.Enabled = false; blnStop = false; if (dblWarpFactor <= 0) { dblWarpFactor = 0; } } else if (dblWarpFactor <= 0) { btnPlasmaIncrease.Enabled = true; btnPlasmaDecrease.Enabled = true; blnStop = true; } } //If Other Warp Factors are Selected Via Radio Button else if (radWarp1.Checked == true) { rad_Warp(1); } else if (radWarp2.Checked == true) { rad_Warp(2); } else if (radWarp3.Checked == true) { rad_Warp(3); } else if (radWarp4.Checked == true) { rad_Warp(4); } else if (radWarp5.Checked == true) { rad_Warp(5); } else if (radWarp6.Checked == true) { rad_Warp(6); } else if (radWarp7.Checked == true) { rad_Warp(7); } else if (radWarp8.Checked == true) { rad_Warp(8); } else if (radWarp9.Checked == true) { rad_Warp(9); } } //Warp Factor Effect on Warp Core Heatlh if ((dblWarpFactor > 0) && (dblWarpFactor <= 7.0)) { dblContainment = dblContainment - 0.0025; } else if ((dblWarpFactor >= 7.1) && (dblWarpFactor <= 8.0)) { dblContainment = dblContainment - 0.005; } else if ((dblWarpFactor >= 8.1) && (dblWarpFactor <= 9.0)) { dblContainment = dblContainment - 0.01; } else if ((dblWarpFactor >= 9.1) && (dblWarpFactor <= 9.5)) { dblContainment = dblContainment - 0.02; } else if (dblWarpFactor >= 9.6) { dblContainment = dblContainment - 0.05; } //Update Labels, Graphics, and Progress Bars //Update Warp Factor and Warp Power Labels lblWarpFactor.Text = String.Format("{0:f1}", dblWarpFactor); lblWarpFactor.Refresh(); //dblWarpFactor = dblPlasmaInjector / 10; if ((dblWarpFactor * 10) > dblInjectorMax) { dblWarpFactor = dblWarpFactor - 0.01; } dblPlasmaInjector = dblWarpFactor * 10; //Decrement Plasma if Over Injector Max if (dblPlasmaInjector <= 0) { dblPlasmaInjector = 0; } dblInjectorPercent = dblPlasmaInjector; dblInjectorPercent = dblInjectorPercent / 100; lblInjector.Text = dblInjectorPercent.ToString("P0"); lblInjector.Refresh(); //Warning Updates //Injector Warning Update if (blnWarning01 == true) { lblWarning01.Visible = true; } else { lblWarning01.Visible = false; } if ((dblPlasmaInjector > 0) && (dblPlasmaInjector < dblInjectorMax)) { prgInjector.Value = Convert.ToInt32(dblPlasmaInjector); } else if (dblPlasmaInjector >= dblInjectorMax) { prgInjector.Value = 100; } else { dblPlasmaInjector = 0; prgInjector.Value = 0; } lblInjector.Refresh(); //Coolant Leak Warning / Update if (intCoolantLevel == 100) { Random coolantleak = new Random(); int leak = coolantleak.Next(0, 50); if (leak == 5) { blnWarning02 = true; } } else if (intCoolantLevel == 80) { Random coolantleak = new Random(); int leak = coolantleak.Next(0, 150); if (leak == 5) { blnWarning02 = true; } } if (blnWarning02 == true) { intCoolantLevel = intCoolantLevel - 1; lblWarning02.Visible = true; } //Update Coolant if ((intCoolantLevel > 0) && (intCoolantLevel < 100)) { prgCoolantLevel.Value = intCoolantLevel; } else if (intCoolantLevel >= 100) { intCoolantLevel = 100; prgCoolantLevel.Value = 100; } else { intCoolantLevel = 0; prgCoolantLevel.Value = intCoolantLevel; } lblCoolant.Text = intCoolantLevel.ToString(); lblCoolant.Refresh(); //Update Coolant Labels dblPercent = ((Convert.ToDouble(intCoolantLevel)) / 100); lblCoolant.Text = dblPercent.ToString("P0"); prgContainment.Value = Convert.ToInt32(dblContainment); dblWarpCoreHealth = dblContainment; //Update Containment if ((intCoolantLevel >= 20) && (intCoolantLevel <= 39)) { dblWarpCoreHealth = dblContainment + ((Convert.ToDouble(intCoolantLevel) / 100)); } else if ((intCoolantLevel >= 40) && (intCoolantLevel <= 59)) { dblWarpCoreHealth = dblContainment + ((Convert.ToDouble(intCoolantLevel) / 100) + .5); } else if ((intCoolantLevel >= 60) && (intCoolantLevel <= 79)) { dblWarpCoreHealth = dblContainment + ((Convert.ToDouble(intCoolantLevel) / 100) + 1); } else if ((intCoolantLevel >= 80) && (intCoolantLevel < 100)) { dblContainment = dblContainment + 0.005; } else if (intCoolantLevel == 100) { dblContainment = dblContainment + 0.01; } else { dblContainment = dblContainment - 1; } if (dblContainment > 100) { dblContainment = 100; } if (dblContainment <= 0) { blnGameOver = true; dblContainment = 0; } //Update Containment Label dblPercent = (dblContainment / 100); lblContainment.Text = dblPercent.ToString("P0"); prgContainment.Value = Convert.ToInt32(dblContainment); dblWarpCoreHealth = dblContainment; //Update Warp Core Heatlh dblPercent = (dblWarpCoreHealth / 100); lblWarpCoreHealth.Text = dblPercent.ToString("P0"); lblWarpCoreHealth.Refresh(); //Turn Containment Failure Warning Label On and Off if (dblContainment < 20) { lblContainmentFailure.Visible = true; } else { lblContainmentFailure.Visible = false; } //Update Dilithium Health if (dblDilithiumIntegrity > 0) { dblDilithiumIntegrity = dblDilithiumIntegrity - 0.1; } else if (dblDilithiumIntegrity <= 0) { dblDilithiumIntegrity = 0; blnGameOver = true; } //Turn Recrystalize Warning Label On and Off if (dblDilithiumIntegrity < 20) { lblRecrystalize.Visible = true; } else { lblRecrystalize.Visible = false; } if (dblDilithiumIntegrity == 0) { blnGameOver = true; endGame(); this.Close(); frmGameOver gameover = new frmGameOver(); gameover.ShowDialog(); } //Dilithium Label Output prgDilithium.Value = Convert.ToInt32(dblDilithiumIntegrity); dblPercent = dblDilithiumIntegrity / 100; lblDilithium.Text = dblPercent.ToString("P0"); lblDilithium.Refresh(); //Game Over //Boolean blnExplode = false; //Boolean blnWarp10 = false; //Boolean blnCoolantLeaK = false; if (dblWarpFactor >= 10) { blnGameOver = true; endGame(); this.Close(); frmGameOverWarp10 warp10 = new frmGameOverWarp10(); warp10.ShowDialog(); } if (dblWarpCoreHealth == 0) { blnGameOver = true; endGame(); this.Close(); frmGameOver gameover = new frmGameOver(); gameover.ShowDialog(); } } }