Example #1
0
 public static QuizApp getInstance()
 {
     if (app == null)
     {
         app             = new QuizApp();
         app.GameCounter = 0;
         app.Score       = AppGlobal.totalScore;
     }
     return(app);
 }
Example #2
0
    public void SetAnswer(int number)
    {
        Debug.Log("your answer = " + number);
        Boolean result = number == correctAnswer;

        Debug.Log(result ? "YOU WIN" : "YOU LOSE");

        if (result)
        {
            QuizApp.getInstance().addScore(WIN_SCORE);
        }
        showDialog(result);
    }
Example #3
0
    void Start()
    {
        Screen.orientation = ScreenOrientation.Portrait;

        continueButton.onClick.AddListener(() => {
            print("continue");
            messageWindow.SetActive(false);
        });

        if (!QuizApp.getInstance().isFirstGame())
        {
            messageWindow.SetActive(false);
        }

        wheelRigidBody = gameObject.GetComponent <Rigidbody2D> () as Rigidbody2D;
        score.text     = "Score: " + QuizApp.getInstance().Score;
    }
Example #4
0
    void showDialog(Boolean isWinner)
    {
        Text textAnswer = answer.GetComponent <Text> ();

        if (isWinner)
        {
            textAnswer.text = "Your answer is correct!\nEarned 50 points";
        }
        else
        {
            textAnswer.text = "Your answer is incorrect!";
        }

        UnityEngine.UI.Button button = btnContinue.GetComponent <UnityEngine.UI.Button> ();
        button.onClick.AddListener(() => {
            QuizApp.getInstance().AddGame();
            if (QuizApp.getInstance().isGameOver())
            {
                QuizApp.getInstance().NewGame();
                if (AppGlobal.isContinious)
                {
                    StartCoroutine(LeaderBoardAPI.addScore((int)QuizApp.getInstance().Score,
                                                           (s) => {
                        SceneManager.LoadScene("Leaderboards");
                        return;
                    }));
                }
                else
                {
                    SceneManager.LoadScene("MainMenu");
                    return;
                }
            }
            else
            {
                SceneManager.LoadScene("QuizWheel");
            }
        });
        dialog.SetActive(true);
    }
Example #5
0
    // Use this for initialization
    void Start()
    {
        Quiz quiz = QuizApp.getInstance().nextQuiz();

        String[] answers          = ShuffleList(quiz.Answers).ToArray();
        String   correctAnswerStr = quiz.Answers.ToArray() [0];

        this.correctAnswer     = findTrueAnswer(answers, correctAnswerStr);
        this.title.text        = QuizApp.Group;
        this.question.text     = quiz.Question;
        this.groupImage.sprite = findImageByGroup(QuizApp.Group);

        answerButton1 = GameObject.Find("AnswerButton1").GetComponent <UnityEngine.UI.Button> ();
        answerButton2 = GameObject.Find("AnswerButton2").GetComponent <UnityEngine.UI.Button> ();
        answerButton3 = GameObject.Find("AnswerButton3").GetComponent <UnityEngine.UI.Button> ();
        answerButton4 = GameObject.Find("AnswerButton4").GetComponent <UnityEngine.UI.Button> ();

        answerButton1.GetComponentInChildren <Text> ().text = answers [3];
        answerButton2.GetComponentInChildren <Text> ().text = answers [2];
        answerButton3.GetComponentInChildren <Text> ().text = answers [1];
        answerButton4.GetComponentInChildren <Text> ().text = answers [0];

        Debug.Log("correct answer =" + correctAnswer);
    }
Example #6
0
 public void clickWheel()
 {
     AppGlobal.totalScore = 0f;
     QuizApp.getInstance().NewGame();
     SceneManager.LoadScene("QuizWheel");
 }