コード例 #1
0
    public void login()
    {
        //this is the parameter sent to the server to verify credentials for login
        string[]  param     = new string[2];
        string[]  responses = new string[4];
        ShortCuts usc       = new ShortCuts();

        //get the input field value from Login Scene
        param[0] = usc.InputValue("loginUserName");
        Debug.Log(param[0]);
        param[1] = usc.InputValue("loginPassword");
        Debug.Log(param[1]);
        if (!param[0].Contains(" ") && !param[1].Contains(" "))
        {
            //start the Connections Manager
            ConnectionManager CM = new ConnectionManager();
            if (CM.StartClient() == 1)
            {
                responses = CM.SubmitLogin(param);
                if (responses.Length > 0)
                {                 //there is good response!
                    for (int i = 0; i < 4; i++)
                    {
                        Debug.Log(responses[i]);
                    }
                    UserInfo accountInfo = JsonUtility.FromJson <UserInfo>(responses[3]);
                    SaveInfo(accountInfo);
                    SceneNavigator navi = new SceneNavigator();
                    navi.GoToScene("MainMenu");
                }
            }
            else
            {
                Debug.Log("Failed to start ConnectionsManager Client");
            }
        }
    }
コード例 #2
0
    public void submitBTN()
    {
        UnityShortCuts.ShortCuts finder = new ShortCuts();
        string[] responses = new string[6];
        string[] param     = new string[6];
        string   passOne;
        string   passTwo;
        int      passWordCheck = 1;

        param[0] = finder.InputValue("usernameInput");
        Debug.Log(param[0]);

        param[1] = finder.InputValue("userEmailInput");
        Debug.Log(param[1]);

        param[2] = finder.InputValue("userFNameInput");
        Debug.Log(param[2]);

        param[3] = finder.InputValue("userLNameInput");
        Debug.Log(param[3]);

        passOne = finder.InputValue("userPasswordInputOne");
        passTwo = finder.InputValue("userPasswordInputTwo");
        if (string.Equals(passOne, passTwo))
        {
            param[4] = passOne;
            myinfo   = new UserInfo(param[2], param[3], param[1], param[0]);
            //SaveInfo(myinfo);
            Debug.Log(param[4]);
        }
        else
        {
            passWordCheck = 0;
        }

        //param[5] = InputValue("userAgeInput");
        //Debug.Log(param[5]);

        if (passWordCheck == 1)
        {
            ConnectionManager CM   = new ConnectionManager();
            SceneNavigator    navi = new SceneNavigator();
            int accepted           = CM.StartClient();
            if (accepted == 1)
            {
                responses = CM.SubmitRegisteration(param);
                if (responses.Length > 0)
                {
                    /* for(int i = 0; i < 7; i++)
                     * {
                     *      Debug.Log(responses[i]);
                     *      string result = responses[i];
                     *      Debug.Log(result.Trim());
                     *      if(string.Equals(result, "1"))
                     *      {
                     *              Debug.Log("Catching that user was added and able to create an event here");
                     *              navi.GoToScene("LoginScreen");
                     *      }
                     *      else
                     *      {
                     *              Debug.Log("Not catching success");
                     *      }
                     * }*/
                    int desiredResult = 1;
                    int result        = System.Convert.ToInt32(responses[6]);
                    Debug.Log(result == desiredResult);
                    if (result == desiredResult)
                    {
                        navi.GoToScene("LoginScreen");
                    }
                    else
                    {
                        Debug.Log("Failed to create Account");
                    }
                }
            }
        }
        else
        {
            showError("passwordMatch");
        }
    }