// Leaderboard button event handler that loads the leaderboard form private void btnLeaderboard_Click(object sender, EventArgs e) { int[] solutionArray = solution.returnSolutionArray(); frmLeaderboard temp = new frmLeaderboard(); temp.Show(); }
// Ok button event handler // Checks to makes sure all the button has been clicked atleast once // Does the comparison from the player guess with the solution // Resets the clicked flags boolean for next round // Checks if the player won or not // Disables butons if the user wins // Loads up the leaderboard form when the user wins private void btnOK_Click(object sender, EventArgs e) { cbxDifficulty.Enabled = false; int count = solution.returnAttempts(); solution.guess.setGuess(counter1++, counter2++, counter3++, counter4++); if (clickFlag1 == false || clickFlag2 == false || clickFlag3 == false || clickFlag4 == false) { MessageBox.Show("There is a missing color for your guess."); return; } else if (!solution.processRound(solution.returnSolutionArray())) { resetCounters(); int[] temp = solution.hints.returnHints(); for (int i = 0; i < 4; i++) { hintButtons[solution.returnAttempts() - 1, i].BackgroundImage = hintList.Images[temp[i]]; guessButtons[solution.returnAttempts() - 1, i].Enabled = false; if (solution.returnAttempts() < turns) { guessButtons[solution.returnAttempts(), i].Enabled = true; } } resetClickFlags(); if (solution.returnAttempts().Equals(turns)) { btnOK.Enabled = false; tmrClock.Enabled = false; pnlSolution.Visible = true; MessageBox.Show("Game Over"); } } else { int[] temp = solution.hints.returnHints(); for (int i = 0; i < 4; i++) { hintButtons[solution.returnAttempts(), i].BackgroundImage = hintList.Images[temp[i]]; if (solution.returnAttempts() != 0) { guessButtons[solution.returnAttempts() - 1, i].Enabled = false; } else { guessButtons[solution.returnAttempts(), i].Enabled = false; } } pnlSolution.Visible = true; tmrClock.Enabled = false; btnOK.Enabled = false; frmLeaderboard newForm = new frmLeaderboard(); newForm.win = solution.returnWin(); newForm.winTime = seconds; if (solution.returnAttempts() == 0) { newForm.winTurn = 1; } else { newForm.winTurn = solution.returnAttempts() + 1; } newForm.winDifficulty = cbxDifficulty.SelectedItem.ToString(); newForm.Show(); MessageBox.Show("You win"); } }