示例#1
0
 // When the WaterTimer ticks
 private void WaterTimer_Tick(object sender, EventArgs e)
 {
     if (WaterBarPictureBox.Width == 193 && timerIncrements[1] < 0) // If the WaterBar is full and the timer is trying to increase the width
     {
         return; // Stop this method here
     }
     WaterBarPictureBox.Width = WaterBarPictureBox.Width - timerIncrements[1]; // Change the width of the bar by the value of the timerIncrement
     if (WaterBarPictureBox.Width <= 0) // If the bar is at 0
     {
         WaterTimer.Stop(); // Stop the timer
         GameCompletedForm gameCompletedForm = new GameCompletedForm();
         gameCompletedForm.Visible = true; // Make this new instance visible
         this.Visible = false; // Hide the current Form
         gameCompletedForm.SetTimeLabel(-1); // Set the time label as incomplete on the new form
         gameCompletedForm.SetQuestionLists(problemQuestions, resolvedProblemQuestions); // Set the values of the question lists on the new form
         gameCompletedForm.SetTotalCorrectAnswers(answersCorrect[0], answersCorrect[1], answersCorrect[2]); // Set the value for total correct answers on the new form
         gameCompletedForm.SetTotalNumMistakes(answersIncorrect[0], answersIncorrect[1], answersIncorrect[2]); // Set the value for the total number of mistakes on the new form
         gameCompletedForm.SetProblemQuestionsLabel(problemQuestions.Count); // Set the data for the Problem Questions on the new form
         gameCompletedForm.SetResolvedQuestionsLabel(resolvedProblemQuestions.Count); // Set the data for the Resolved Questions on the new form
     }
 }
示例#2
0
        // Used to complete the game
        public void CompleteGame()
        {
            AirTimer.Stop(); // Stop all timers
            WaterTimer.Stop();
            FoodTimer.Stop();
            SecondTimer.Stop();
            GameCompletedForm gameCompletedForm = new GameCompletedForm(); // Create a new instance of a GameCompletedForm
            gameCompletedForm.Visible = true; // Make this new instance visible
            this.Visible = false; // Hide the current Form
            gameCompletedForm.SetTimeLabel(secondsPassed); // Set the time label on the new form
            gameCompletedForm.SetQuestionLists(problemQuestions, resolvedProblemQuestions); // Set the values of the question lists on the new form
            gameCompletedForm.SetTotalCorrectAnswers(answersCorrect[0], answersCorrect[1], answersCorrect[2]); // Set the value for total correct answers on the new form
            gameCompletedForm.SetTotalNumMistakes(answersIncorrect[0], answersIncorrect[1], answersIncorrect[2]); // Set the value for the total number of mistakes on the new form
            gameCompletedForm.SetProblemQuestionsLabel(problemQuestions.Count); // Set the data for the Problem Questions on the new form
            gameCompletedForm.SetResolvedQuestionsLabel(resolvedProblemQuestions.Count); // Set the data for the Resolved Questions on the new form

            UserDatabase userDB = new UserDatabase();
            UserDatabase.GameCompletedDetails gameCompletedDetails = new UserDatabase.GameCompletedDetails();
            gameCompletedDetails.timeInSeconds = secondsPassed;
            gameCompletedDetails.numCorrectAnswers = answersCorrect;
            gameCompletedDetails.numMistakes = answersIncorrect;
            gameCompletedDetails.problemQuestions = problemQuestions;
            gameCompletedDetails.resolvedQuestions = resolvedProblemQuestions;
            userDB.AddGameCompletedDetails(username, gameCompletedDetails);
            userDB.SaveDatabase();
        }