Пример #1
0
 public void TestClick()
 {
     bar.UpdateProgress(0.1f);
 }
Пример #2
0
    public void answerButton()
    {
        if (EventSystem.current.currentSelectedGameObject.name == op1.name)
        {
            if (answerOptions[0, 1] == "Correct")
            {
                correct.Play();
                score++;
                numCorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "CORRECT!";
                raceBar.UpdateProgress(1.0f);
            }

            else
            {
                incorrect.Play();
                numIncorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "INCORRECT!";
            }
        }
        if (EventSystem.current.currentSelectedGameObject.name == op2.name)
        {
            if (answerOptions[1, 1] == "Correct")
            {
                correct.Play();
                score++;
                numCorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "CORRECT!";
                raceBar.UpdateProgress(1.0f);
            }

            else
            {
                incorrect.Play();
                numIncorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "INCORRECT!";
            }
        }
        if (EventSystem.current.currentSelectedGameObject.name == op3.name)
        {
            if (answerOptions[2, 1] == "Correct")
            {
                correct.Play();
                score++;
                numCorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "CORRECT!";
                raceBar.UpdateProgress(1.0f);
            }

            else
            {
                incorrect.Play();
                numIncorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "INCORRECT!";
            }
        }
        if (EventSystem.current.currentSelectedGameObject.name == op4.name)
        {
            if (answerOptions[3, 1] == "Correct")
            {
                correct.Play();
                score++;
                numCorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "CORRECT!";
                raceBar.UpdateProgress(1.0f);
            }

            else
            {
                incorrect.Play();
                numIncorrect++;
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().color = new Color(255, 255, 255);
                answerMessage.GetComponent <TMPro.TextMeshProUGUI>().text  = "INCORRECT!";
            }
        }

        if (score == 5)
        {
            SceneManager.LoadScene(4);

            string        conn = "URI=file:" + Application.dataPath + "/Plugins/DMVIE.db"; //location of database
            IDbConnection dbconn;                                                          //object to connect to database
            dbconn = (IDbConnection) new SqliteConnection(conn);                           //database connection created
            dbconn.Open();                                                                 //database connection made
            IDbCommand dbcmd = dbconn.CreateCommand();                                     //object to create commands for database

            string updateProgressQuery = "INSERT INTO usr_prog (username, quizcat, numIncorrect, numCorrect) VALUES (\"" + Login.userRef + "\", \"" + Main_Menu.quizType + "\", \"" + numIncorrect + "\", \"" + numCorrect + "\")";
            dbcmd.CommandText = updateProgressQuery;
            IDataReader reader = dbcmd.ExecuteReader();
            reader.Close();
        }

        if (numIncorrect == 5)
        {
            SceneManager.LoadScene(5);

            string        conn = "URI=file:" + Application.dataPath + "/Plugins/DMVIE.db"; //location of database
            IDbConnection dbconn;                                                          //object to connect to database
            dbconn = (IDbConnection) new SqliteConnection(conn);                           //database connection created
            dbconn.Open();                                                                 //database connection made
            IDbCommand dbcmd = dbconn.CreateCommand();                                     //object to create commands for database

            string updateProgressQuery = "INSERT INTO usr_prog (username, quizcat, numIncorrect, numCorrect) VALUES (\"" + Login.userRef + "\", \"" + Main_Menu.quizType + "\", \"" + numIncorrect + "\", \"" + numCorrect + "\")";
            dbcmd.CommandText = updateProgressQuery;
            IDataReader reader = dbcmd.ExecuteReader();
            reader.Close();
        }

        questionPanel.SetActive(false);
        answerMessage.SetActive(true);
        cardButton.SetActive(true);
    }