Beispiel #1
0
    public void OnLoginFB(string username, string pass, string name = "")
    {
        usernameLogin = username;
        passwordLogin = pass;

        //usernameLogin.TryToLogin(passwordLogin, LoginAttempted);
        StartCoroutine(AS_Login.TryToLoginFB(username: username, password: pass, resultCallback: LoginAttempted, Namefb: name));
        // Equivalent to:
        // StartCoroutine ( AS_Login.TryToLogin( usernameLogin, passwordLogin, LoginAttempted ) ) ;
        Debug.Log("Attempting to Log In.." + usernameLogin + ":" + passwordLogin);
        GameManager.instance.ShowLoading(true);
    }
    /// <summary>
    /// Tries to register.
    /// </summary>
    /// <param name="accountInfo">New account info.</param>
    /// <param name="callback">What to call when we are done.</param>
    /// <param name="phpScriptsLocation">Where the PHP scripts are located.</param>
    public static void TryToRegister(this AS_AccountInfo accountInfo, Action <string> callback, string phpScriptsLocation = null)
    {
        AS_CoroutineCaller caller = AS_CoroutineCaller.Create();

        caller.StartCoroutine(AS_Login.TryToRegister
                                  (accountInfo,
                                  value =>
        {
            caller.Destroy();
            callback(value);
        },
                                  phpScriptsLocation));
    }
    /// <summary>
    /// Tries to login.
    /// </summary>
    /// <param name="username">Username.</param>
    /// <param name="password">Password.</param>
    /// <param name="callback">What to call when we are done.</param>
    /// <param name="phpScriptsLocation">Where the PHP scripts are located.</param>
    public static void TryToLogin(this string username, string password, Action <string> callback, string phpScriptsLocation = null)
    {
        AS_CoroutineCaller caller = AS_CoroutineCaller.Create();

        caller.StartCoroutine(AS_Login.TryToLogin
                                  (username, password,
                                  value =>
        {
            caller.Destroy();
            callback(value);
        },
                                  phpScriptsLocation));
    }
    /// <summary>
    /// Tries to recover the password.
    /// </summary>
    /// <param name="email">Where to send the password recovery link.</param>
    /// <param name="callback">What to call when we are done.</param>
    /// <param name="phpScriptsLocation">Where the PHP scripts are located.</param>
    public static void TryToRecoverPassword(this string email, Action <string> callback, string phpScriptsLocation = null)
    {
        AS_CoroutineCaller caller = AS_CoroutineCaller.Create();

        caller.StartCoroutine(AS_Login.TryToRecoverPassword
                                  (email,
                                  value =>
        {
            caller.Destroy();
            callback(value);
        },
                                  phpScriptsLocation));
    }
Beispiel #5
0
    public void OnRegisterBtn(string email, string pass, string nickName, string country)
    {
        accountInfo.fields.SetFieldValue("username", email);
        accountInfo.fields.SetFieldValue("email", email);
        accountInfo.fields.SetFieldValue("password", pass);
        accountInfo.fields.SetFieldValue("NickName", nickName);
        accountInfo.fields.SetFieldValue("Country", country);

        Debug.Log("выполнение registerBTN");
        if (!AS_Login.CheckFields(accountInfo, ref guiMessage))
        {
            GameManager.instance.PopupMessage(guiMessage);
            return;
        }

        // Online check with the given database
        guiMessage = "Attempting to Register..";
        accountInfo.TryToRegister(RegistrationAttempted);
        // Equivalent to:
        // StartCoroutine ( AS_Login.TryToRegister( accountInfo, RegistrationAttempted ) ) ;
        GameManager.instance.ShowLoading(true);
        Debug.Log("выполнился register");
    }
    // Called by OnGUI and provides a basic registration GUI layout
    void RegistrationGUI()
    {
        // Title
        GUILayout.Label("~~~==== Registration ====~~~", GUILayout.Width(300));
        GUILayout.Label(" ", GUILayout.Width(100));

        // Registration Info has the fields the user should fill in
        foreach (AS_MySQLField field in accountInfo.fields)
        {
            // Id is an auto-increment unique identifier
            // and custom info is not specified during registration
            if (field.name.ToLower() == "id" | field.name.ToLower() == "custominfo" | field.name.ToLower() == "isactive")
            {
                continue;
            }

            // For any given field
            GUILayout.BeginHorizontal();

            // Print the name
            // Check if it's required
            string msgRequired = field.isRequired ? "\t\b *" : "";
            GUILayout.Label(field.name.UppercaseFirst() + msgRequired, GUILayout.Width(200));

            // Prompt the user to input the value
            // And store the value
            string tempVal = "";
            if (field.name.ToLower().Contains("password"))
            {
                passwordPrompt = GUILayout.TextField(passwordPrompt, new GUILayoutOption[] { GUILayout.Width(200), GUILayout.Height(20) });
                accountInfo.fields.SetFieldValue(field.name, passwordPrompt);
            }

            else
            {
                tempVal = GUILayout.TextField(accountInfo.fields.GetFieldValue(field.name), new GUILayoutOption[] { GUILayout.Width(200), GUILayout.Height(20) });
                accountInfo.fields.SetFieldValue(field.name, tempVal);
            }

            GUILayout.EndHorizontal();


            // Additionally, if it's the password or email
            // Ask for confirmation
            if (field.name.ToLower().Contains("password"))
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label("Repeat your Password:"******"email"))
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label("Repeat your Email:", GUILayout.Width(200));

                emailConfirm = GUILayout.TextField(emailConfirm,
                                                   new GUILayoutOption[] { GUILayout.Width(200), GUILayout.Height(20) });

                GUILayout.EndHorizontal();
            }
        }

        GUILayout.Label(" ", GUILayout.Height(10));
        GUILayout.Label("*: Required Field", GUILayout.Width(300));
        GUILayout.Label(" ", GUILayout.Height(10));

        // For errors ( username taken etc.. )
        GUILayout.Label(guiMessage);
        GUILayout.Label(" ", GUILayout.Height(10));

        // Submit registration button
        if (GUILayout.Button("Register",
                             new GUILayoutOption[] { GUILayout.Width(150), GUILayout.Height(50) }))
        {
            // Offline field check
            if (!AS_Login.CheckFields(accountInfo, ref guiMessage))           // passwordConfirm, emailConfirm, ref guiMessage))
            {
                return;
            }

            // Online check with the given database
            guiMessage = "Attempting to Register..";
            accountInfo.TryToRegister(RegistrationAttempted);
            // Equivalent to:
            // StartCoroutine ( AS_Login.TryToRegister( accountInfo, RegistrationAttempted ) ) ;
        }

        // Return to Login
        if (GUILayout.Button("Back",
                             new GUILayoutOption[] { GUILayout.Width(75), GUILayout.Height(40) }))
        {
            usernameLogin = "";
            passwordLogin = "";
            loginState    = AS_LoginState.LoginPrompt;
        }
    }