private void wire_Click(object sender, EventArgs e) { //Stop the timer progressTimer.Stop(); //Check if the wire was the correct one if ((Button)sender == yellowWire) { resultBox.Text = "You win!"; } else { resultBox.Text = "KABOOM! You lost."; Button buttonHolder = (Button)sender; string wireColor = buttonHolder.BackColor.Name; BoomForm boomForm = new BoomForm($"{wireColor}"); boomForm.ShowDialog(); } //Disable the wires & enable the reset button foreach (Button w in wires) { w.Enabled = false; } gameButton.Text = "Reset"; gameButton.Enabled = true; }
private void progressTimer_Tick(object sender, EventArgs e) { //Increment the progress bar accordingly, check if time has run out if (timerBar.Value < 100) { timerBar.Value += 1; } else if (timerBar.Value == 100) { progressTimer.Stop(); resultBox.Text = "KABOOM! You lost."; foreach (Button w in wires) { w.Enabled = false; } gameButton.Text = "Reset"; gameButton.Enabled = true; BoomForm boomForm = new BoomForm("timer"); boomForm.ShowDialog(); } }