コード例 #1
0
ファイル: OnlineManager.cs プロジェクト: DevJock/WORDS
    public IEnumerator uploadScoreData()
    {
        Debug.Log("Attempting to Upload Score Data");
        WWWForm form = new WWWForm();

        form.AddField("score", GameController.MyScore.CurrentScore);
        form.AddField("gamerID", UserData.GamerID);
        using (UnityWebRequest www = UnityWebRequest.Post(URL, form)) {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError || www.error != null)
            {
                Debug.Log(www.error);
                ErrorPanel.ShowError("ERROR: " + www.error);
            }
            else
            {
                var response = JSON.Parse(www.downloadHandler.text);
                if (response["code"].AsInt == 200)
                {
                    Debug.Log("Upload Successfull");
                }
                else
                {
                    ErrorPanel.ShowError("Upload Unsuccessfull. Reason: " + response["message"]);
                }
            }
            ButtonHelper.ResetClick();
        }
    }
コード例 #2
0
ファイル: OnlineManager.cs プロジェクト: DevJock/WORDS
    public IEnumerator Login()
    {
        Debug.Log("Attempting Login");
        WWWForm form = new WWWForm();

        form.AddField("email", UserData.EmailID);
        form.AddField("password", UserData.Password);

        using (UnityWebRequest www = UnityWebRequest.Post(AuthenticateURL, form)) {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError || www.error != null)
            {
                Debug.Log(www.error);
                ErrorPanel.ShowError("ERROR: " + www.error);
            }
            else
            {
                var response = JSON.Parse(www.downloadHandler.text);
                Debug.Log("Sign In Successfull");
                UserData.GamerID = response["gamerID"];
                GameController.MyScore.CurrentScore = 0;
                GameController.MyScore.HighScore    = 0;
                StartCoroutine(fetchGameData());
                Debug.Log(response["message"]);
            }
        }
        ButtonHelper.ResetClick();
    }
コード例 #3
0
 public void ACTION_SKIP_ACCOUNT()
 {
     ButtonHelper.Clicked();
     GameController.disableOnline    = true;
     OnlineManager.UserData.EmailID  = "*****@*****.**";
     OnlineManager.UserData.Password = "******";
     StartCoroutine(onlineManager.Login());
     AlertPanel.DismissPanel();
     ButtonHelper.ResetClick();
 }
コード例 #4
0
    public void ACTION_REGISTER()
    {
        ButtonHelper.Clicked();
        string name          = register.transform.Find("name").GetComponent <InputField>().text;
        string email         = register.transform.Find("email").GetComponent <InputField>().text;
        string password      = register.transform.Find("password").GetComponent <InputField>().text;
        string gamerID       = register.transform.Find("gamerID").GetComponent <InputField>().text;
        string validEmail    = FormValidation.ValidEmail(email);
        string validName     = FormValidation.ValidName(name);
        string validPassword = FormValidation.ValidPassword(password);
        string validGamerID  = FormValidation.ValidGamerID(gamerID);


        if (validName != null)
        {
            ErrorPanel.ShowError(validName);
            ButtonHelper.ResetClick();
        }

        else if (validGamerID != null)
        {
            ErrorPanel.ShowError(validGamerID);
            ButtonHelper.ResetClick();
        }

        else if (validEmail != null)
        {
            ErrorPanel.ShowError(validEmail);
            ButtonHelper.ResetClick();
        }

        else if (validPassword != null)
        {
            ErrorPanel.ShowError(validPassword);
            ButtonHelper.ResetClick();
        }

        else
        {
            OnlineManager.UserData.Name     = name;
            OnlineManager.UserData.EmailID  = email;
            OnlineManager.UserData.Password = password;
            OnlineManager.UserData.GamerID  = gamerID;
            StartCoroutine(onlineManager.Register());
        }
    }
コード例 #5
0
ファイル: OnlineManager.cs プロジェクト: DevJock/WORDS
    public IEnumerator downloadScoreData()
    {
        Debug.Log("Attempting to download LeaderBoard Data");
        WWWForm form = new WWWForm();

        using (UnityWebRequest www = UnityWebRequest.Post(URL, form)) {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError || www.error != null)
            {
                Debug.Log(www.error);
                ErrorPanel.ShowError("ERROR: " + www.error);
            }
            else
            {
                var response = JSON.Parse(www.downloadHandler.text);
                if (response["code"].AsInt == 200)
                {
                    Debug.Log("Download Successfull");
                    var           data     = response["leaderBoardData"].AsArray;
                    List <string> gamerIDs = new List <string>();
                    List <string> scores   = new List <string>();
                    foreach (JSONObject obj in data)
                    {
                        var key = obj.GetKeys()[0] as string;
                        gamerIDs.Add(key);
                        scores.Add(obj[key]);
                    }
                    uiManager.showLeaderboardData(gamerIDs, scores);
                    uiManager.SwitchPage(UIManager.Page.HighScore);
                }
                else
                {
                    ErrorPanel.ShowError("Fetch Unsuccessfull. Reason: " + response["description"]);
                }
            }
        }
        ButtonHelper.ResetClick();
    }
コード例 #6
0
ファイル: OnlineManager.cs プロジェクト: DevJock/WORDS
    public IEnumerator fetchGameData()
    {
        Debug.Log("Attempting to Fetch Game Data");
        WWWForm form = new WWWForm();

        form.AddField("gamerID", UserData.GamerID ?? "__no__");
        form.AddField("gamePlatform", GameController.GameData.gamePlatform + "_" + GameController.GameData.gameBuildType + "_" + GameController.GameData.gameVersion);
        using (UnityWebRequest www = UnityWebRequest.Post(URL, form)) {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError || www.error != null)
            {
                Debug.Log(www.error);
                ErrorPanel.ShowError("ERROR: " + www.error);
            }
            else
            {
                var response = JSON.Parse(www.downloadHandler.text);
                if (response["code"].AsInt == 200)
                {
                    Debug.Log("Fetch Successfull");
                    Word_Server.Words = response["words"];
                    WordManager.Initialize();
                    GameController.GameData.enabled = response["enabled"];
                    uiManager.SwitchPage(UIManager.Page.MainMenu);
                }
                else if (response["code"].AsInt == 100)
                {
                    ErrorPanel.ShowError("Error: " + response["message"]);
                    //StartCoroutine(downloadFile());
                }
                else
                {
                    ErrorPanel.ShowError("Fetch Unsuccessfull. Reason: " + response["message"]);
                }
            }
        }
        ButtonHelper.ResetClick();
    }
コード例 #7
0
 public void SHOW_LEADERBOARD()
 {
     ButtonHelper.Clicked();
     StartCoroutine(onlineManager.downloadScoreData());
     ButtonHelper.ResetClick();
 }
コード例 #8
0
 public void SHOW_SKIP_ACCOUNT()
 {
     ButtonHelper.Clicked();
     AlertPanel.ShowError("Skipping Account Sign In/ Sign Up Will disable High Score Tracking.\nAre You Sure you Want to Proceed ?");
     ButtonHelper.ResetClick();
 }
コード例 #9
0
    public void SwitchPage(Page page)
    {
        switch (page)
        {
        case Page.Register:
        {
            if (!text.activeSelf)
            {
                text.SetActive(true);
            }
            register.SetActive(true);
            signIn.SetActive(false);
            mainMenu.SetActive(false);
            Game.SetActive(false);
            ButtonHelper.ResetClick();
        }
        break;

        case Page.SignIn:
        {
            if (!text.activeSelf)
            {
                text.SetActive(true);
            }
            register.SetActive(false);
            signIn.SetActive(true);
            HighScores.SetActive(false);
            mainMenu.SetActive(false);
            Game.SetActive(false);
            ButtonHelper.ResetClick();
        }
        break;

        case Page.MainMenu:
        {
            if (!text.activeSelf)
            {
                text.SetActive(true);
            }
            register.SetActive(false);
            signIn.SetActive(false);
            mainMenu.SetActive(true);
            HighScores.SetActive(false);
            mainMenu.transform.Find("gamerID").GetComponent <Text>().text = OnlineManager.UserData.GamerID;
            Game.SetActive(false);
            ButtonHelper.ResetClick();
        }
        break;

        case Page.HighScore:
        {
            if (!text.activeSelf)
            {
                text.SetActive(true);
            }
            register.SetActive(false);
            signIn.SetActive(false);
            mainMenu.SetActive(false);
            HighScores.SetActive(true);
            Game.SetActive(false);
            ButtonHelper.ResetClick();
        }
        break;

        case Page.Game:
        {
            text.SetActive(false);
            register.SetActive(false);
            signIn.SetActive(false);
            mainMenu.SetActive(false);
            HighScores.SetActive(false);
            Game.SetActive(true);
            ButtonHelper.ResetClick();
        }
        break;
        }
    }