Beispiel #1
0
        private IEnumerator SignUpCoroutine(Credentials credentials)
        {
            //string json = JsonUtility.ToJson(credentials);
            string json = string.Concat("{ \"username\" : \"", credentials.username, "\",\"password\" : \"", credentials.password, "\",\"country\" : \"", System.Globalization.RegionInfo.CurrentRegion, "\" }");

            string url = "https://isartdigitalf2pscrawl.herokuapp.com/users/signup";

            using (UnityWebRequest req = PostJson(url, json))
            {
                yield return(req.SendWebRequest());

                if (req.isNetworkError || req.isHttpError)
                {
                    Debug.LogWarning(string.Concat("[ServerManager] Cannot access to server or database at Sign Up, reason : ", req.downloadHandler.text));
                    Screens.Login.Instance.LoginFailed(req.downloadHandler.text);
                }
                else
                {
                    Credentials receivedCreds = JsonUtility.FromJson <Credentials>(req.downloadHandler.text);
                    credentials.token = Token = receivedCreds.token;
                    credentials.id    = receivedCreds.id;

                    OnLoginSuccess?.Invoke(credentials);
                    //PlayerDatas playerDatas = new PlayerDatas();
                    //OnGettingDatasSuccess?.Invoke(playerDatas);
                    //LastPubDate date = new LastPubDate(credentials.id, System.DateTime.Now);
                    OnStartFTUE?.Invoke();
                    //SaveLastPubDate(date);
                    //AdsManager.Instance.GetLastPubDate(date);
                    //SavePlayerDatas(playerDatas);
                }
            }
        }
Beispiel #2
0
        private IEnumerator GetPlayerDatas()
        {
            string url = "https://isartdigitalf2pscrawl.herokuapp.com/playerdatas/get";

            using (UnityWebRequest req = UnityWebRequest.Get(url))
            {
                req.SetRequestHeader("Authorization", "Bearer " + Token);

                yield return(req.SendWebRequest());

                if (req.isNetworkError || req.isHttpError)
                {
                    Debug.LogWarning(string.Concat("[ServerManager] Cannot get playerDatas, reason : ", req.downloadHandler.text));
                    OnStartFTUE?.Invoke();
                }
                else
                {
                    PlayerDatas receivedPlayerDatas = JsonUtility.FromJson <PlayerDatas>(req.downloadHandler.text);
                    if (receivedPlayerDatas.worlds.Count == 0 || receivedPlayerDatas.squads.Count == 0)
                    {
                        OnStartFTUE?.Invoke();
                    }
                    else
                    {
                        OnGettingDatasSuccess?.Invoke(receivedPlayerDatas);
                        GetLastPubDate(GameManager.Credentials.id);
                    }

                    /*receivedPlayerDatas.softCurrency = 100;
                     * receivedPlayerDatas.noAds = true;
                     *
                     * if (receivedPlayerDatas.worlds.Count == 0 || receivedPlayerDatas.squads.Count == 0)
                     * {
                     *      receivedPlayerDatas.AfterTutosGift(GameManager.Credentials.id);
                     * }*/

                    //StartCoroutine(SavePlayerDatasCoroutine(receivedPlayerDatas));
                }
            }
        }