Пример #1
0
        public void TappedInviteFromList(Tournament t)
        {
            // TODO : move tournament Target to this class
            TacoManager.SetTarget(t);

            TacoManager.OpenModalWithPreFab(TacoConfig.TacoInviteFriendsModalHeader, TournamentInvitePrefab, TacoConfig.InviteSprite, ModalFunctions.InviteFriends, TacoConfig.CloseSprite, null);

            if (t.played)
            {
                TournamentManager.Instance.ShowTournamentPanel(PanelNames.MyLeaderboardPanel);
            }
            else if (t.memberlength == t.size)
            {
                Double prize = double.Parse(t.prize.ToString());

                string replacedString = TacoConfig.TacoSurePlayModalBody.Replace("&prize", TacoManager.FormatMoney(prize));

                TacoManager.OpenModal(TacoConfig.TacoSurePlayModalHeader, replacedString, TacoConfig.PlaySprite, ModalFunctions.StartPlay, TacoConfig.CloseSprite, null);
            }
            else
            {
                TacoManager.OpenModalWithPreFab(TacoConfig.TacoInviteFriendsModalHeader, TournamentInvitePrefab, TacoConfig.InviteSprite, ModalFunctions.InviteFriends, TacoConfig.CloseSprite, null);

                TacoModalPanel.Instance.SetModalButtonEnabled(false);

                TournamentInvite tournamentInvite = TacoModalPanel.Instance.GetPreFab().GetComponent <TournamentInvite> ();
            }
        }
Пример #2
0
        public void TappedGameFromList(Tournament t)
        {
            TacoManager.SetTarget(t);

            if (t.played)
            {
                TournamentManager.Instance.ShowTournamentPanel(PanelNames.MyLeaderboardPanel);
            }
            else
            {
                Double prize          = t.prize;
                int    typeCurrency   = t.typeCurrency;
                string replacedString = string.Empty;

                if (typeCurrency == 0)
                {
                    replacedString = TacoConfig.TacoSurePlayModalBody.Replace("&prize", TacoManager.FormatMoney(prize));
                }
                else
                {
                    replacedString = TacoConfig.TacoSurePlayModalBody.Replace("&prize", TacoManager.FormatGTokens(prize));
                }
                TacoManager.OpenModal(TacoConfig.TacoSurePlayModalHeader, replacedString, TacoConfig.PlaySprite, ModalFunctions.StartPlay, TacoConfig.CloseSprite, null);
            }
        }
Пример #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);
                    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));
        }
Пример #4
0
        public void OnPlayPress(bool isDown)
        {
            if (!isDown)
            {
                ButtonSound("Default");

                TacoManager.OpenModal(TacoConfig.TacoSurePlayModalHeader, TacoConfig.TacoSurePlayModalBody, TacoConfig.PlaySprite, ModalFunctions.StartPlay, TacoConfig.CloseSprite, null);
            }
        }
Пример #5
0
        public void PostScore(int score, Tournament target)
        {
            TacoConfig.print(" Game Ended with score : " + score);

            PlayerPrefs.SetInt(TacoConfig.TacoHighScoresType, 0);
            PlayerPrefs.SetFloat(TacoConfig.TacoHighScoresPerhapsText, 0);
            Highscore.Instance.highscore = PlayerPrefs.GetFloat("highscoreArcade");
            Highscore.Instance.UpdateManually();

            if (target != null && TacoManager.UserLoggedIn())
            {
                //StartCoroutine(endGame(score));

                Action <string> success = (string data) => {
                    ScoreResult r = JsonUtility.FromJson <ScoreResult>(data);
                    TacoConfig.print("Result complete = " + r.success + " - " + r.score + " - " + r.message);
                    string modalBody = string.Empty;
                    //If user play again so token can't verify
                    if (r.success)
                    {
                        modalBody = TacoConfig.TacoPlayEndedModalBody;

                        modalBody = modalBody.Replace("&gameEndScore", r.score.ToString());
                    }
                    else
                    {
                        modalBody = TacoConfig.TacoPlayEndedAgainModalBody;
                    }

                    TacoManager.CloseAllModals();
                    TacoManager.OpenModal(TacoConfig.TacoPlayEndedModalHeader, modalBody, null, ModalFunctions.TournamentGamePosted);

                    // set the status text
                    TacoManager.StatusText.text = "";

                    // game is over : release token
                    TacoManager.GameToken = null;
                    if (r.updated)
                    {
                        TacoManager.UpdateFundsWithToken(r.funds, r.gTokens.ToString());
                    }
                };

                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.EndGame(score, target.id, target.gameId, TacoManager.GameToken, TacoManager.User.token, success, fail));
            }
        }
Пример #6
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));
        }
Пример #7
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);
        }
Пример #8
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));
        }
Пример #9
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));
            }
        }
Пример #10
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);
        }
Пример #11
0
        public void OnLoginHelpPress(bool isDown)
        {
            if (!isDown)
            {
                ButtonSound("Default");
                switch (name)
                {
                case "LoginHelpButton":

                    TacoManager.OpenModal(TacoConfig.TacoHelpLoginTitle, TacoConfig.TacoHelpLoginBody);

                    break;

                default:
                    break;
                }
            }
        }
Пример #12
0
        public void LoadLeaderboard(Tournament t)
        {
            Action <string> success = (string data) => {
                LeaderboardResult r = JsonUtility.FromJson <LeaderboardResult>(data);

                Double prize    = Double.Parse(r.tournament.prize.ToString());
                Double entryFee = Double.Parse(r.tournament.entryFee.ToString());

                string details;
                if (r.tournament.typeCurrency == 0)
                {
                    details = TacoConfig.LeaderboardResults.Replace("&prize", TacoManager.FormatMoney(prize));
                    details = details.Replace("&name", r.tournament.name);
                    details = details.Replace("&fee", TacoManager.FormatMoney(entryFee));
                }
                else
                {
                    details = TacoConfig.LeaderboardResults.Replace("&prize", TacoManager.FormatGTokens(prize));
                    details = details.Replace("&name", r.tournament.name);
                    details = details.Replace("&fee", TacoManager.FormatGTokens(entryFee));
                }

                TacoConfig.print(details);

                tournamentDetailsText.text = details;

                this.Reload(r.leaderboard);
            };

            Action <string, string> fail = (string data, string error) => {
                TacoManager.OpenModal(TacoConfig.Error, TacoConfig.TacoTournamentError + " | " + error + " | " + data);
            };

            var url = "api/tournament/leaderboard/" + TacoConfig.SiteId + "/" + t.id;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
Пример #13
0
        public void ValidateUserOrEmail(string emailToCheck)
        {
            EmailOkay.SetActive(false);
            TacoModalPanel.Instance.SetModalButtonEnabled(false);

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

                if (r.success)
                {
                    if (data.Contains("true"))
                    {
                        EmailOkay.SetActive(true);
                        TacoModalPanel.Instance.SetModalButtonEnabled(true);
                    }
                    ;
                }
                ;
            };

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

                TacoManager.CloseMessage();
                string msg = errorData + (string.IsNullOrEmpty(error) ? "" : " : " + error);
                TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01);
            };


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

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
Пример #14
0
        public void GetOurGames()
        {
            if (!loadedGames)
            {
                TacoManager.OpenMessage(TacoConfig.TacoOurGamesLoadingMessage);

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

                        TacoManager.CloseMessage();
                        UpdateGames(r);
                    }
                };

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

                    TacoManager.CloseMessage();

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

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

                string url = "api/game/featured";
                StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
                loadedGames = true;
            }
        }
Пример #15
0
        public void StartCreate( )
        {
            string bodyString = TacoConfig.TournamentCreateModalBody;

            //GetCurrentFeeFromToggles
            //string feeString = GetFeeAmount();
            int    typeCurrencyOption = TacoManager.GetTogglActiveName(typeCurrencyToggle.GetComponent <ToggleGroup> ());
            Double feeString          = 0;
            string replacedString     = string.Empty;

            if (typeCurrencyOption == 0)
            {
                feeString      = double.Parse(GetFeeAmount());
                replacedString = bodyString.Replace("&fee", TacoManager.FormatMoney(feeString));
            }
            else
            {
                feeString      = GetCurrentGTokenFromToggles() * TacoConfig.gTokenExchange;
                replacedString = bodyString.Replace("&fee", TacoManager.FormatGTokens(feeString));
            }

            // pop a dialog to make sure they want to create the tournament
            TacoManager.OpenModal(TacoConfig.TournamentCreateModalHeader, replacedString, TacoConfig.PlaySprite, ModalFunctions.TournamentSubmit);
        }
        public void AddFunds()
        {
            var num = CardNumberInput.GetComponent <InputField>().text;

            if (num == string.Empty)
            {
                AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError00;
                return;
            }

            var month = ExpMonthInput.GetComponent <InputField>().text;

            if (month == string.Empty)
            {
                AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError01;
                return;
            }

            var year = ExpYearInput.GetComponent <InputField>().text;

            if (year == string.Empty)
            {
                AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError02;
                return;
            }

            var cvc = CVCInput.GetComponent <InputField>().text;

            if (cvc == string.Empty)
            {
                AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError03;
                return;
            }

            var group  = FundsGroup.GetComponent <ToggleGroup>();
            var toggle = group.ActiveToggles().FirstOrDefault();

            if (toggle == null)
            {
                AddStatusText.GetComponent <Text>().text = TacoConfig.AddFundsError04;
                return;
            }
            int amount = 0;

            switch (toggle.name)
            {
            case "Toggle5":
                amount = 5 * 100;
                break;

            case "Toggle10":
                amount = 10 * 100;
                break;

            case "Toggle25":
                amount = 25 * 100;
                break;

            case "Toggle50":
                amount = 50 * 100;
                break;

            case "Toggle100":
                amount = 100 * 100;
                break;

            default:
                break;
            }
            AddFundsButton.GetComponent <Button>().interactable = false;
            AddStatusText.GetComponent <Text>().text            = TacoConfig.AddFundsAdding;
            isAdding = true;

            //StartCoroutine(purchaseFunds(num, Int32.Parse(month), Int32.Parse(year), Int32.Parse(cvc), amount));
            //StartCoroutine(GetStripeToken(num, month, year, cvc, amount));


            Action <string> success = (string data) => {
                TacoConfig.print("Purchase funds complete - " + data);
                var r = JsonUtility.FromJson <AddFundsResult>(data);
                if (r.success)
                {
                    if (r.funds != null && r.funds != string.Empty)
                    {
                        TacoConfig.print("funds = " + r.funds);

                        var funds = double.Parse(r.funds);

                        // funds added : return to Tournaments view

                        TacoManager.UpdateFundsOnly(funds);
                        string returnMessage = TacoConfig.AddFundsSuccessMessage + TacoManager.FormatMoney(funds);
                        AddStatusText.GetComponent <Text>().text = "";
                        Destroy();
                        // show a dialog to indicate success : then return to tournaments
                        TacoManager.OpenModal(TacoConfig.AddFundsTitleSuccessMessage, returnMessage, null, ModalFunctions.ReturnToTournaments, null, null, false);
                    }
                }
                else
                {
                    AddStatusText.GetComponent <Text>().text = TacoConfig.Error + " : " + r.message;
                }
                AddFundsButton.GetComponent <Button>().interactable = true;
            };

            Action <string, string> fail = (string data, string error) => {
                var msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);
                TacoConfig.print("Error adding funds : " + msg);
                AddStatusText.GetComponent <Text>().text            = TacoConfig.Error + " : " + msg;
                AddFundsButton.GetComponent <Button>().interactable = true;
            };

            StartCoroutine(ApiManager.Instance.AddFunds(num, month, year, cvc, amount, success, fail));
        }
Пример #17
0
        private IEnumerator postJoin(Tournament t)
        {
            WWWForm form = new WWWForm();

            form.AddField("type", t.typeCurrency);
            form.AddField("tournamentId", t.id);
            form.AddField("siteId", TacoConfig.SiteId);
            form.AddField("gameId", TacoManager.GameId);

            UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/tournament/join", form);

            www.SetRequestHeader("x-access-token", TacoManager.User.token);
            yield return(www.Send());

            if (www.isError || www.responseCode == 500)
            {
                TacoConfig.print("DL Handler = " + www.downloadHandler.text);
                TacoConfig.print("URL = " + www.url);
                TacoConfig.print("Error downloading: " + www.error);


                var r = JsonUtility.FromJson <CreateTournamentResult>(www.downloadHandler.text);


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

                    TacoManager.OpenModal(TacoConfig.TacoJoinPublicErrorHead, r.message);
                }
            }
            else
            {
                // show the highscores
                TacoConfig.print("Join Tournament complete - " + www.downloadHandler.text);
                //createResultsText.GetComponent<Text>().text = "Tournament created, click the 'Play' button below to play your round now!";

                var r = JsonUtility.FromJson <JoinTournamentResult>(www.downloadHandler.text);
                TacoConfig.print(r);

                if (r.success)
                {
                    TacoManager.SetTarget(t);

                    Decimal prize    = decimal.Parse(r.tournament.prize.ToString("F2"));
                    Decimal entryFee = decimal.Parse(r.tournament.entryFee.ToString("F2"));

                    string replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", r.userFunds);
                    replacedString = replacedString.Replace("&entryFee", entryFee.ToString());

                    replacedString = replacedString.Replace("&prize", prize.ToString());

                    TacoManager.CloseMessage();


                    TacoManager.OpenModal(TacoConfig.TacoJoinPublicSuccessHead, replacedString, null, ModalFunctions.JoinPublicSuccess);

                    double val = 0;
                    if (double.TryParse(r.userFunds, out val))
                    {
                        TacoManager.UpdateFundsOnly(val);
                    }
                }
                else
                {
                    TacoManager.CloseMessage();
                    TacoManager.OpenModal(TacoConfig.TacoJoinPublicErrorHead, TacoConfig.TacoJoinPublicErrorMessage00 + r.message);
                }
            }
        }
Пример #18
0
        public void Join()
        {
            TacoManager.OpenMessage(TacoConfig.TacoPublicJoining);

            var t = TacoManager.Target;


            Action <string> success = (string data) => {
                // show the highscores
                TacoConfig.print("Join Tournament complete - " + data);
                //createResultsText.GetComponent<Text>().text = "Tournament created, click the 'Play' button below to play your round now!";

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


                if (r.success)
                {
                    TacoManager.SetTarget(t);

                    Decimal prize    = decimal.Parse(r.tournament.prize.ToString("F2"));
                    Decimal entryFee = decimal.Parse(r.tournament.entryFee.ToString("F2"));

                    string replacedString = "";
                    if (r.tournament.typeCurrency == 0)
                    {
                        replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", r.userFunds);
                        replacedString = replacedString.Replace("&entryFee", entryFee.ToString());
                        replacedString = replacedString.Replace("&prize", prize.ToString());
                    }
                    else
                    {
                        replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", " G " + r.userFunds);
                        replacedString = replacedString.Replace("&entryFee", " G " + entryFee.ToString());
                        replacedString = replacedString.Replace("&prize", " G " + prize.ToString());
                    }
                    TacoManager.CloseMessage();

                    TacoManager.OpenModal(TacoConfig.TacoJoinPublicSuccessHead, replacedString, null, ModalFunctions.JoinPublicSuccess);

                    double val = 0;
                    if (r.tournament.typeCurrency == 0)
                    {
                        //real money
                        if (double.TryParse(r.userFunds, out val))
                        {
                            TacoManager.UpdateFundsWithToken(val, r.currencyValue);
                        }
                    }
                    else
                    {
                        //userFunds is 'gtoken' now
                        if (double.TryParse(r.currencyValue, out val))
                        {
                            TacoManager.UpdateFundsWithToken(val, r.userFunds);
                        }
                    }
                }
                else
                {
                    TacoManager.CloseMessage();

                    TacoManager.OpenModal(TacoConfig.TacoJoinPublicErrorHead, TacoConfig.TacoJoinPublicErrorMessage00 + r.message);
                }
            };

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

                if (!string.IsNullOrEmpty(data))
                {
                    var r = JsonUtility.FromJson <CreateTournamentResult>(data);
                    if (!string.IsNullOrEmpty(r.message))
                    {
                        TacoConfig.print("r.message: " + r.message);
                        TacoManager.CloseMessage();
                        TacoManager.OpenModal(TacoConfig.TacoJoinPublicErrorHead, r.message);
                    }
                }
            };


            if (t != null)
            {
                StartCoroutine(ApiManager.Instance.JoinTournament(t.typeCurrency, t.id, TacoConfig.SiteId, TacoManager.GameId, TacoManager.User.token, success, fail));
            }
        }
Пример #19
0
 public void TournamentSubmitError(string results)
 {
     TacoConfig.print("TournamentSubmitError");
     TacoManager.CloseMessage();
     TacoManager.OpenModal("", results);
 }
Пример #20
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));
            }
        }
Пример #21
0
        public void Register()
        {
            TacoConfig.print("Register Pressed");

            var email    = EmailInput.GetComponent <InputField>().text;
            var password = PasswordInput.GetComponent <InputField>().text;
            var age      = AgeToggle.GetComponent <Toggle>().isOn;
            var user     = UserInput.GetComponent <InputField>().text;

            if (validateInput())
            {
                int avatar = 0;

                //StartCoroutine(postRegister(email, password, age, avatar, user));

                TacoManager.OpenMessage(TacoConfig.TacoRegisteredStatusMessage00);

                Action <string> success = (string data) => {
                    TacoConfig.print(data);
                    LoginResult r = JsonUtility.FromJson <LoginResult>(data);
                    TacoConfig.print("Result = " + r.success + " - " + r.started.Count + " - " + r.ended.Count + " - " + r.userId + " - " + r.funds);

                    if (r.success)
                    {
                        TacoManager.CloseMessage();
                        // email sent, have to wait for them to verify.
                        TacoManager.OpenModal(TacoConfig.TacoRegisteredModalTitle, r.message, null, "TacoRegisterResult");

                        // clean up the registerpanel
                        Init();
                    }
                    else
                    {
                        // an error returned
                        TacoManager.CloseMessage();
                        TacoManager.OpenModal(TacoConfig.TacoRegisteredErrorHeader, r.message);
                    }
                };

                Action <string, string> fail = (string data, string error) => {
                    TacoConfig.print("Error on register : " + data);
                    if (!string.IsNullOrEmpty(error))
                    {
                        TacoConfig.print("Error : " + error);
                    }
                    TacoManager.CloseMessage();
                    string msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);
                    if (!string.IsNullOrEmpty(data))
                    {
                        ErrorResult errorResult = JsonUtility.FromJson <ErrorResult>(data);
                        if (!errorResult.success)
                        {
                            msg = errorResult.message;
                        }
                    }

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

                StartCoroutine(ApiManager.Instance.Register(user, email, password, age, success, fail));
            }
        }
Пример #22
0
 public void TacoOpenModel(object[] contentModal)
 {
     scoreNow = int.Parse(contentModal[2].ToString());
     TacoManager.OpenModal(contentModal[0].ToString(), contentModal[1].ToString(), null, contentModal[3].ToString());
 }