예제 #1
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");
    }
예제 #2
0
    // Used by the Register when it's finished executing
    void RegistrationFormDownloaded(string callbackMessage)
    {
        // Check for Errors
        if (callbackMessage.IsAnError())
        {
            Debug.LogError(callbackMessage);
            return;
        }

        // 1) Add the user's input to the accountInfo fields
        foreach (AS_MySQLField field in accountInfo.fields)
        {
            // At this step you would normally prompt your user for input via the GUI)
            accountInfo.SetFieldValue(field.name, "somethingFromOurUsers@_" + randomNum.ToString());
        }

        // We will also use the provided username and password
        accountInfo.SetFieldValue("username", username);
        accountInfo.SetFieldValue("password", password);

        // 2) Attempt to Register
        accountInfo.TryToRegister(RegistrationAttempted);
    }
예제 #3
0
    // 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;
        }
    }