Esempio n. 1
0
 public void RestartGame()
 {
     SceneManager.LoadScene(startGameLevel);
     AnswerController.ResumeGame();
     DistanceManager.pointsPerSecondsLast          = 0;
     AnswerCorrectManager.answerCorrectCountStatic = 0;
 }
    // Método para o Botão <Start>
    public void StartGame()
    {
        nickname = inputNickname.text;

        if (string.IsNullOrEmpty(inputNickname.text))
        {
            SSTools.ShowMessage("Verifique o Nickname!", SSTools.Position.bottom, SSTools.Time.twoSecond);

            return;
        }
        if (SelectTheme.themeValue == 0)
        {
            SSTools.ShowMessage("Selecione um Tema!", SSTools.Position.bottom, SSTools.Time.twoSecond);

            return;
        }
        else
        {
            SceneManager.LoadScene(startGameLevel);
            AnswerController.ResumeGame();
            AnswerCorrectManager.answerCorrectCountStatic = 0;
            DistanceManager.pointsPerSecondsLast          = 0;
        }
    }
    public void OnSelect(bool change)
    {
        Debug.Log(isCorrectController);

        if (isCorrectController)
        {
            isCorrectStatic = isCorrectController;
            Destroy(GameObject.Find("Perguntas(Clone)"));
            AnswerController.ResumeGame();
        }
        else
        {
            Destroy(GameObject.Find("Perguntas(Clone)"));
            GameObject postDeath = GameObject.Instantiate(postDeathPrefabs);

            try
            {
                string queryVerify = $"SELECT * FROM [Player] WHERE [Nickname] = '{MainMenu.nickname}'";

                var verifyNickname = myDB.ExecuteQuery(queryVerify);

                while (verifyNickname.Read())
                {
                    verifyNicks.Add(verifyNickname.GetString(1));
                }

                verifyNicks.Count.ToString();

                if (verifyNicks.Count.Equals(0))
                {
                    Debug.Log("Inserir dados desse Nickname: " + verifyNicks.Count);

                    string query =
                        $"INSERT INTO [Player](ID_Player, Nickname, Distancia_Percorrida, Respostas_Corretas) VALUES(null, '{MainMenu.nickname}', {DistanceManager.pointsPerSecondsLast}, {AnswerCorrectManager.answerCorrectCountStatic})";

                    myDB.ExecuteQuery(query);

                    Debug.Log("DISTANCIA: " + DistanceManager.pointsPerSecondsLast);
                    Debug.Log("PERGUNTAS CORRETAS: " + AnswerCorrectManager.answerCorrectCountStatic);
                    Debug.Log("NICKNAME: " + MainMenu.nickname);
                }
                else
                {
                    Debug.Log("Fazer Update desse nickname: " + verifyNicks.Count);

                    string queryUpdate =
                        $"UPDATE [Player] SET [Distancia_Percorrida] = {DistanceManager.pointsPerSecondsLast}, [Respostas_Corretas] = {AnswerCorrectManager.answerCorrectCountStatic} WHERE [Nickname] = '{MainMenu.nickname}'";

                    myDB.ExecuteQuery(queryUpdate);

                    Debug.Log("DISTANCIA: " + DistanceManager.pointsPerSecondsLast);
                    Debug.Log("PERGUNTAS CORRETAS: " + AnswerCorrectManager.answerCorrectCountStatic);
                    Debug.Log("NICKNAME: " + MainMenu.nickname);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
    }