Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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> ();
            }
        }
Ejemplo n.º 3
0
        public void TappedJoinFromList(Tournament t)
        {
            // TODO : move tournament Target to this class
            TacoManager.SetTarget(t);
            TacoConfig.print("join");
            TacoConfig.print(t);
            TacoConfig.print(t.typeCurrency);
            Double prize        = t.prize;
            Double entryFee     = t.entryFee;
            int    typeCurrency = t.typeCurrency;
            string players      = t.size.ToString() + " " + TacoConfig.Players;

            TacoManager.OpenModalWithPreFab(TacoConfig.TacoSureJoinModalHeader, TournamentDetailsPrefab, TacoConfig.JoinSprite, ModalFunctions.JoinTournament, TacoConfig.CloseSprite, null);

            TournamentDetails tournamentDetails = TacoModalPanel.Instance.GetPreFab().GetComponent <TournamentDetails> ();

            if (typeCurrency == 0)
            {
                string replacedString = TacoConfig.TacoSureJoinModalBody.Replace("&entryFee", TacoManager.FormatMoney(entryFee));
                replacedString = replacedString.Replace("&prize", TacoManager.FormatMoney(prize));
                tournamentDetails.UpdateDetails(replacedString, players, TacoManager.FormatMoney(prize));
            }
            else
            {
                string replacedString = TacoConfig.TacoSureJoinModalBody.Replace("&entryFee", TacoManager.FormatGTokens(entryFee));
                replacedString = replacedString.Replace("&prize", TacoManager.FormatGTokens(prize));
                tournamentDetails.UpdateDetails(replacedString, players, TacoManager.FormatGTokens(prize));
            }
        }
Ejemplo n.º 4
0
        public void TappedGameFromList(Tournament t)
        {
            TacoManager.SetTarget(t);

            if (t.played)
            {
                ShowTournamentPanel(PanelNames.MyLeaderboardPanel);
            }
            else
            {
                TacoManager.OpenModalPlayTournamentPanel(t);
            }
        }
Ejemplo n.º 5
0
 public void TappedInviteFromList(Tournament t, string actionPrefabName, PrivateTournamentsList myPrivatePanel)
 {
     // TODO : move tournament Target to this class
     TacoManager.SetTarget(t);
     if (actionPrefabName == myPrivatePanel.ItemShowLeaderboardPrefab.name)
     {
         ShowTournamentPanel(PanelNames.MyLeaderboardPanel);
     }
     else if (actionPrefabName == myPrivatePanel.ItemPlayPrefab.name)
     {
         TacoManager.OpenModalPlayTournamentPanel(t);
     }
     else if (actionPrefabName == myPrivatePanel.ItemInvitePrefab.name)
     {
         TacoManager.Target = t;
         TacoManager.ShowPanel(PanelNames.ManageTournamentPanel);
     }
 }
Ejemplo n.º 6
0
        public void TappedJoinFromList(Tournament t)
        {
            TacoManager.SetTarget(t);
            double entryFee       = t.entryFee;
            int    typeCurrency   = t.typeCurrency;
            string replacedString = string.Empty;

            if (t.IsWarningTime())
            {
                TacoManager.OpenModalWarningTimePanel(t);
            }
            else
            {
                string formatFee = string.Empty;
                replacedString = "To enter this <b>'" + TacoSetup.Instance.gameName + " &tournamentType'</b> the &tournamentFee will be debited from your account.";
                if (typeCurrency == 0)
                {
                    replacedString = replacedString.Replace("&tournamentFee", "Cash Entry Fee");
                    formatFee      = TacoManager.FormatCash(entryFee);
                }
                else
                {
                    replacedString = replacedString.Replace("&tournamentFee", "Taco Token Entry Fee");
                    formatFee      = TacoManager.FormatGTokens(entryFee);
                }

                if (CurrentSubPanel == PanelNames.MyPublicPanel)
                {
                    replacedString = replacedString.Replace("&tournamentType", "Public Tournament");
                }
                else
                {
                    replacedString = replacedString.Replace("&tournamentType", "Private Tournament");
                }

                TacoManager.OpenModalEnterTournamentPanel(replacedString, formatFee, typeCurrency);
            }
        }
Ejemplo n.º 7
0
        private IEnumerator postCreate(string name, string fee, string players, string opponents, string gameInt)
        {
            WWWForm form = new WWWForm();

            form.AddField("name", name);
            form.AddField("fee", fee);
            form.AddField("size", players);

            //form.AddField("gameId", TacoManager.Instance.GameId);
            form.AddField("gameId", gameInt);

            form.AddField("siteId", TacoConfig.SiteId);
            form.AddField("opponents", opponents);


            TacoConfig.print("Form Post : Fee =" + fee + " players = " + players + " name =" + name);

            TacoConfig.print("Create Tournament complete - " + fee);

            UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/tournament", 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);

                if (!string.IsNullOrEmpty(www.downloadHandler.text))
                {
                    var r = JsonUtility.FromJson <CreateTournamentResult>(www.downloadHandler.text);
                    if (!string.IsNullOrEmpty(r.message))
                    {
                        TacoConfig.print("r.message: " + r.message);

                        TournamentSubmitError(r.message);
                    }
                }
            }
            else
            {
                // show the highscores
                TacoConfig.print("Create Tournament complete - " + www.downloadHandler.text);


                TournamentSubmitResult(TacoConfig.TacoTournamentCreated);

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

                if (r.tournament != null)
                {
                    TacoConfig.print("New tournament = " + r.tournament.id + " - " + r.tournament.name);
                }
                double val = 0;

                if (double.TryParse(r.userFunds, out val))
                {
                    TacoManager.UpdateFundsOnly(val);
                }

                TacoManager.SetTarget(r.tournament);
            }
        }
Ejemplo n.º 8
0
        public void CreateTournament()
        {
            // disable the button during the creation process : it holds the keyboard focus
            // TODO : find a way to release the focus
            Button createButton = CreateTournamentButton.GetComponent <Button>();

            createButton.interactable = false;
            int    typeCurrency = TacoManager.GetTogglActiveName(typeCurrencyToggle.GetComponent <ToggleGroup> ());
            string feeAmount    = string.Empty;
            string currencyIcon = string.Empty;

            if (typeCurrency == 0)
            {
                feeAmount    = GetFeeAmount();
                currencyIcon = "$";
            }
            else
            {
                feeAmount    = (GetCurrentGTokenFromToggles() * TacoConfig.gTokenExchange).ToString();
                currencyIcon = "G";
            }


            int playersOption = TacoManager.GetTogglActiveName(playersToggle.GetComponent <ToggleGroup> ());

            int prizeStructure = TacoManager.GetTogglActiveName(structureToggle.GetComponent <ToggleGroup> ());

            Debug.Log("prizeStructure" + prizeStructure);
            string name = string.Format(TacoManager.GameName + " - " + currencyIcon + "{0} Entry - {1} Players", feeAmount, playersOption);

            int opponentsOption = TacoManager.GetTogglActiveName(opponentsToggle.GetComponent <ToggleGroup> ());

            string opponents = "";

            string invitedFriendsString = "";

            for (int i = 0; i < invitedFriends.Count; i++)
            {
                invitedFriendsString = invitedFriendsString + "," + invitedFriends[i].ToString();
            }

            if (!string.IsNullOrEmpty(invitedFriendsString))
            {
                invitedFriendsString = invitedFriendsString.Substring(1);
            }

            switch (opponentsOption)
            {
            case 0:
                opponents = "public";
                break;

            case 1:
                opponents = "private";
                break;
            }
            int timeRemaining = 0;

            timeRemaining = TacoManager.GetTogglActiveName(timeRemainingToggle.GetComponent <ToggleGroup> ());

            Action <string> success = (string data) => {
                TacoConfig.print("Create Tournament complete - " + data);

                TournamentSubmitResult(TacoConfig.TacoTournamentCreated);

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

                if (r.tournament != null)
                {
                    TacoConfig.print("New tournament = " + r.tournament.id + " - " + r.tournament.name);

                    double val = 0;
                    if (r.typeCurrency == "real")
                    {
                        if (double.TryParse(r.userFunds, out val))
                        {
                            TacoManager.UpdateFundsOnly(val);
                        }
                    }
                    else
                    {
                        TacoManager.UpdateTokenOnly(r.userFunds);
                    }


                    TacoManager.SetTarget(r.tournament);
                }
            };

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

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

            StartCoroutine(ApiManager.Instance.CreateTournament(timeRemaining, typeCurrency, prizeStructure, invitedFriendsString, name, feeAmount, playersOption, opponents, TacoManager.GameId, TacoManager.User.token, success, fail));
        }
Ejemplo n.º 9
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);
                }
            }
        }
Ejemplo n.º 10
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));
            }
        }
Ejemplo n.º 11
0
        public void Join()
        {
            TacoManager.OpenMessage(TacoConfig.TacoPublicJoining);
            var t = TacoManager.Target;

            Action <string> success = (string data) => {
                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 = string.Empty;
                    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", " T " + r.userFunds);
                        replacedString = replacedString.Replace("&entryFee", " T " + entryFee.ToString());
                        replacedString = replacedString.Replace("&prize", " T " + prize.ToString());
                    }
                    TacoManager.CloseMessage();

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

                    ShowTournamentPanel(CurrentSubPanel);
                }
                else
                {
                    TacoManager.CloseMessage();
                    if (r.addFund)
                    {
                        if (t.typeCurrency == 0)
                        {
                            TacoManager.OpenModalFundErrorJoinPanel(TacoConfig.TacoJoinPublicNoFundHead, t);
                        }
                        else
                        {
                            TacoManager.OpenModalTacoErrorJoinPanel(TacoConfig.TacoJoinPublicNoTacoHead, t);
                        }
                    }
                    else
                    {
                        TacoManager.OpenModalAlreadyJoinedPanel(TacoConfig.TacoJoinAlreadyHead, r.message);
                    }
                }
            };

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

                if (!string.IsNullOrEmpty(data))
                {
                    var r = JsonUtility.FromJson <CreateTournamentResult> (data);
                    TacoManager.CloseMessage();
                    if (!string.IsNullOrEmpty(r.message))
                    {
                        if (r.forbidden)
                        {
                            TournamentSubmitForbidden(r.message);
                        }
                        else
                        {
                            TacoManager.OpenModalTournamentJoinErrorPanel(TacoConfig.TacoJoinPublicErrorHead, r.message, ModalFunctions.FundsScreen);
                        }
                    }
                }
            };

            if (t != null)
            {
                StartCoroutine(ApiManager.Instance.JoinTournament(t.typeCurrency, t.id, TacoSetup.Instance.SiteId, TacoManager.GameId, TacoManager.User.token, success, fail));
            }
        }
Ejemplo n.º 12
0
        public void ReEnter()
        {
            TacoManager.OpenMessage(TacoConfig.TacoPublicJoining);
            var t = TacoManager.Target;

            Action <string> success = (string data) => {
                Debug.Log("reenter data: " + data);
                var r = JsonUtility.FromJson <JoinTournamentResult> (data);
                if (r.success)
                {
                    TacoManager.SetTarget(t);
                    var prize    = decimal.Parse(r.tournament.prize.ToString("F2"));
                    var entryFee = decimal.Parse(r.tournament.entryFee.ToString("F2"));

                    string replacedString = string.Empty;
                    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", " T " + r.userFunds);
                        replacedString = replacedString.Replace("&entryFee", " T " + entryFee.ToString());
                        replacedString = replacedString.Replace("&prize", " T " + prize.ToString());
                    }
                    TacoManager.CloseMessage();
                    TacoManager.OpenModalJoinSuccessPanel(r.tournament, TacoConfig.ReenterSuccessNotice);
                    TacoManager.UpdateFundsWithToken(r.cash, r.token.ToString(), r.ticket.ToString());
                    ShowTournamentPanel(CurrentSubPanel);
                }
                else
                {
                    TacoManager.CloseMessage();
                    if (r.error == TacoConfig.NotEnoughFundError)
                    {
                        TacoManager.OpenModalFundErrorJoinPanel(TacoConfig.TacoJoinPublicNoFundHead, t);
                    }
                    else if (r.error == TacoConfig.NotEnoughTokenError)
                    {
                        TacoManager.OpenModalTacoErrorJoinPanel(TacoConfig.TacoJoinPublicNoTacoHead, t);
                    }
                    else if (r.error == TacoConfig.DuplidateError)
                    {
                        TacoManager.OpenModalAlreadyJoinedPanel(TacoConfig.TacoJoinAlreadyHead, r.message);
                    }
                    else
                    {
                        TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.Error, r.message);
                    }
                }
            };

            Action <string, string> fail = (string data, string error) => {
                if (!string.IsNullOrEmpty(data))
                {
                    var r = JsonUtility.FromJson <CreateTournamentResult> (data);
                    TacoManager.CloseMessage();
                    if (!string.IsNullOrEmpty(r.message))
                    {
                        if (r.forbidden)
                        {
                            TournamentSubmitForbidden(r.message);
                        }
                        else
                        {
                            TacoManager.OpenModalTournamentJoinErrorPanel(TacoConfig.TacoJoinPublicErrorHead, r.message, ModalFunctions.FundsScreen);
                        }
                    }
                }
            };

            if (t != null)
            {
                StartCoroutine(ApiManager.Instance.ReEnterTournament(t.id, success, fail));
            }
        }
Ejemplo n.º 13
0
        public void CreateTournament(Tournament tourament)
        {
            // disable the button during the creation process : it holds the keyboard focus
            // TODO : find a way to release the focus
            //Button createButton = CreateTournamentButton.GetComponent<Button>();
            //createButton.interactable = false;
            int    typeCurrency = tourament.typeCurrency;
            string feeAmount    = tourament.entryFee.ToString();
            string currencyIcon = tourament.typeCurrency == 0 ? "$" : "T";

            int playersOption  = tourament.size;
            int prizeStructure = tourament.prize_structure;


            string name = string.Format(TacoManager.GameName + " - " + currencyIcon + "{0} Entry - {1} Players", feeAmount, tourament.size);

            string accessType           = string.Empty;
            string invitedFriendsString = string.Empty;

            if (tourament.accessType == "public")
            {
                accessType = "public";
            }
            else
            {
                //for( int i = 0; i < invitedFriends.Count; i++ ) {
                for (int i = 0; i < tourament.invitedEmails.Length; i++)
                {
                    invitedFriendsString = invitedFriendsString + "," + tourament.invitedEmails [i];
                }
                accessType = "private";
            }


            int timeRemaining = tourament.TimeRemaining;

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

                if (r.tournament != null)
                {
                    if (r.best)
                    {
                        TacoManager.SetTarget(r.tournament);
                        TournamentDuplicateResult(TacoConfig.TacoTournamentDuplicated, r.tournament);
                    }
                    else
                    {
                        ShowTournamentPanel(CurrentSubPanel);
                        TacoManager.CreatePublicPanel.SetActive(false);
                        TournamentSubmitResult(r.tournament);

                        double val = 0;
                        if (r.typeCurrency == "real")
                        {
                            if (double.TryParse(r.userFunds, out val))
                            {
                                TacoManager.UpdateFundsOnly(val, r.userBonus);
                            }
                        }
                        else
                        {
                            TacoManager.UpdateTokenOnly(r.userFunds);
                        }

                        TacoManager.SetTarget(r.tournament);
                        SetMoneytext();
                    }
                }
            };

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

                if (!string.IsNullOrEmpty(data))
                {
                    var r = JsonUtility.FromJson <CreateTournamentResult> (data);
                    if (!string.IsNullOrEmpty(r.message))
                    {
                        if (r.forbidden)
                        {
                            TournamentSubmitForbidden(r.message);
                        }
                        else
                        {
                            TournamentSubmitError(r.message);
                        }
                    }
                }
            };

            StartCoroutine(ApiManager.Instance.CreateTournament(timeRemaining, typeCurrency, prizeStructure, invitedFriendsString, name, feeAmount, playersOption, accessType, TacoManager.GameId, TacoManager.User.token, success, fail));
        }
Ejemplo n.º 14
0
 public void SeeResult(Tournament t)
 {
     TacoManager.SetTarget(t);
     ShowTournamentPanel(PanelNames.MyLeaderboardPanel);
 }