Beispiel #1
0
    public async void SendFormData()
    {
        if (PlayerPrefs.GetInt("registered") == 1)
        {
            DisplayMessage("You cannot register twice");
            return;
        }

        string userName = GameObject.Find("UsernameInput").transform.Find("Text").GetComponent <Text>().text;
        string token    = GameObject.Find("TokenInput").transform.Find("Text").GetComponent <Text>().text;

        Highscore highscore = await Highscores.Create(userName, token);

        if (highscore != null)
        {
            PlayerPrefs.SetString("_id", highscore._id);
            PlayerPrefs.SetString("username", highscore.user);
            PlayerPrefs.SetString("token", highscore.token);
            PlayerPrefs.SetInt("highScore", highscore.score);
            PlayerPrefs.SetInt("rank", highscore.rank);
            PlayerPrefs.SetInt("registered", 1);
            LoadMainMenu();
        }
        else
        {
            HandleError();
        }
    }