예제 #1
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();
        }