Example #1
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));
        }
Example #2
0
        public void Login()
        {
            var email    = EmailInput.GetComponent <InputField> ().text;
            var password = PasswordInput.GetComponent <InputField> ().text;
            // toggle returns a bool
            bool autoLoginBool = AutoLoginToggle.GetComponent <Toggle> ().isOn;

            // Unity doesn't allow Bool as a preference type, using int
            int autoLoginInt = 0;

            if (autoLoginBool)
            {
                autoLoginInt = 1;
            }

            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            //TODO: Verify valid email syntax
            if (email == string.Empty || password == string.Empty)
            {
                TacoManager.CloseMessage();
                TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorMessage00);
            }
            else
            {
                Action <string> success = (string data) => {
                    LoginResult r = JsonUtility.FromJson <LoginResult> (data);
                    if (r.success)
                    {
                        Debug.Log("login login_count " + r.login_count);
                        BalanceManager.Instance.SetRemainingValue(r.remainingClaim, r.login_count);
                        TacoManager.SetPreference(UserPreferences.autoLogin, autoLoginInt);
                        TacoManager.SetPreferenceString(UserPreferences.userToken, r.token);

                        TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                        TacoManager.CreateUser(r);

                        if (r.msg == "in")
                        {
                            if (r.free == "free")
                            {
                                //Debug.LogError("No longer implemented");
                                //TacoManager.OpenModal("Login success", "Welcome back to game taco! You get " + r.score_tokens + " taco token from free play!");
                            }
                            else
                            {
                                if (r.free == "enough")
                                {
                                    Debug.LogError("No longer implemented");
                                    //TacoManager.OpenModal("Login success", "Welcome back to game taco! You've got too many taco tokens today! Please try again tomorrow.");
                                }
                                else
                                {
                                    TacoManager.OpenHowToPlayPanel();
                                }
                            }
                        }
                        else
                        {
                            if (r.free == "free")
                            {
                                Debug.LogError("No longer implemented");
                                //TacoManager.OpenModal("Login success", "You get " + r.value + " taco token for login today! And " + r.score_tokens + " taco token from free play!");
                            }
                            else
                            {
                                if (!TacoManager.GetPanel("SuccessRegister").activeSelf)
                                {
                                    TacoManager.OpenModalDailyTokenPanel(r.value);
                                }
                                else
                                {
                                    TacoManager.OpenModalRegisterPanel(TacoManager.User.name);
                                }
                            }
                        }
                        //ApiManager.Instance.OpenConnection();
                        //ApiManager.Instance.SendData(r.userName + string.Empty);
                        Init();
                    }
                    else
                    {
                        TacoManager.CloseMessage();
                        TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword);
                    }
                };

                Action <string, string> fail = (string data, string error) => {
                    if (!string.IsNullOrEmpty(data))
                    {
                        SystemError r = JsonUtility.FromJson <SystemError> (data);
                        if (r.verErr)
                        {
                            //version error
                            TacoManager.CloseMessage();
                            TacoManager.OpenModalIncorrectVersionPanel(r.message);
                        }
                        else
                        {
                            TacoManager.CloseMessage();
                            string msg = r.message;
                            if (string.IsNullOrEmpty(msg))
                            {
                                msg = TacoConfig.TacoLoginErrorEmailPassword;
                            }
                            TacoManager.OpenModalLoginFailedPanel(msg);
                        }
                    }
                    else
                    {
                        TacoManager.CloseMessage();
                        TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword);
                    }

                    if (!string.IsNullOrEmpty(error))
                    {
                        Debug.Log("Error : " + error);
                    }
                };

                StartCoroutine(ApiManager.Instance.Login(email, password, success, fail));
            }
        }
Example #3
0
        public void Login()
        {
            var email    = EmailInput.GetComponent <InputField>().text;
            var password = PasswordInput.GetComponent <InputField>().text;

            TacoConfig.print("Login : email =  " + email);

            // toggle returns a bool
            bool autoLoginBool = AutoLoginToggle.GetComponent <Toggle>().isOn;

            // API wants a string for the form post
            string autoLoginString = autoLoginBool.ToString();

            // Unity doesn't allow Bool as a preference type, using int
            int autoLoginInt = 0;

            if (autoLoginBool == true)
            {
                autoLoginInt = 1;
            }

            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            //TODO: Verify valid email syntax
            if (email == string.Empty || password == string.Empty)
            {
                TacoManager.CloseMessage();
                TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage00);
            }
            else
            {
                Action <string> success = (string data) => {
                    LoginResult r = JsonUtility.FromJson <LoginResult>(data);
                    if (r.success)
                    {
                        TacoManager.SetPreference(UserPreferences.autoLogin, autoLoginInt);
                        TacoManager.SetPreferenceString(UserPreferences.userToken, r.token);

                        TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                        TacoManager.CreateUser(r);
                        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! ");
                        }

                        // clean up the login panel
                        Init();
                    }
                    else
                    {
                        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);
                    TacoConfig.print("login msg : " + msg);

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

                TacoConfig.print("Login calling API");
                //SecureApiManager.Instance.Login(email, password, success, fail);
                StartCoroutine(ApiManager.Instance.Login(email, password, success, fail));
                //StartCoroutine(postLogin(email, password));
            }
        }
Example #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));
        }
        //TODO put these strings in TacoModels
        public void ModalClicked()
        {
            if (ModalButtonEnabled)
            {
                if (Callback != null)
                {
                    switch (Callback)
                    {
                    case ModalFunctions.ReturnToGame:

                        TacoManager.CloseTaco();

                        break;


                    case ModalFunctions.TournamentGamePosted:

                        // They finished the game, after modal closed - show past tournaments
                        TacoManager.ShowPanel(PanelNames.MyPrivatePanel);

                        break;

                    case ModalFunctions.RegisterResult:

                        // when they close the modal, show login
                        TacoManager.ShowPanel(PanelNames.LoginPanel);

                        break;

                    case ModalFunctions.TournamentSubmit:

                        TournamentManager.Instance.TournamentSubmit();

                        break;

                    case ModalFunctions.TournamentSubmitComplete:

                        // close the creation panel - remove from stack
                        TacoManager.ClosePanel();

                        // refresh and show the current tournaments
                        TacoManager.ShowPanel(PanelNames.MyTournamentsPanel);

                        break;

                    case ModalFunctions.LogoutUser:


                        TacoManager.LogoutUser();


                        break;

                    case ModalFunctions.JoinTournament:


                        TournamentManager.Instance.Join();


                        break;

                    case ModalFunctions.InviteFriends:


                        TournamentManager.Instance.InviteFriend();

                        break;

                    case ModalFunctions.InviteFriendsFromCreate:


                        TournamentManager.Instance.InviteFriendsFromCreate();

                        break;

                    case ModalFunctions.JoinPublicSuccess:

                        // close the join panel - remove from stack
                        TacoManager.ClosePanel();

                        // refresh and show the current tournaments
                        TacoManager.ShowPanel(PanelNames.MyTournamentsPanel);


                        break;

                    case ModalFunctions.StartPlay:
                        GameManager.Instance.StartPlay(TacoManager.Target);
                        break;

                    case ModalFunctions.SawIntro:

                        TacoManager.SetPreference(UserPreferences.sawIntro, 1);
                        TacoManager.ShowPanel(PanelNames.LoginPanel);
                        break;

                    case ModalFunctions.ForfeitTournamentGame:


                        //TacoManager.Instance.ForfeitTournamentGame();


                        break;


                    case ModalFunctions.ReturnToTournaments:


                        // refresh and show the current tournaments
                        TacoManager.ShowPanel(PanelNames.MyTournamentsPanel);


                        break;

                    case ModalFunctions.ReturnToMenu:

                        TacoSetup.Instance.ReturnMenu();
                        break;

                    case ModalFunctions.TacoEndTournament: {
                        TacoSetup.Instance.TacoEndTournament();
                        break;
                    }

                    case ModalFunctions.TacoFreePlayGiftToken: {
                        TacoSetup.Instance.TacoSigninWithTokenFree();
                        break;
                    }
                    }
                }

                TacoConfig.print("DismissModals");

                DismissModal();
            }
        }