Example #1
0
        private void mainTimer_Tick(object sender, EventArgs e)
        {
            if (submitAnswerButton.BackColor == Color.Green || submitAnswerButton.BackColor == Color.Red)
            {
                submitAnswerButton.BackColor = Color.DarkGray;
            }
            timerSeconds--;
            mainTimerLabel.Text = timerMinutes + ":" + timerSeconds.ToString("D2");
            if (timerSeconds == 00 && timerMinutes != 0)
            {
                timerMinutes--;
                timerSeconds = 60;
            }
            else if (timerSeconds == 00 && timerMinutes == 0)
            {
                mainTimer.Enabled = false;
                MessageBox.Show("TIME IS UP! YOU WEREN'T ABLE TO FINISH THE QUESTIONS IN TIME. HERE ARE THE RESULTS.", "TIME IS UP!");

                GameResultsWindow grw = new GameResultsWindow(MainMenuForm.mainMenuForm.playerName, currentScore.ToString(),
                                                              mainTimerLabel.Text, DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString());

                grw.Show();
                Close();
            }
        }
Example #2
0
        private void CheckAnswer()
        {
            command.CommandText = "select answerWord from answers where question_id=@id";
            command.Parameters.AddWithValue("@id", questionId);
            string answer = command.ExecuteScalar().ToString();

            if (playerAnswerTxt.Text.ToUpper(new CultureInfo("tr-TR", false)) == answer)
            {
                playerAnswerTxt.Enabled      = false;
                playerAnswerTxt.Text         = string.Empty;
                submitAnswerButton.BackColor = Color.Green;
                pauseTimer.Enabled           = false;
                currentScore          += earnableScore;
                currentScoreLabel.Text = string.Empty + currentScore;
                if (questionId != 14)
                {
                    questionId++;
                    pauseTimerSeconds          = 20;
                    submitAnswerButton.Enabled = false;
                    command            = new MySqlCommand();
                    command.Connection = MainMenuForm.connection;
                    if (!mainTimer.Enabled)
                    {
                        mainTimer.Enabled   = true;
                        mainTimerLabel.Text = timerMinutes + ":" + timerSeconds.ToString("D2");
                        pauseTimer.Enabled  = false;
                    }
                    GetQuestionFromDatabase();
                    EmptyLetterSlots();
                    requestLetterButton.Enabled = true;
                }
                else if (questionId == 14)
                {
                    mainTimer.Enabled   = false;
                    pauseTimer.Enabled  = false;
                    mainTimerLabel.Text = timerMinutes + ":" + timerSeconds.ToString("D2");
                    MessageBox.Show("THE GAME IS OVER! CLICK OK TO SEE YOUR RESULTS!", "YOU JUST BEAT THE GAME", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    GameResultsWindow grw = new GameResultsWindow(MainMenuForm.mainMenuForm.playerName, currentScore.ToString(),
                                                                  mainTimerLabel.Text, DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString());

                    grw.Show();
                    Close();
                }
            }
            else
            {
                submitAnswerButton.BackColor = Color.Red;
                command            = new MySqlCommand();
                command.Connection = MainMenuForm.connection;
            }
        }
Example #3
0
        private void pauseTimer_Tick(object sender, EventArgs e)
        {
            pauseTimerSeconds--;
            mainTimerLabel.Text = pauseTimerMinutes + ":" + pauseTimerSeconds.ToString("D2");
            if (pauseTimerSeconds == 00)
            {
                playerAnswerTxt.Enabled = false;
                playerAnswerTxt.Text    = string.Empty;
                currentScore           -= earnableScore;
                if (currentScore < 0)
                {
                    currentScore = 0;
                }
                currentScoreLabel.Text = currentScore.ToString();
                command            = new MySqlCommand();
                command.Connection = MainMenuForm.connection;
                RequestLetter(); //It won't request another letter, it will straight-forward show the right word. Line 80
                if (questionId < 14)
                {
                    questionId++;
                }
                else
                {
                    pauseTimer.Enabled = false;
                    MessageBox.Show("QUESTIONS ARE DONE! HERE ARE THE RESULTS", "GAME SESSIONS IS OVER!");

                    GameResultsWindow grw = new GameResultsWindow(MainMenuForm.mainMenuForm.playerName, currentScore.ToString(),
                                                                  mainTimerLabel.Text, DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString());

                    grw.Show();
                    Close();
                }
                pauseTimerSeconds = 20;
                twentySecondsTimeoutTimer.Enabled = true;
                mainTimerLabel.Text        = timerMinutes + ":" + timerSeconds.ToString("D2");
                submitAnswerButton.Enabled = false;
                pauseTimer.Enabled         = false;
            }
        }