Ejemplo n.º 1
0
    void ChosenAnswer(int number)
    {
        currentHealth = infectionB.getHealth();//get the current value of the health bar

        checkNumber = number;
        //switch checks if answer was correct and displays the corresponding screen
        if (number == correctAnswer)
        {
            // change colour of selected option
            switchGreen();

            // display correct UI
            Invoke("correctPopUp", 0.5f);

            // add to score. 1st argument is personal 2nd is community
            if (string.Equals(displayQuestion[4], "both"))
            {
                scoreScript.setScore(1, 1);
            }
            else if (string.Equals(displayQuestion[4], "pers"))
            {
                scoreScript.setScore(1, 0);
            }
            else
            {
                scoreScript.setScore(0, 1);
            }

            // display quiz
            Invoke("backToQuiz", 2);
        }
        else
        {
            // change colour of selected option
            switchRed();

            // increase infection bar by a third
            currentHealth += 33;
            infectionB.SetHealth(currentHealth);

            // display incorrect pop
            Invoke("incorrectPopUp", 0.5f);

            if (currentHealth < 90)
            {
                // display next quiz question
                Invoke("backToQuiz", 2);
            }
            else
            {
                Invoke("levelFailedPopUp", 2);
            }
        }

        //Output this to console when Button1 or Button3 is clicked
        Debug.Log($"You have clicked the button {number}!");
    }
Ejemplo n.º 2
0
    void ChosenAnswer(int number)
    {
        currentHealth = infectionB.getHealth();//get the current value of the health bar
        checkNumber   = number;
        //switch checks if answer was correct and displays the corresponding screen
        if (number == correctAnswer)
        {
            // change colour of selected option
            switchGreen();

            // display correct UI
            Invoke("correctPopUp", 0.5f);

            // add to score. 1st argument is personal 2nd is community
            if (string.Equals(displayQuestion[6], "both"))
            {
                scoreScript.setScore(1, 1);
            }
            else if (string.Equals(displayQuestion[6], "pers"))
            {
                scoreScript.setScore(1, 0);
            }
            else
            {
                scoreScript.setScore(0, 1);
            }

            // display quiz
            Invoke("backToQuiz", 2);
        }
        else
        {
            // change colour of selected option
            switchRed();

            // increase infection bar by 20
            currentHealth += 33;
            infectionB.SetHealth(currentHealth);

            // display incorrect pop
            Invoke("incorrectPopUp", 0.5f);

            if (currentHealth < 90)
            {
                // display next quiz question
                Invoke("backToQuiz", 2);
            }
            else
            {
                Invoke("levelFailedPopUp", 2);
            }
        }

        switch (num)
        {
        case 0:
            if (number == 3)
            {
                score += 1;
            }
            break;

        case 1:
            if (number == 2)
            {
                score += 1;
            }
            break;

        case 2:
            if (number == 4)
            {
                score += 1;
            }
            break;

        case 3:
            if (number == 4)
            {
                score += 1;
            }
            break;
        }
    }