Exemplo n.º 1
0
    /// <summary>
    /// Sends the inventory data.
    /// </summary>
    /// <returns><c>true</c>, if inventory data was sent, <c>false</c> otherwise.</returns>
    public void SendInventoryData()
    {
        new AuthenticationRequest()
        .SetPassword("0000")
        .SetUserName(StaticInfo.userInfo.userName)
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Login successfully");
            }
            else
            {
                Debug.Log("Error login");
            }
        });
        //データ整形(シリアライズ込み)
        string jsonData = JsonUtility.ToJson(new Serialization <Item>(StaticInfo.items));

        GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData(jsonData);
        //送信リクエスト
        new LogEventRequest()
        .SetEventKey("SaveInventory")
        .SetEventAttribute("inventory", data)
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Save inventory successfully");
            }
            else
            {
                Debug.Log("Error save inventory");
            }
        });
    }
Exemplo n.º 2
0
    public void OnSubmitNewPassword()
    {
        //Sending the request with spaces for Username and Password so no errors are given and scriptData is sent
        //Response is breaken down and the result of the action is determined for debug or feedback to user
        GameSparks.Core.GSRequestData script = new GameSparks.Core.GSRequestData();

        script.Add("action", "resetPassword");
        script.Add("token", TokenInput.text);
        script.Add("password", NewPasswordInput.text);

        new AuthenticationRequest().SetUserName("").SetPassword("").SetScriptData(script).Send((response) => {
            if (response.HasErrors)
            {
                if (response.Errors.GetString("action") == "complete")
                {
                    GenericPopup popup = Backend.Utility.MakeNewGenericPopup("Success!", "Password changed. You will now be returned to the main menu.", false);
                    popup.OkButton.onClick.AddListener(() => SceneManager.Instance.LoadScene("TitleScreen"));

                    TokenInput.text       = "";
                    NewPasswordInput.text = "";
                }
                else
                {
                    Backend.Utility.MakeNewGenericPopup("Failed!", "Please ensure token is valid", false);
                }
            }
        });
    }
    public void CancelHosting()
    {
        if (hosting)
        {
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserID.myDisplayName);
            participantData.AddBoolean("hosting", true);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Cancel host
            hosting = false;
            matchmakingRequest.SetAction("cancel");
            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            // Change button text to represent hosting a game
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text          = "Host Game";
            joinGameButton.interactable = true;
            onRefreshGamesButtonClick();
            UnblockMatchmakingButton();
        }
    }
Exemplo n.º 4
0
    public void SendRecoveryTokenRequest()
    {
        Initialize();

        Debug.Log("Sending Recovery Token Request...");

        var data = new GameSparks.Core.GSRequestData()
                   .AddString("email", emailInput.text)
                   .AddString("action", "passwordRecoveryRequest");

        new GameSparks.Api.Requests.AuthenticationRequest()
        .SetUserName("")
        .SetPassword("")
        .SetScriptData(data)
        .Send((response) =>
        {
            if (response.Errors.GetString("action") == "complete")
            {
                Debug.Log(string.Format("Request Token Sent To Email : {0}", emailInput.text));
                tokenInputPanel.SetActive(true);
                tokenRequestPanel.SetActive(false);
            }
            else
            {
                Debug.Log("Error Requesting Token... \n " + response.Errors.JSON.ToString());
                emailErrorText.text = "Invalid E-Mail. Please Try Again.";
                emailErrorHighlight.SetActive(true);
            }
        });
    }
    private void onRefreshGamesButtonClick()
    {
        BlockRefreshInput();
        // Make sure the user isn't currently hosting that way the refresh doesn't remove their hosted lobby/game
        if (!hosting)
        {
            GameSparksUserID gameSparksUserIDScript = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();
            // Do a matchmaking request
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserIDScript.myDisplayName);
            participantData.AddBoolean("hosting", false);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Store this request incase we get a throttled message
            lastMatchmakingRequest = matchmakingRequest;

            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            FindGameLobbies();
        }
        else
        {
            FindGameLobbies();
        }
    }
Exemplo n.º 6
0
    public void OnSubmitTokenRequest()
    {
        //Construction a GSRquestData object to pass in as scriptData

        GameSparks.Core.GSRequestData script = new GameSparks.Core.GSRequestData();

        script.Add("action", "passwordRecoveryRequest");
        script.Add("email", EmailAddress.text);


        //Sending the request with spaces for Username and Password so no errors are given and scriptData is sent
        //Response is breaken down and the result of the action is determined for debug or feedback to user
        new AuthenticationRequest().SetUserName("").SetPassword("").SetScriptData(script).Send((response) => {
            if (response.HasErrors)
            {
                if (response.Errors.GetString("action") == "complete")
                {
                    GenericPopup popup = Backend.Utility.MakeNewGenericPopup("Email sent!", "Check your email for a reset token.", false);
                    popup.OkButton.onClick.AddListener(() => StartCoroutine(TransitionBetweenCanvasGroups(ForgotPwdCanvasGroup, NewPwdCanvasGroup)));

                    EmailAddress.text = "";
                }
                else
                {
                    Backend.Utility.MakeNewGenericPopup("Email not sent!", "Please ensure email is linked to account", false);
                }
            }
        });
    }
Exemplo n.º 7
0
        internal void SendImmediate(GSRequest request)
        {
            if (_WebSocketClient != null)
            {
                lock (_WebSocketClient)
                {
                    if (_WebSocketClient != null)
                    {
                        if (!request.Type.Equals(".AuthenticatedConnectRequest"))
                        {
                            if (request.GetString("requestId") == null)
                            {
                                request.AddString("requestId", DateTime.Now.Ticks + "_" + (_gs._requestCounter++));
                            }

                            //if (request.MaxResponseTimeInMillis != _gs.RequestTimeout) {
                            //	request.AddNumber ("timeout", request.MaxResponseTimeInMillis);
                            //}

                            lock (_pendingRequests) {
                                _pendingRequests.Add(request.GetString("requestId"), request);
                            }
                        }

                        String requestJson = request.JSON;

                        _gSPlatform.DebugMsg("SEND:" + requestJson);

                        //Wrap it in a secure request
                        if (_gs.GSPlatform.ApiSecret.Contains(":") && SessionId != null)
                        {
                            GSRequestData secureRequest = new GSRequestData();

                            secureRequest.AddString("json", requestJson);
                            secureRequest.AddString("hmac", _gs.GSPlatform.MakeHmac(requestJson, _gs.GSPlatform.ApiSecret + "-" + SessionId));

                            requestJson = secureRequest.JSON;
                        }

                        if (_gs.GSPlatform.ApiSecret.Contains(":"))
                        {
                            requestJson = Encrypt(requestJson);
                        }

                        if (_gs.TraceMessages)
                        {
                            _gSPlatform.DebugMsg("SOCKET-SEND:" + requestJson);
                        }

                        _WebSocketClient.Send(requestJson);
                    }
                }
            }
        }
Exemplo n.º 8
0
    public void ConfirmRecoveryToken()
    {
        bool error = false;

        Initialize();

        if (passwordInput.text.Length < 8)
        {
            passwordErrorHighlight.SetActive(true);
            passwordErrorText.text = "Password Must be Longer than Eight Digits!";
        }

        if (passwordInput.text != confirmPasswordInput.text)
        {
            confirmPasswordErrorText.text = "Passwords do not Match!";
            passwordErrorText.text        = "Passwords do not Match!";
            confirmPasswordErrorHighlight.SetActive(true);
            passwordErrorHighlight.SetActive(true);
            error = true;
        }

        if (error)
        {
            return;
        }

        var data = new GameSparks.Core.GSRequestData()
                   .AddString("token", recoveryTokenInput.text)
                   .AddString("password", passwordInput.text)
                   .AddString("action", "resetPassword");

        Debug.Log("Contacting...");

        new GameSparks.Api.Requests.AuthenticationRequest()
        .SetUserName("")
        .SetPassword("")
        .SetScriptData(data)
        .Send((response) =>
        {
            if (response.Errors.GetString("action") == "complete")
            {
                Debug.Log("Password change Successful!");
                this.gameObject.SetActive(false);
            }
            else
            {
                Debug.Log("Error... \n " + response.Errors.JSON.ToString());

                recoveryTokenErrorText.text = "Recovery Token Incorrect.";
                recoveryTokenErrorHighlight.SetActive(true);
            }
        });
    }
        public void NewPasswordLogin()
        {
            DataController.SaveValue("password", password.text);

            Debug.Log(password.text);

            var loginRequest = new AuthenticationRequest();

            GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData();

            data.AddString("password", DataController.GetValue <string>("password"));

            data.AddString("action", "resetPassword");

            data.AddString("token", token.text);

            loginRequest.SetScriptData(data);

            loginRequest.SetUserName(DataController.GetValue <string>("username"));

            loginRequest.SetPassword(password.text);

            loginRequest.Send(response =>
            {
                if (response.Errors.GetString("action").Contains("complete"))
                {
                    Warning.SetActive(true);

                    PopUpMessage.ActivatePopUp(delegate {  }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning5"));

                    UIController.SetActivePanel(UI_Element.Login);
                }

                if (response.Errors.GetString("action").Contains("invalid"))
                {
                    Warning.SetActive(true);

                    PopUpMessage.ActivatePopUp(delegate { }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning4") + LocalisationSystem.GetLocalisedValue("password_error"));

                    UIController.SetActivePanel(UI_Element.ConfirmResetPassword);
                }


                Debug.Log("well done " + response.Errors.JSON.ToString());

                if (!response.HasErrors)
                {
                    Debug.Log("Error reseting password.../n" + response.Errors.JSON.ToString());
                }
            });
        }
    public void OnHostGameButtonClick()
    {
        BlockMatchmakingButton();
        joinGameButton.interactable = false;
        EventSystem.current.SetSelectedGameObject(null);

        gameSparksUserID = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();

        MatchmakingRequest matchmakingRequest = new MatchmakingRequest();

        matchmakingRequest.SetMatchShortCode("HostedMatch");

        GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
        participantData.AddString("displayName", gameSparksUserID.myDisplayName);
        participantData.AddBoolean("hosting", true);
        matchmakingRequest.SetParticipantData(participantData);
        matchmakingRequest.SetMatchData(participantData);
        matchmakingRequest.SetSkill(0);


        if (!hosting)
        {
            hosting = true;
            // Change button text to represent canceling host
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text = "Cancel Host";
        }
        else
        {
            // Cancel host
            hosting = false;
            matchmakingRequest.SetAction("cancel");
            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            // Change button text to represent hosting a game
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text          = "Host Game";
            joinGameButton.interactable = true;
            onRefreshGamesButtonClick();
            UnblockMatchmakingButton();
        }

        matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
    }
Exemplo n.º 11
0
    /// <summary>
    /// Sends the user info.
    /// </summary>
    /// <returns><c>true</c>, if user info was sent, <c>false</c> otherwise.</returns>
    public void SendUserInfo()
    {
        //とりあえず保存先ユーザー指定,認証
        new AuthenticationRequest()
        .SetPassword("0000")
        .SetUserName(StaticInfo.userInfo.userName)
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Authentication successfully");
            }
            else
            {
                Debug.Log("Error authentication");
            }
        });

        //プレイヤーデータ整形
        PlayerData player = new PlayerData {
            gold = StaticInfo.userData.gold,
            rate = StaticInfo.userData.rate
        };
        //jsonに変換
        string jsonData = JsonUtility.ToJson(player);

        GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData(jsonData);
        //送信イベントリクエスト
        new LogEventRequest()
        .SetEventKey("SavePlayerData")
        .SetEventAttribute("playerData", data)
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Save data successfully");
            }
            else
            {
                Debug.Log("Error save player data");
            }
        });
    }
    public void CheckHosting()
    {
        if (hosting)
        {
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserID.myDisplayName);
            participantData.AddBoolean("hosting", true);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Store this request incase we get a throttled message
            lastMatchmakingRequest = matchmakingRequest;

            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            FindGameLobbies();
        }
        hostingCheckTimer.ResetTimer();
        hostingCheckTimer.StartCountdown();
    }
Exemplo n.º 13
0
    public void createNewPlayer()
    {
        playerClass = activeButtons[1].nameID;
        rank        = 1;
        points      = 0;


        var classData = new GameSparks.Core.GSRequestData().AddString("classData", playerClass);

        if (gameSparksAvailable)
        {
            Debug.Log("Registering...");
            new RegistrationRequest()
            .SetUserName(username)
            .SetDisplayName(username)
            .SetPassword(password)
            .SetScriptData(classData)
            .Send(response =>
            {
                if (response.HasErrors)
                {
                    Debug.LogError(response.Errors.JSON);
                    dialogBox.GetComponent <RectTransform>().DOAnchorPosY(-100, 1);
                }
                else
                {
                    Debug.Log("Registered");
                    dialogBox.GetComponent <RectTransform>().DOAnchorPosY(-100, 1);
                    characterCreationScreen.SetActive(true);
                    userID = response.UserId;
                    SceneManager.LoadScene("Chamber");
                    musicPlayer.clip = inGameMusic;
                    musicPlayer.Play();
                }
            });
        }
    }
Exemplo n.º 14
0
    void playerdata()
    {
        new AuthenticationRequest()
        .SetPassword("0000")
        .SetUserName("26337")
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Login successfully");
            }
            else
            {
                Debug.Log("Error login");
            }
        });

        //Item item = new Item { name = "test1", cnt = 1 };
        //Item item2 = new Item { name = "test2", cnt = 3 };
        //StaticInfo.userData.items = item;
        //Debug.Log(StaticInfo.userData.items.name);
        //StaticInfo.userData.items.Add(item2);
        Debug.Log("Saving");
        PlayerData player = new PlayerData {
            gold = 2,
            rate = 0
        };
        string jsonData = JsonUtility.ToJson(player);

        GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData(jsonData);
        Debug.Log(jsonData);
        new LogEventRequest()
        .SetEventKey("SavePlayerData")
        .SetEventAttribute("playerData", data)
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Save data successfully");
            }
            else
            {
                Debug.Log("Error Save Player Data");
            }
        });

        new LogEventRequest()
        .SetEventKey("LoadPlayerData")
        .Send((response) => {
            if (!response.HasErrors)
            {
                GameSparks.Core.GSData scriptData = response.ScriptData.GetGSData("data");
                PlayerData playerData             = new PlayerData {
                    rate = (int)scriptData.GetInt("rate"),
                    gold = (int)scriptData.GetInt("gold")
                };
                Debug.Log("rate:" + playerData.rate + "gold:" + playerData.gold);
            }
            else
            {
                Debug.Log("Error Load Player Data");
            }
        });
    }
Exemplo n.º 15
0
    void inventory()
    {
        new AuthenticationRequest()
        .SetPassword("0000")
        .SetUserName("334870")
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Login successfully");
            }
            else
            {
                Debug.Log("Error login");
            }
        });

        Item item = new Item {
            name = "test1", cnt = 1
        };
        Item item2 = new Item {
            name = "test2", cnt = 3
        };

        //Debug.Log(StaticInfo.userData.items.name);
        StaticInfo.items.Add(item);
        StaticInfo.items.Add(item2);
        string jsonData = JsonUtility.ToJson(new Serialization <Item>(StaticInfo.items));

        //string jsonData = JsonUtility.ToJson(items);
        GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData(jsonData);
        Debug.Log(jsonData);
        new LogEventRequest()
        .SetEventKey("SaveInventory")
        .SetEventAttribute("inventory", data)
        .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Save inventory successfully");
            }
            else
            {
                Debug.Log("Error save inventory");
            }
        });

        new LogEventRequest()
        .SetEventKey("LoadInventory")
        .Send((response) => {
            if (!response.HasErrors)
            {
                GameSparks.Core.GSData scriptData = response.ScriptData.GetGSData("data");
                var temp = scriptData.GetGSDataList("target");

                List <Item> items = new List <Item>();
                for (int i = 0; i < temp.Count; i++)
                {
                    Item tempItem = new Item {
                        name = temp[i].GetString("name"),
                        cnt  = (int)temp[i].GetInt("cnt")
                    };
                    StaticInfo.items.Add(tempItem);
                }

                foreach (Item tempItem in StaticInfo.items)
                {
                    Debug.Log("name:" + tempItem.name + "cnt:" + tempItem.cnt);
                }
            }
            else
            {
                Debug.Log("Error Load Player Data");
            }
        });
    }
        /// <summary>
        /// User Login
        /// </summary>>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="eventName"></param>
        public static void Login(string username, string password, string eventName)
        {
            if (DataController.GetValue <string>("LastValidusername") != username)
            {
                if (DataController.GetValue <string>("LastValidusername") != "")
                {
                    Login(DataController.GetValue <string>("LastValidusername"), DataController.GetValue <string>("LastValidPassword"), null);
                }
            }

            DataController.SaveValue("username", username);

            StatsList = new List <long>();

            EquipmentList = new List <long>();

            OtherStuffList = new List <long>();

            StatsList = new List <long>();

            EquipmentList = new List <long>();

            PrimaryStuffList = new List <long>();

            if (DataController.GetValue <int>("Rating") >= 0)
            {
                var newRequest = new GameSparks.Api.Requests.LogEventRequest();// DataController.GetValue<int>("Rating"));

                newRequest.SetEventKey("RATING_UPDATE").SetEventAttribute("Rating", DataController.GetValue <int>("Rating")).Send(response =>
                {
                });
            }

            var newRequest1 = new GameSparks.Api.Requests.LeaderboardDataRequest();

            newRequest1.SetLeaderboardShortCode("LeaderboardRating").SetEntryCount(35).Send(response =>
            {
                Debug.Log(response.BaseData.JSON);

                LeaderBoardsScript.Ranks = new List <long?>();

                LeaderBoardsScript.Names = new List <string>();

                LeaderBoardsScript.Ratings = new List <long?>();

                foreach (var gd in response.BaseData.GetGSDataList("data"))
                {
                    LeaderBoardsScript.Ranks.Add(gd.GetLong("rank"));

                    LeaderBoardsScript.Names.Add(gd.GetString("userName"));

                    LeaderBoardsScript.Ratings.Add(gd.GetLong("Rating"));

                    //Debug.Log(gd.GetString("userName"));

                    //Debug.Log(gd.GetLong("Rating"));
                }
            });

            Debug.Log("Authentication...");
            var loginRequest = new AuthenticationRequest();


            GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData();
            if (DataController.GetValue <int>("GSNotSynced" + username) > 0 && DataController.GetValue <string>("LastValidusername") == username)
            {
                foreach (string attr in ServerNamz)
                {
                    Debug.Log(DataController.GetValue <int>(attr + "Mine"));
                    StatsList.Add((long)DataController.GetValue <int>(attr + "Mine"));
                }
                data.AddNumberList("Stats", StatsList);

                foreach (string TypeItem in Equipment.ForInvLoad)
                {
                    foreach (string Name in EquipmentNames)
                    {
                        EquipmentList.Add((long)DataController.GetValue <int>(Name + TypeItem + "ammount"));
                    }
                }
                data.AddNumberList("Equipment", EquipmentList);

                int tempNum = 0;

                foreach (int num in CelebrationAnimation.Prices)
                {
                    Debug.Log(num);

                    if (DataController.GetValue <int>("WinAnimNumberMine" + tempNum + "ammount") > 0)
                    {
                        OtherStuffList.Add(1);
                    }
                    else
                    {
                        OtherStuffList.Add(0);
                    }
                    tempNum += 1;
                }

                PrimaryStuffList.Add(DataController.GetValue <int>("Exp"));

                PrimaryStuffList.Add(DataController.GetValue <int>("Bread"));

                PrimaryStuffList.Add(DataController.GetValue <int>("SkillPoints"));

                PrimaryStuffList.Add(DataController.GetValue <int>("Rating"));

                Debug.Log(DataController.GetValue <int>("SkillPoints"));

                data.AddNumberList("OtherStuffList", OtherStuffList);

                data.AddNumberList("PrimaryStuffList", PrimaryStuffList);
            }

            loginRequest.SetUserName(username);
            loginRequest.SetPassword(password);
            loginRequest.SetScriptData(data);


            loginRequest.Send(response =>
            {
                if (!response.HasErrors)
                {
                    GameSparks.Core.GSData GSList = response.ScriptData;
                    foreach (string atributeName in ServerNamz)
                    {
                        DataController.SaveValue(atributeName + "Mine", (int)GSList.GetInt(atributeName));
                    }
                    foreach (string TypeItem in Equipment.ForInvLoad)
                    {
                        foreach (string Name in EquipmentNames)
                        {
                            if (GSList.GetGSData("BoughtOrNot").ContainsKey(Name + TypeItem))
                            {
                                if (GSList.GetGSData("BoughtOrNot").GetInt(Name + TypeItem) > 0)
                                {
                                    DataController.SaveValue(Name + TypeItem + "ammount", 1);
                                }
                                else
                                {
                                    DataController.SaveValue(Name + TypeItem + "ammount", 0);
                                }
                            }
                            else
                            {
                                DataController.SaveValue(Name + TypeItem + "ammount", 0);
                            }
                        }
                    }
                    foreach (var vg in GSList.GetGSDataList("VirtualGoodsList"))
                    {
                        foreach (string modifier in EqModifiers)
                        {
                            if (vg.GetGSData("currencyCosts").GetInt(modifier) != null)
                            {
                                DataController.SaveValue(vg.GetString("name") + modifier, (int)vg.GetGSData("currencyCosts").GetInt(modifier));
                                //Debug.Log(vg.GetString("name"));
                            }
                        }
                        //Debug.Log(vg.GetString("name"));
                        DataController.SaveValue(vg.GetString("name") + "Price", (int)vg.GetGSData("currencyCosts").GetInt("Bread"));
                        DataController.SaveValue(vg.GetString("name") + "SellPrice", (int)vg.GetGSData("currencyCosts").GetInt("BreadPrice"));
                    }

                    int tempNum = 0;
                    long?value  = GSList.GetLong("Anim" + tempNum);
                    while (value != null)
                    {
                        DataController.SaveValue("WinAnimNumberMine" + tempNum + "ammount", (int)value);
                        tempNum += 1;
                        value    = GSList.GetLong("Anim" + tempNum);
                    }

                    for (int i = tempNum; i < CelebrationAnimation.Prices.Count; i++)
                    {
                        DataController.SaveValue("WinAnimNumberMine" + i + "ammount", 0);
                    }

                    long?Exp = GSList.GetLong("TotalExp");
                    DataController.SaveValue("Exp", (int)Exp);

                    long?Bread = GSList.GetLong("TotalBread");
                    DataController.SaveValue("Bread", (int)Bread);

                    long?SkillPoints = GSList.GetLong("TotalSkillPoints");
                    DataController.SaveValue("SkillPoints", (int)SkillPoints);

                    long?Rating = GSList.GetLong("Rating");
                    DataController.SaveValue("Rating", (int)Rating);

                    Debug.Log(DataController.GetValue <int>("SkillPoints"));


                    DataController.SaveValue("GSNotSynced" + username, 0);
                    Debug.Log("Player authenticated! \n Name:" + response.DisplayName + response.ScriptData.JSON);// + response.ScriptData);//.ScriptData.JSON.ToString());


                    IsUserLoggedIn = false;

                    EventManager.TriggerEvent(eventName, response.DisplayName);

                    DataController.SaveValue("LastValidPassword" + username, password);

                    DataController.SaveValue("LastValidusername", username);
                }
                else
                {
                    ResetPassword.instance.Warning.SetActive(true);

                    PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.Login); }, LocalisationSystem.GetLocalisedValue("loginerror1"));

                    Debug.Log("Error authenticating player.../n" + response.Errors.JSON.ToString());

                    EventManager.TriggerEvent(eventName, "");
                }
            });
        }
Exemplo n.º 17
0
        public void GetToken()
        {
            DataController.SaveValue("username", username.text);

            var loginRequest = new AuthenticationRequest();

            GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData();

            data.AddString("action", "passwordRecoveryRequest");

            data.AddString("email", email.text);

            loginRequest.SetScriptData(data);

            loginRequest.SetUserName(DataController.GetValue <string>("username"));

            loginRequest.SetPassword("");

            loginRequest.Send(response => {
                if (!response.HasErrors)
                {
                    Warning.SetActive(true);

                    Warning.GetComponentsInChildren <Button>()[1].gameObject.SetActive(false);

                    PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.ConfirmResetPassword); }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning1"));
                }
                else
                {
                    Debug.Log("Error authenticating player.../n" + response.Errors.JSON.ToString());

                    Debug.Log(response.Errors.GetString("action"));

                    if (response.Errors.ContainsKey("action"))
                    {
                        Warning.SetActive(true);

                        //Warning.GetComponentsInChildren<Button>()[1].gameObject.SetActive(false);

                        if (response.Errors.GetString("action").Contains("complete"))
                        {
                            Debug.Log("warn1");

                            UIController.SetActivePanel(UI_Element.ConfirmResetPassword);

                            PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.ConfirmResetPassword); }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning1"));
                        }
                        else if (response.Errors.GetString("action").Contains("email") || response.Errors.GetString("action").Contains("invalid"))
                        {
                            Debug.Log("warn2");

                            PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.ResetPassword); }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning2"));
                        }
                        else
                        {
                            Debug.Log("exception");
                        }
                    }
                }
            });
        }
Exemplo n.º 18
0
        /// <summary>
        /// Set the script-data which will be sent to the backend in addition to the data-fields defined by the request itself.
        /// </summary>
        public IN SetScriptData(GSRequestData data)
        {
            request.AddObject("scriptData", data);

            return((IN)this);
        }