예제 #1
0
    //for every new question
    public void PopQuestion()
    {
        answeredQuestion = false;
        nextButton.SetActive(false);
        //if questions.count is 1 then the next time players see the next button it should say end game
        if (questions.Count == 1)
        {
            nextButtonText.text = "End Game";
        }
        if (questions.Count > 0)
        {
            CorrectText.SetActive(false);
            WrongText.SetActive(false);

            TriviaQuestionObject temp = questions.Pop();

            //add object back to shuffle list to be reshuffled next round
            shuffleList.Add(temp);

            correctAnswer = temp.correctAnswer;

            questionText.text = temp.question;
            answer1Text.text  = "1. " + temp.answer1;
            answer2Text.text  = "2. " + temp.answer2;
            answer3Text.text  = "3. " + temp.answer3;
            answer4Text.text  = "4. " + temp.answer4;
        }
        else
        {
            //show endUI after all questions
            GameUI.SetActive(false);
            EndUI.SetActive(true);
            scoreText.text = "Final Score: " + score + "/10";
        }
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            for (int i = 0; i < listStartCount; i++)
            {
                int randomNum = Random.Range(0, testList.Count);
                testStack.Push(testList[randomNum]);
                testList.Remove(testList[randomNum]);
            }
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            for (int i = 0; i < listStartCount; i++)
            {
                TriviaQuestionObject testObject = testStack.Pop();
                testList.Add(testObject);
                Debug.Log(testObject.question);
            }
        }
    }