コード例 #1
0
        /// <summary>
        /// Randomly choosing a question to show and setup UI accordingly
        /// </summary>
        private void GameSetup()
        {
            // Get a random question from the list and display it
            int rndQuestion = testRandom.RandomQuestion(ListofTriviaQuestions.Count);

            answerBoxSelection = testRandom.AnswerBox();

            QuestionLabel.Text          = ListofTriviaQuestions[rndQuestion].question;
            QuestionLabel.TextAlignment = UITextAlignment.Center;

            // Finds the correct answer box to "hide" the correct ansswer in
            if (answerBoxSelection == 1)
            {
                // Correct Answer
                AnswerButton1.SetTitle(ListofTriviaQuestions[rndQuestion].answer, UIControlState.Normal);

                // False Answers
                AnswerButton2.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ2, UIControlState.Normal);
                AnswerButton3.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ3, UIControlState.Normal);
                AnswerButton4.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ1, UIControlState.Normal);
            }
            else if (answerBoxSelection == 2)
            {
                // Correct Answer
                AnswerButton2.SetTitle(ListofTriviaQuestions[rndQuestion].answer, UIControlState.Normal);

                // False Answers
                AnswerButton1.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ1, UIControlState.Normal);
                AnswerButton3.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ3, UIControlState.Normal);
                AnswerButton4.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ2, UIControlState.Normal);
            }
            else if (answerBoxSelection == 3)
            {
                // Correct Answer
                AnswerButton3.SetTitle(ListofTriviaQuestions[rndQuestion].answer, UIControlState.Normal);

                // False Answers
                AnswerButton1.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ1, UIControlState.Normal);
                AnswerButton4.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ2, UIControlState.Normal);
                AnswerButton2.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ3, UIControlState.Normal);
            }
            else if (answerBoxSelection == 4)
            {
                // Correct Answer
                AnswerButton4.SetTitle(ListofTriviaQuestions[rndQuestion].answer, UIControlState.Normal);

                // False Answers
                AnswerButton1.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ3, UIControlState.Normal);
                AnswerButton2.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ2, UIControlState.Normal);
                AnswerButton3.SetTitle(ListofTriviaQuestions[rndQuestion].falseQ1, UIControlState.Normal);
            }
        }
コード例 #2
0
    private void ShowQuestion()
    {
        RemoveAnswerButtons();
        QuestionData1 questionData1 = questionPool1[questionIndex];

        questionDisplayText.text = questionData1.QuestionText;

        for (int i = 0; i < questionData1.answers.Length; i++)
        {
            GameObject answerButtonGameObject = answerButtonObjectPool1.GetObject();
            answerButtonGameObjects.Add(answerButtonGameObject);
            answerButtonGameObject.transform.SetParent(answerButtonParent);

            AnswerButton1 answerButton1 = answerButtonGameObject.GetComponent <AnswerButton1>();
            answerButton1.Setup(questionData1.answers[i]);
        }
    }
コード例 #3
0
        void ReleaseDesignerOutlets()
        {
            if (AnswerButton1 != null)
            {
                AnswerButton1.Dispose();
                AnswerButton1 = null;
            }

            if (AnswerButton2 != null)
            {
                AnswerButton2.Dispose();
                AnswerButton2 = null;
            }

            if (AnswerButton3 != null)
            {
                AnswerButton3.Dispose();
                AnswerButton3 = null;
            }

            if (AnswerButton4 != null)
            {
                AnswerButton4.Dispose();
                AnswerButton4 = null;
            }

            if (congratulationsLabel != null)
            {
                congratulationsLabel.Dispose();
                congratulationsLabel = null;
            }

            if (displayHighScoreLabel != null)
            {
                displayHighScoreLabel.Dispose();
                displayHighScoreLabel = null;
            }

            if (finalScoreLabel != null)
            {
                finalScoreLabel.Dispose();
                finalScoreLabel = null;
            }

            if (highScoreLabel != null)
            {
                highScoreLabel.Dispose();
                highScoreLabel = null;
            }

            if (QuestionLabel != null)
            {
                QuestionLabel.Dispose();
                QuestionLabel = null;
            }

            if (questionNumberLabel != null)
            {
                questionNumberLabel.Dispose();
                questionNumberLabel = null;
            }

            if (QuestionNumberLabel2 != null)
            {
                QuestionNumberLabel2.Dispose();
                QuestionNumberLabel2 = null;
            }

            if (QuestionTimerProgressBar != null)
            {
                QuestionTimerProgressBar.Dispose();
                QuestionTimerProgressBar = null;
            }

            if (returnHomeButton != null)
            {
                returnHomeButton.Dispose();
                returnHomeButton = null;
            }

            if (yourScoreLabel != null)
            {
                yourScoreLabel.Dispose();
                yourScoreLabel = null;
            }
        }