Esempio n. 1
0
 /// <summary>
 /// ddisplay battle results
 /// </summary>
 private void toggleResultScreen()
 {
     twitterShareController.setResults(normal.levelNo, score);
     questionUI.SetActive(false);
     resultUIScript.gameObject.SetActive(true);
     userData.setCoin(userData.getCoin() + monsterScript.Coin);
     //level up
     if (userData.getMaxExperience() <= userData.getExperience() + monsterScript.Experience)
     {
         userData.setLevel(userData.getLevel() + 1);
         userData.setExperience(userData.getMaxExperience() - userData.getExperience() + monsterScript.Experience);
     }
     else
     {
         userData.setExperience(userData.getExperience() + monsterScript.Experience);
     }
     LoginDbHandler.UpdateToDatabase(userData);
     if (PlayerHealth <= 0)
     {
         resultUIScript.setResults(score, 0, 0);
     }
     else
     {
         resultUIScript.setResults(score, monsterScript.Coin, monsterScript.Experience);
     }
     mainMenuControllerScript.loadMainMenu();
     if (isThisNormalLevel)
     {
         RestClient.Put($"https://engeenur-17baa.firebaseio.com/score/" + userData.getName() + "/levelScore/" + normal.levelNo + ".json", score.ToString());
     }
     else
     {
         RestClient.Put($"https://engeenur-17baa.firebaseio.com/specialScore/" + special.courseName + "/" + userData.getName() + ".json", score.ToString());
     }
 }
Esempio n. 2
0
    /// <summary>
    /// This function is use to allow the user to login when the user click on the Login button. Checks will be done by the server to verify the user before logging him/her in
    /// </summary>
    public async void login()
    {
        string email    = emailInput.text.Trim().ToLower();
        string password = passwordInput.text;

        Debug.Log(email);
        Debug.Log(password);

        if ((email == "" || email == null) && (password == "" || password == null))
        {
            Debug.Log("Email Password not filled");
            StartCoroutine(EmailPasswordNotFill());
        }
        else
        {
            if (email == "" || email == null)
            {
                Debug.Log("Email not filled");
                StartCoroutine(EmailNotFill());
            }
            else
            {
                if (password == "" || password == null)
                {
                    Debug.Log("Password not filled");
                    StartCoroutine(PassNotFill());
                }
                else
                {
                    Debug.Log(email);
                    Debug.Log(password);
                    Debug.Log("entering loginChk");
                    string loginChk = await PostRequest(email, password);

                    Debug.Log("exited loginChk. Value below.");
                    Debug.Log(loginChk);
                    if (loginChk != null)
                    {
                        Debug.Log("loginChk is not null");
                        studentChk = await ChkStudent(loginChk);

                        Debug.Log("studenChk exited");
                        if (studentChk == true)
                        {
                            Debug.Log("studentChk true");
                            Debug.Log(userData.userName);
                            mainMenuController.setUserData(userData);
                            mainMenuController.loadMainMenu();
                            UIController.loginButton();
                        }
                        else
                        {
                            Debug.Log("Wrong User Pass");
                            StartCoroutine(ShowWrongMessage());
                        }
                    }
                    else
                    {
                        Debug.Log("Wrong User Pass");
                        StartCoroutine(ShowWrongMessage());
                    }
                }
            }
        }
    }