Пример #1
0
        public void getPrivateUserTournaments(Func <Tournament, bool> filterCondition = null)
        {
            TacoManager.OpenMessage(TacoConfig.TacoRefreshing);
            int             cate    = (int)TacoSetup.Instance.TournamentCategory;
            Action <string> success = (string data) => {
                List <Tournament> publicList = new List <Tournament> ();

                PrivateTournamentsResult r = JsonUtility.FromJson <PrivateTournamentsResult> (data);
                foreach (Tournament item in r.tournaments)
                {
                    if (item.typeCurrency == cate && (!item.played || item.playable) && item.status != "ended")
                    {
                        publicList.Add(item);
                    }
                }
                if (filterCondition != null)
                {
                    publicList = publicList.Where(filterCondition).ToList();
                }
                publicList = publicList.OrderBy(x => PrivateTournamentsList.Instance.GetDisplayedStatus(x)).ToList();
                PrivateTournamentsList.Instance.Reload(publicList);

                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                Debug.Log("Error getting open tournaments : " + data);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }
            };

            StartCoroutine(ApiManager.Instance.GetWithToken("api/tournament/private/" + TacoSetup.Instance.SiteId, success, fail));
        }
Пример #2
0
        public void RemoveFriend(string email, Action callback)
        {
            TacoManager.OpenMessage(TacoConfig.TacoSending);

            Action <string> success = (string data) => {
                TacoManager.CloseMessage();
                TacoManager.OpenModalRemovePlayerNoticePanel();
                callback();
            };

            Action <string, string> fail = (string data, string error) => {
                Debug.Log("Error getting open tournaments : " + data);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }
            };

            Tournament t        = ManageTournament.Instance.tournament;
            int        friendId = 0;

            for (int i = 0; i < t.friendEmails.Length; i++)
            {
                if (t.friendEmails [i] == email)
                {
                    friendId = t.friendIds [i];
                    break;
                }
            }

            int tournamentId = t.id;

            StartCoroutine(ApiManager.Instance.RemoveFriend(email, friendId, tournamentId, success, fail));
        }
Пример #3
0
        public void InviteFriend(string email, Action callback = null)
        {
            TacoManager.OpenMessage(TacoConfig.TacoSending);
            Action <string> success = (string data) => {
                if (callback != null)
                {
                    callback();
                }
                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                Debug.Log("Error getting open tournaments : " + data);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }
            };

            string fromEmail = TacoManager.User.email;
            string baseUrl   = "baysidegames.com";

            int tournamentId = TacoManager.Target.id;

            StartCoroutine(ApiManager.Instance.InviteFriend(fromEmail, baseUrl, email, tournamentId, success, fail));
        }
Пример #4
0
 private void AddAddressesEvent()
 {
     SubmitAddessesBtn.onClick.AddListener(() => {
         if (!string.IsNullOrEmpty(addressInput.text + address2Input.text + cityInput.text + stateInput.text + zipcodeInput.text))
         {
             TacoManager.OpenMessage(TacoConfig.Processing);
             Action <string> success = (string data) => {
                 TacoManager.CloseMessage();
                 GeneralResult r = JsonUtility.FromJson <GeneralResult>(data);
                 string notice   = string.Empty;
                 string header   = string.Empty;
                 if (r.success)
                 {
                     notice = r.msg;
                     header = TacoConfig.SuccessHeader;
                     TacoManager.User.contactProfile.UpdateData(addressInput.text, address2Input.text, cityInput.text, stateInput.text, zipcodeInput.text);
                     FillFullAddress();
                 }
                 else
                 {
                     notice = r.err;
                     header = TacoConfig.ErrorHeader;
                     FillAddressesField();
                 }
                 TacoManager.OpenModalGeneralResultPanel(r.success, header, notice);
             };
             Action <string, string> fail = (string data, string error) => {
                 TacoManager.CloseMessage();
                 GeneralResult r = JsonUtility.FromJson <GeneralResult>(data);
                 TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.ErrorHeader, r.err);
             };
             StartCoroutine(ApiManager.Instance.ChangeAddress(addressInput.text, address2Input.text, cityInput.text, stateInput.text, zipcodeInput.text, success, fail));
         }
     });
 }
Пример #5
0
        public void GetOurGames()
        {
            TacoManager.OpenMessage(TacoConfig.TacoOurGamesLoadingMessage);
            foreach (Transform child in gamesList)
            {
                Destroy(child.gameObject);
            }
            ourGamesList     = new List <OurGame> ();
            buttons [0].isOn = true;            //set default to all toggle

            Action <string> success = (string data) => {
                GameFeaturedResult r = JsonUtility.FromJson <GameFeaturedResult> (data);
                if (r.success)
                {
                    TacoManager.CloseMessage();
                    UpdateGames(r.games);
                }
            };

            Action <string, string> fail = (string errorData, string error) => {
                Debug.Log("Error on get : " + errorData);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }

                TacoManager.CloseMessage();

                TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword);
            };

            string url = "api/game/featured?userAgent=" + platform;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
Пример #6
0
        private void GetTransaction()
        {
            isLoadingTransaction = true;
            TacoManager.OpenMessage(TacoConfig.Processing);
            Action <string> success = (string data) => {
                Debug.Log(data);
                isLoadingTransaction = false;
                if (!isLoadingActiveTours)
                {
                    TacoManager.CloseMessage();
                }
                TransactionResult r = JsonUtility.FromJson <TransactionResult>(data);
                if (r.transactions.Length > 0)
                {
                    UserTransaction recent = r.transactions[0];
                    recentTransaction.text = string.Format("{0} ({1})", recent.action, recent.FormatCurrency);
                }
                transactions = r.transactions;
                GenerateTransactionTable();
            };
            Action <string, string> fail = (string data, string error) => {
                isLoadingTransaction = false;
                if (!isLoadingActiveTours)
                {
                    TacoManager.CloseMessage();
                }
                TacoManager.OpenModalConnectionErrorPanel(error);
                recentTransaction.text = string.Empty;
            };

            StartCoroutine(ApiManager.Instance.GetTransactions(3, success, fail));
        }
Пример #7
0
        public void LoginWithGoogle()
        {
            TacoManager.LoginPanelObject.SetActive(true);//if from register panel
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);
            Debug.Log("internet: " + Application.internetReachability);
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                TacoManager.CloseMessage();
                TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginStatusNoInternet);
                return;
            }

            Action <string> onSuccess = (string data) => {
                TacoManager.CloseMessage();
                GoogleDeviceInfo r = JsonUtility.FromJson <GoogleDeviceInfo> (data);
                CodeDisplayPanel.SetActive(true);
                CodeDisplayPanel.transform.Find("Main/Code").GetComponent <InputField> ().text = r.user_code;
                deviceInfo = r;
                //testing
                TextEditor te = new TextEditor();
                te.text = deviceInfo.user_code;
                te.SelectAll();
                te.Copy();
            };

            Action <string, string> onFail = (string data, string error) => {
                TacoManager.CloseMessage();
                TacoManager.OpenModalLoginFailedPanel(error);
            };

            StartCoroutine(ApiManager.Instance.RequestDeviceAdnUserCode(authorizationDeviceEndpoint, clientID, onSuccess, onFail));
        }
Пример #8
0
        private void SendClaimToken()
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);
            Action <string> onSuccess = (string data) => {
                ClaimInfo r = JsonUtility.FromJson <ClaimInfo>(data);
                if (r.success)
                {
                    TacoManager.OpenClaimTokenPanel(TacoConfig.ClaimSuccessHeader, tokenClaim.text, TacoConfig.ClaimSuccessNotice);
                    TacoManager.User.gToken = r.newTacoToken.ToString();
                    UpdateUI(r);
                    TournamentManager.Instance.SetMoneytext();
                }
                else
                {
                    TacoManager.OpenClaimTokenPanel(TacoConfig.ClaimFailHeader, "0", TacoConfig.NoTokenNotice);
                    UpdateUI(r);
                }
                TacoManager.CloseMessage();
            };
            Action <string, string> onFail = (string data, string error) => {
                TacoManager.OpenClaimTokenPanel(TacoConfig.ClaimFailHeader, "0", TacoConfig.ClaimErrorNotice);
                TacoManager.CloseMessage();
            };

            StartCoroutine(ApiManager.Instance.ClaimToken(onSuccess, onFail));
        }
Пример #9
0
        public void ValidateUserOrEmail(string emailToCheck)
        {
            EmailOkay.SetActive(false);

            Action <string> success = (string data) => {
                GameFeaturedResult r = JsonUtility.FromJson <GameFeaturedResult> (data);
                if (r.success)
                {
                    if (data.Contains("true"))
                    {
                        EmailOkay.SetActive(true);
                    }
                }
                ;
            };

            Action <string, string> fail = (string errorData, string error) => {
                Debug.Log("Error on get : " + errorData);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }

                TacoManager.CloseMessage();
                TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword);
            };

            string url = "api/user/verify?u=" + emailToCheck;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
Пример #10
0
        public void InviteFriend()
        {
            TacoManager.OpenMessage(TacoConfig.TacoSending);

            Action <string> success = (string data) => {
                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                TacoConfig.print("Error getting open tournaments : " + data);
                if (!string.IsNullOrEmpty(error))
                {
                    TacoConfig.print("Error : " + error);
                }
            };


            string fromEmail = TacoManager.User.email;
            string baseUrl   = "baysidegames.com";

            GameObject invitePreFab = TacoModalPanel.Instance.GetPreFab();

            TournamentInvite _TournamentInvite = invitePreFab.GetComponent <TournamentInvite>();

            string emails       = _TournamentInvite.GetEmail();
            int    tournamentId = TacoManager.Target.id;

            TacoConfig.print("emails : " + emails);

            StartCoroutine(ApiManager.Instance.InviteFriend(fromEmail, baseUrl, emails, tournamentId, success, fail));
        }
Пример #11
0
        private void SubmitPurchaseToken()
        {
            TacoManager.OpenMessage(TacoConfig.Processing);
            Action <string> success = (string data) => {
                TacoManager.CloseMessage();
                GeneralResult r = JsonUtility.FromJson <GeneralResult>(data);
                string        notice;
                string        header;
                if (r.success)
                {
                    TacoManager.UpdateFundsWithToken(r.cash, r.token.ToString(), r.ticket.ToString());
                    moneyValue.text = TacoManager.FormatGTokens(double.Parse(TacoManager.User.gToken));
                    TournamentManager.Instance.SetMoneytext();
                    header = TacoConfig.SuccessHeader;
                    notice = r.msg;
                }
                else
                {
                    header = TacoConfig.ErrorHeader;
                    notice = r.err;
                }

                TacoManager.OpenModalGeneralResultPanel(r.success, header, notice);
            };
            Action <string, string> fail = (string data, string error) => {
                TacoManager.CloseMessage();
                TacoManager.OpenModalConnectionErrorPanel(error);
            };
            string currency = exchangedCurrencyIcon.sprite == TacoConfig.currencySprites[0] ? "0" : "2";

            StartCoroutine(ApiManager.Instance.BuyToken(currency, exchangedNumber, success, fail));
        }
Пример #12
0
        public void getCompletedTournaments(Func <Tournament, bool> filterCondition = null)
        {
            TacoManager.OpenMessage(TacoConfig.TacoRefreshing);
            int             cate    = (int)TacoSetup.Instance.TournamentCategory;
            Action <string> success = (string data) => {
                List <Tournament>          publicList = new List <Tournament> ();
                CompletedTournamentsResult r          = JsonUtility.FromJson <CompletedTournamentsResult> (data);

                foreach (var item in r.tournaments)
                {
                    if (item.typeCurrency == cate)
                    {
                        publicList.Add(item);
                    }
                }

                if (filterCondition != null)
                {
                    publicList = publicList.Where(filterCondition).ToList();
                }
                CompletedTournamentsList.Instance.Reload(publicList);

                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }
            };

            StartCoroutine(ApiManager.Instance.GetWithToken("api/tournament/history/" + TacoSetup.Instance.SiteId + "/" + TacoManager.User.userId, success, fail));
        }
Пример #13
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));
        }
Пример #14
0
        public void PostScore(int score, Tournament target)
        {
            if (target != null && TacoManager.UserLoggedIn())
            {
                Action <string> success = (string data) => {
                    ScoreResult r         = JsonUtility.FromJson <ScoreResult>(data);
                    string      modalBody = TacoConfig.TacoPlayEndedModalBody;
                    string      modal     = TacoConfig.TacoPlayEndedWinnerModalBody;
                    modalBody = modalBody.Replace("&gameEndScore", r.score.ToString());
                    if (r.tournament.typeCurrency == 0)
                    {
                        modal = modal.Replace("&prize", " $ " + Math.Round((Decimal)r.tournament.prize, 2, MidpointRounding.AwayFromZero));
                        modal = modal.Replace("&point", "P " + (int)Math.Round(r.tournament.prize * 50, 0, MidpointRounding.AwayFromZero) + " and ");
                    }
                    else
                    {
                        modal = modal.Replace("&point", string.Empty);
                        modal = modal.Replace("&prize", " T " + r.tournament.prize);
                    }

                    if (r.winner)
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.SetToMainMenu();
                        TacoManager.ShowPanel(PanelNames.MyLeaderboardPanelFromEndGame);
                    }
                    else
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.SetToMainMenu();
                        TacoManager.ShowPanel(PanelNames.MyLeaderboardPanelFromEndGame);
                    }
                    TacoManager.GameToken = null;
                    if (r.updated)
                    {
                        TacoManager.UpdateFundsWithToken(r.funds, r.gTokens.ToString(), r.ticket.ToString());
                    }
                };

                Action <string, string> fail = (string data, string error) => {
                    if (Application.internetReachability == NetworkReachability.NotReachable)
                    {
                        TacoManager.CloseMessage();
                        TacoManager.OpenModalConnectionErrorPanel(TacoConfig.ErrorStatusNoInternet);
                    }
                    else
                    {
                        var r = JsonUtility.FromJson <StartGameResult>(data);
                        TacoManager.CloseAllModals();
                        TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.TacoPlayError, r.message);
                    }
                    TacoManager.GameToken = null;
                };

                StartCoroutine(ApiManager.Instance.EndGame(score, target.id, target.gameId, TacoManager.GameToken, TacoManager.User.token, success, fail));
            }
        }
Пример #15
0
 private void GetActiveTournament()
 {
     isLoadingActiveTours = true;
     TournamentManager.Instance.getActiveTournaments((bool success) => {
         isLoadingActiveTours = false;
         if (!isLoadingTransaction)
         {
             TacoManager.CloseMessage();
         }
         toggleActiveTournaments(success);
     });
 }
Пример #16
0
        public void LoginWithFacebook()
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            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.LoginWithFacebook(success, fail));
            //StartCoroutine(postLogin(email, password));
        }
Пример #17
0
        public void LoginWithFacebook()
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                TacoManager.CloseMessage();
                TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginStatusNoInternet);
                //TacoManager.OpenModal (TacoConfig.TacoLoginErrorHeader, "Please connect internet before login.");
                return;
            }
#if UNITY_IOS || UNITY_ANDROID
            //FB.LogInWithReadPermissions(new List<string>() { "public_profile", "email", "user_friends" }, AuthCallback);
#endif
        }
Пример #18
0
        public void TournamentSubmitResult(string results)
        {
            // clear invites
            invitedFriends.Clear();

            // turn back on create button
            Button createButton = CreateTournamentButton.GetComponent <Button>();

            createButton.interactable = true;

            TacoManager.CloseMessage();
            // open modal but don't let it be closed, they have to hit okay

            TacoManager.OpenModal("", results, null, ModalFunctions.TournamentSubmitComplete, null, null, false);
        }
Пример #19
0
        private void SubmitRedeemForm()
        {
            TacoManager.OpenMessage(TacoConfig.Processing);
            Action <string> success = (string data) => {
                TacoManager.CloseMessage();
                GeneralResult r = JsonUtility.FromJson <GeneralResult>(data);
                string        notice;
                string        header;
                if (r.success)
                {
                    notice                = r.msg;
                    header                = TacoConfig.SuccessHeader;
                    emailInput.text       = string.Empty;
                    dateOfBirthInput.text = string.Empty;
                    streetInput.text      = string.Empty;
                    buildingInput.text    = string.Empty;
                    countryInput.text     = string.Empty;
                    stateInput.text       = string.Empty;
                    postcodeInput.text    = string.Empty;
                    cityInput.text        = string.Empty;
                    TacoManager.UpdateTicketOnly(r.ticket.ToString());
                    TournamentManager.Instance.SetMoneytext();
                    moneyValue.text = TacoManager.FormatRP(TacoManager.User.ticket);
                }
                else
                {
                    notice = r.err;
                    header = TacoConfig.ErrorHeader;
                }
                TacoManager.OpenModalGeneralResultPanel(r.success, header, notice);
            };
            Action <string, string> fail = (string data, string error) => {
                TacoManager.CloseMessage();
                GeneralResult r = JsonUtility.FromJson <GeneralResult>(data);
                TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.ErrorHeader, r.err);
            };

            StartCoroutine(ApiManager.Instance.SubmitRedeemInfo(purchasingPrize,
                                                                emailInput.text,
                                                                dateOfBirthInput.text,
                                                                streetInput.text,
                                                                buildingInput.text,
                                                                countryInput.text,
                                                                stateInput.text,
                                                                postcodeInput.text,
                                                                cityInput.text,
                                                                success, fail));
        }
Пример #20
0
        public void convertFundsToGTokens(int fee)
        {
            AddGTokensText.GetComponent <Text>().text             = TacoConfig.AddGTokensAdding;
            AddGTokensButton.GetComponent <Button>().interactable = false;

            Action <string> success = (string data) => {
                TacoConfig.print("Purchase GTokens complete - " + data);
                var r = JsonUtility.FromJson <AddGTokesResult>(data);
                if (r.success)
                {
                    TacoManager.UpdateFundsWithToken(r.funds, r.gTokens);
                    string returnMessage = TacoConfig.AddFundsSuccessMessage + TacoManager.FormatGTokens(double.Parse(r.gTokens));

                    AddGTokensText.GetComponent <Text>().text = "";

                    // show a dialog to indicate success : then return to tournaments
                    TacoManager.OpenModal(TacoConfig.AddGTokensTitleSuccessMessage, returnMessage, null, ModalFunctions.ReturnToTournaments, null, null, false);
                }
                else
                {
                    AddGTokensText.GetComponent <Text>().text = TacoConfig.Error + " : " + r.message;
                }
                AddGTokensButton.GetComponent <Button>().interactable = true;
            };

            Action <string, string> fail = (string data, string error) => {
                if (!string.IsNullOrEmpty(error))
                {
                    TacoConfig.print("Error : " + error);
                }
                TacoManager.CloseMessage();
                string msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);
                TacoConfig.print("Error adding gTokens : " + msg);
                if (!string.IsNullOrEmpty(data))
                {
                    ErrorResult errorResult = JsonUtility.FromJson <ErrorResult>(data);
                    if (!errorResult.success)
                    {
                        msg = errorResult.message;
                    }
                }
                AddGTokensText.GetComponent <Text>().text             = TacoConfig.Error + " : " + msg;
                AddGTokensButton.GetComponent <Button>().interactable = true;
                //TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, msg);
            };

            StartCoroutine(ApiManager.Instance.AddGTokens(fee, fee * TacoConfig.gTokenExchange, success, fail));
        }
Пример #21
0
        private void GetPrizesList()
        {
            TacoManager.OpenMessage(TacoConfig.Processing);
            Action <string> success = (string data) => {
                alreadyLoadPrize = true;
                TacoManager.CloseMessage();
                PrizesResult r = JsonUtility.FromJson <PrizesResult>(data);
                LoadPrizes(r.prizes);
            };
            Action <string, string> fail = (string data, string error) => {
                TacoManager.CloseMessage();
                TacoManager.OpenModalConnectionErrorPanel(error);
            };

            StartCoroutine(ApiManager.Instance.GetPrizes(success, fail));
        }
Пример #22
0
        public void StartPlay(Tournament target)
        {
            if (target != null && target.id > 0)
            {
                TacoManager.OpenMessage(TacoConfig.TacoPlayStarting);
                //StartCoroutine(postStart());

                Action <string> success = (string data) => {
                    var r = JsonUtility.FromJson <StartGameResult>(data);
                    if (r.success)
                    {
                        TacoManager.GameToken = r.token;

                        GameManager.Instance.GetHighScore(r.highScore);

                        TacoManager.CloseMessage();

                        // delegate to your game
                        TacoSetup.Instance.StartMyGame();

                        // set the status text
                        TacoManager.StatusText.text = TacoConfig.GamePlayingMessage;

                        // close taco to play the game
                        TacoManager.CloseTaco();
                    }
                    else
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.OpenModal(TacoConfig.TacoPlayError, r.message);
                    }
                };


                Action <string, string> fail = (string data, string error) => {
                    var msg = data + ((string.IsNullOrEmpty(error)) ? "" : " : " + error);
                    TacoConfig.print("Error starting game - " + msg);

                    var r = JsonUtility.FromJson <StartGameResult>(data);

                    TacoManager.CloseAllModals();
                    TacoManager.OpenModal(TacoConfig.TacoPlayError, r.message);
                };

                StartCoroutine(ApiManager.Instance.StartGame(target.id, TacoManager.User.token, success, fail));
            }
        }
Пример #23
0
        private void SendWithdrawRequest()
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);
            Action <string> onSuccess = (string data) => {
                GeneralResult r = JsonUtility.FromJson <GeneralResult>(data);
                if (r.success)
                {
                    TacoManager.CloseMessage();
                    TacoManager.OpenModalGeneralResultPanel(r.success, TacoConfig.SuccessHeader, "You will receive a confirmation email within\n1 Business day once the withdraw amount has been approved.");
                    TacoManager.UpdateFundsOnly(r.cash);
                    if (wdSaveProfile.isOn)
                    {
                        TacoManager.User.contactProfile.UpdateData(wdAddress1Input.text, wdAddress2Input.text, wdCityInput.text, wdStateInput.text, wdZipcodeInput.text);
                    }
                    ResetWithdrawInputField();
                    moneyValue.text    = TacoManager.FormatCash(TacoManager.User.TotalCash);
                    availableFund.text = TacoManager.FormatCash(TacoManager.User.funds);
                    TournamentManager.Instance.SetMoneytext();
                    defaultAddress.text = TacoManager.User.contactProfile.FullAddress();
                    if (switchAddressBtn.transform.GetChild(0).GetComponent <Text>().text == TacoConfig.NoDefaultAddress)
                    {
                        withdrawBtn.onClick.Invoke();
                    }
                }
                else
                {
                    TacoManager.CloseMessage();
                    TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.Error, r.msg);
                }
                TacoManager.CloseMessage();
            };
            Action <string, string> onFail = (string data, string error) => {
                TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.ErrorHeader, error);
                TacoManager.CloseMessage();
            };

            if (newAddress.activeSelf)
            {
                StartCoroutine(ApiManager.Instance.Withdraw(withdrawAmoutInput.text, wdAddress1Input.text, wdAddress2Input.text, wdCityInput.text, wdStateInput.text, wdZipcodeInput.text, wdSaveProfile.isOn, onSuccess, onFail));
            }
            else
            {
                ContactProfile addr = TacoManager.User.contactProfile;
                StartCoroutine(ApiManager.Instance.Withdraw(withdrawAmoutInput.text, addr.address, addr.address2, addr.city, addr.state, addr.zipcode, false, onSuccess, onFail));
            }
        }
Пример #24
0
        public void StartPlay(Tournament target)
        {
            if (target != null && target.id > 0)
            {
                TacoManager.OpenMessage(TacoConfig.TacoPlayStarting);
                Action <string> success = (string data) => {
                    var r = JsonUtility.FromJson <StartGameResult>(data);
                    if (r.success)
                    {
                        TacoManager.GameToken = r.token;
                        TacoManager.CloseMessage();
                        // delegate to your game
                        TacoSetup.Instance.StartTournamentGame();
                        TacoManager.CloseTaco();
                    }
                    else
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.TacoPlayError, r.message);
                    }
                };


                Action <string, string> fail = (string data, string error) => {
                    var msg = data + ((string.IsNullOrEmpty(error)) ? string.Empty : " : " + error);
                    Debug.Log("Error starting game - " + msg);

                    var r = JsonUtility.FromJson <StartGameResult>(data);

                    TacoManager.CloseAllModals();
                    TacoManager.CloseAllModals();
                    if (r.forbidden)
                    {
                        TacoManager.OpenModalTournamentCreationForbiddenPanel(r.message);
                    }
                    else
                    {
                        TacoManager.OpenModalPlayTournamentErrorPanel(r.message);
                    }
                    //TacoManager.OpenModal(TacoConfig.TacoPlayError, r.message);
                };

                StartCoroutine(ApiManager.Instance.StartGame(target.typeCurrency, target.id, TacoManager.User.token, success, fail));
            }
        }
Пример #25
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);
        }
Пример #26
0
        public void InviteFriends()
        {
            //not be used --> remove in new version
            TacoManager.OpenMessage(TacoConfig.TacoSending);
            Action <string> success = (string data) => {
                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                Debug.Log("Error getting open tournaments : " + data);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }
            };

            StartCoroutine(ApiManager.Instance.InviteFriends(success, fail));
        }
Пример #27
0
        public void LoadInformation(Tournament t)
        {
            TacoManager.OpenMessage(TacoConfig.TacoRefreshing);

            Action <string> success = (string data) => {
                ManageTournamentResult r = JsonUtility.FromJson <ManageTournamentResult>(data);
                UpdateUIValue(r);

                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.Error, TacoConfig.TacoTournamentError);
            };

            var url = "api/tournament/getTourById";

            StartCoroutine(ApiManager.Instance.GetManageTournament(url, t.id, success, fail));
        }
Пример #28
0
        public void Reset()
        {
            TacoManager.OpenMessage(TacoConfig.Processing);
            Action <string> success = (string data) => {
                TacoManager.CloseMessage();
                GeneralResult r      = JsonUtility.FromJson <GeneralResult> (data);
                string        notice = r.success ? r.msg : r.err;
                string        header = r.success ? TacoConfig.EmailSentHeader : TacoConfig.ErrorHeader;
                TacoManager.OpenModalGeneralResultPanel(r.success, header, notice);
            };
            Action <string, string> fail = (string data, string error) => {
                TacoManager.CloseMessage();
                GeneralResult r = JsonUtility.FromJson <GeneralResult> (data);
                TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.ErrorHeader, r.err);
            };

            StartCoroutine(ApiManager.Instance.ResetPassword(resetAccount.text, success, fail));
            resetAccount.text = string.Empty;
        }
Пример #29
0
        public void LoadLeaderboard(Tournament tournament)
        {
            TacoManager.OpenMessage(TacoConfig.TacoRefreshing);
            ResetUIValue();

            Action <string> success = (string data) => {
                LeaderboardResult r = JsonUtility.FromJson <LeaderboardResult> (data);
                UpdateUIValue(r);

                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.Error, TacoConfig.TacoTournamentError);
            };

            var url = "api/tournament/leaderboard/" + TacoSetup.Instance.SiteId + "/" + tournament.id;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
Пример #30
0
        public void GetTransactions()
        {
            TacoManager.OpenMessage(TacoConfig.TacoRefreshing);
            int             cate    = (int)TacoSetup.Instance.TournamentCategory;
            Action <string> success = (string data) => {
                TransactionResult r = JsonUtility.FromJson <TransactionResult> (data);
                Reload(r.transactions.ToList());
                TacoManager.CloseMessage();
            };

            Action <string, string> fail = (string data, string error) => {
                Debug.Log("Error getting open tournaments : " + data);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }
                TacoManager.CloseMessage();
            };

            StartCoroutine(ApiManager.Instance.GetTransactions(15, success, fail));
        }