Ejemplo n.º 1
0
    //Log user in
    public void Login()
    {
        //Get entered username and password
        string username  = UsernameBox.GetComponent <InputField>().text;
        string password  = PasswordBox.GetComponent <InputField>().text;
        string bonusCode = BonusCodeBox.GetComponent <InputField>().text;
        //Attempt user login
        int status = DatabaseManager.GetComponent <NetworkManager>().PlayerLogin(username, password, bonusCode);

        //Log user in if successful (status == 0)
        if (status == 0)
        {
            StartGame();
            return;
        }
        //Else print error code
        //Get error message
        if (status == -1)    //Username not found
        {
            ErrorMessage.GetComponent <Text>().text  = "Error: Username not found";
            ErrorMessage.GetComponent <Text>().color = Color.red;
        }
        else if (status == -2) //Password incorrect
        {
            ErrorMessage.GetComponent <Text>().text  = "Error: Password incorrect";
            ErrorMessage.GetComponent <Text>().color = Color.red;
        }
    }