public void Login()
    {
        if (Highscores.GetUsernameHash(usernameLoginField.text) == float.Parse(passwordLoginField.text))
        {
            highscores.ContainsUsername(usernameLoginField.text, (bool contains) => {
                if (contains)
                {
                    SetUsername(usernameLoginField.text);
                    Debug.Log("Loged in as " + username + " with the password " + passwordField.text);

                    ClearError();
                    mainErrorText.color = loginErrorText.color = Color.green;
                    mainErrorText.text  = loginErrorText.text = "Logged in successfully";

                    loginPanel.SetActive(false);
                }
                else
                {
                    Debug.Log("Username not recognised");
                    loginErrorText.text = "Username or password incorrect";
                }
            });
        }
        else
        {
            Debug.Log("Password incorrect");
            loginErrorText.text = "Username or password incorrect";
        }
    }
Ejemplo n.º 2
0
 public Highscore(string username, int score, Version version)
 {
     this.username = username;
     this.score    = score;
     this.version  = version;
     hash          = Highscores.GetUsernameHash(username);
 }
Ejemplo n.º 3
0
    public Highscore(string pipe)
    {
        string[] parts = pipe.Split(new char[] { '|' });

        if (parts.Length == 1)
        {
            this = Null;
        }
        else
        {
            string  username = WWW.UnEscapeURL(parts[0]);
            int     score    = int.Parse(parts[1]);
            Version version  = (parts[3] == "Full") ? Version.Full : Version.Lite;

            this.username = username;
            this.score    = score;
            this.version  = version;

            hash = Highscores.GetUsernameHash(username);
        }
    }
    IEnumerator CheckUsername()
    {
        yield return(null);

        if (string.IsNullOrEmpty(username))
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                multiplayerButton.interactable = logoutButton.interactable = deleteAccoundButton.interactable = false;
                ShowError("No internet connection");
            }
            else
            {
                doneButton.interactable = false;
                UI.SetPage("Username", true);
            }
        }
        else
        {
            usernameField.readOnly = true;
            passwordField.gameObject.SetActive(true);
            passwordField.text = Highscores.GetUsernameHash(username).ToString();
        }
    }
 void SetUsername(string username)
 {
     PlayerPrefs.SetString("Username", username);
     Options.username   = usernameField.text = username;
     passwordField.text = passwordPanelField.text = Highscores.GetUsernameHash(username).ToString();
 }