Ejemplo n.º 1
0
        public static void UpdateUser(SessionResult result, string token)
        {
            panelStack.Clear();

            TacoUser user = new TacoUser {
                email         = result.user.email,            //.email,
                userId        = result.user.id,
                funds         = result.user.funds,
                token         = token,
                gToken        = result.gToken,
                highScoreUser = result.highScoreUser,
                ticket        = result.ticket,
                //avatar = result.avatar,
            };

            User = user;
            PlayerPrefs.SetInt("highscoretype", 0);
            PlayerPrefs.SetFloat("highscoreArcade", result.highScoreUser);

            UpdateAvatar(result.user.userName, result.user.funds, result.gToken);

            GameId        = result.game.id;
            GameName      = result.game.name;
            currentUserId = result.user.id;

            Setup();
            CloseMessage();
        }
Ejemplo n.º 2
0
        public void GetSession(string token)
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            TacoConfig.print("Attempting auto login with token = " + token);

            Action <string> success = (string data) => {
                TacoConfig.print("data= " + data);
                SessionResult r = JsonUtility.FromJson <SessionResult>(data);
                if (r.success)
                {
                    TacoConfig.print("Success = " + r);

                    TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                    TacoManager.UpdateUser(r, token);
                    if (r.msg == "in")
                    {
                        TacoManager.OpenModal("Login success", "Welcome back to game taco! ");
                    }
                    else
                    {
                        TacoManager.OpenModal("Login success", "You get " + r.value + " taco token for login today! ");
                    }
                }
                else
                {
                    //TacoConfig.print("Error = " + r.message );

                    TacoManager.CloseMessage();

                    TacoManager.SetPreferenceString(UserPreferences.userToken, null);
                    TacoManager.SetPreference(UserPreferences.autoLogin, 0);
                    TacoManager.ShowPanel(PanelNames.LoginPanel);

                    if (!string.IsNullOrEmpty(r.message))
                    {
                        TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, r.message);
                    }
                }
            };

            Action <string, string> fail = (string data, string error) => {
                TacoConfig.print("Error on Login : "******"Error : " + error);
                }

                TacoManager.CloseMessage();

                string msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);

                // TODO : have the message 'Cannot Reach Destination Host' - read 'No Internet Connection'  -- something more clear?
                TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01 + "\n\n" + msg);
            };
            string url = "api/session/detail/" + TacoConfig.SiteId;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
Ejemplo n.º 3
0
        public void GetSession(string token)
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            TacoConfig.print("Attempting auto login with token = " + token);

            Action <string> success = (string data) => {
                TacoConfig.print("data= " + data);
                SessionResult r = JsonUtility.FromJson <SessionResult>(data);
                if (r.success)
                {
                    TacoConfig.print("Success = " + r);

                    TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                    TacoManager.UpdateUser(r, token);
                }
                else
                {
                    //TacoConfig.print("Error = " + r.message );

                    TacoManager.CloseMessage();
                    TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01);
                }
            };

            Action <string, string> fail = (string data, string error) => {
                TacoConfig.print("Error on Login : "******"Error : " + error);
                }

                TacoManager.CloseMessage();

                string msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);

                // TODO : have the message 'Cannot Reach Destination Host' - read 'No Internet Connection'  -- something more clear?
                TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01 + "\n\n" + msg);
            };

            string url = "api/session/detail/" + TacoConfig.SiteId;

            this.Get(url, success, fail);
        }
Ejemplo n.º 4
0
        public void GetSession(string token)
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            Action <string> success = (string data) => {
                SessionResult r = JsonUtility.FromJson <SessionResult> (data);
                if (r.success)
                {
                    Debug.Log("session: " + data);
                    BalanceManager.Instance.SetRemainingValue(r.remainingClaim, r.login_count);
                    TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                    TacoManager.UpdateUser(r, token);
                    if (r.msg == "in")
                    {
                        //Debug.LogWarning("No longer implemented");
                    }
                    else
                    {
                        TacoManager.OpenModalDailyTokenPanel(r.value);
                    }
                }
                else
                {
                    TacoManager.CloseMessage();
                    TacoManager.SetPreferenceString(UserPreferences.userToken, null);
                    TacoManager.SetPreference(UserPreferences.autoLogin, 0);
                    TacoManager.ShowPanel(PanelNames.LoginPanel);

                    if (!string.IsNullOrEmpty(r.message))
                    {
                        TacoManager.OpenModalLoginFailedPanel(r.message);
                    }
                }
            };

            Action <string, string> fail = (string data, string error) => {
                if (!string.IsNullOrEmpty(data))
                {
                    try {
                        SystemError r = JsonUtility.FromJson <SystemError> (data);
                        if (r.verErr)
                        {
                            //version error
                            TacoManager.OpenModalIncorrectVersionPanel(r.message);
                        }
                        else
                        {
                            string msg = r.message;
                            if (string.IsNullOrEmpty(msg))
                            {
                                msg = TacoConfig.TacoLoginErrorEmailPassword;
                            }
                            TacoManager.OpenModalLoginFailedPanel(msg);
                        }
                    } catch (Exception) {
                        TacoManager.OpenModalLoginFailedPanel(TacoConfig.Error);
                    }
                }
                else
                {
                    TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword);
                }
                TacoManager.CloseMessage();
            };
            string url = "api/session/detail/" + TacoSetup.Instance.SiteId;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }