Exemplo n.º 1
0
        public void UpdateGTokenToBuy()
        {
            int         gTokenchoise  = TacoManager.GetTogglActiveName(currencyToConvertToggle.GetComponent <ToggleGroup> ());
            ToggleGroup currencyGroup = currencyToConvertToggle.GetComponent <ToggleGroup>();
            var         currencyList  = currencyGroup.GetComponentsInChildren <Toggle>();

            gTokensWillHaveText.text = "GTokens you will have: " + (gTokenchoise * TacoConfig.gTokenExchange).ToString("0,0.00");
            addGTokensText.text      = "";
        }
Exemplo n.º 2
0
        public string CalculateGTokenFromToggles()
        {
            int gTokenOption   = GetCurrentGTokenFromToggles() * TacoConfig.gTokenExchange;
            int playersOption  = TacoManager.GetTogglActiveName(playersToggle.GetComponent <ToggleGroup> ());
            int prizeStructure = TacoManager.GetTogglActiveName(structureToggle.GetComponent <ToggleGroup> ());

            int     total  = gTokenOption * playersOption;
            decimal amount = (decimal)((total - (.1 * total)) / prizeStructure);

            Debug.Log("GToken " + gTokenOption + "players " + playersOption + "prize " + prizeStructure + "total " + total);
            return("G " + amount.ToString(TacoConfig.GTokenFormat));
        }
Exemplo n.º 3
0
        public string GetCurrentPrizeFromToggles()
        {
            int feeAmount      = GetCurrentFeeFromToggles();
            int playersOption  = TacoManager.GetTogglActiveName(playersToggle.GetComponent <ToggleGroup> ());
            int prizeStructure = TacoManager.GetTogglActiveName(structureToggle.GetComponent <ToggleGroup> ());

            int     total  = feeAmount * playersOption;
            decimal amount = (decimal)((total - (.1 * total)) / prizeStructure);

            Debug.Log("fee " + feeAmount + "players " + playersOption + "prize " + prizeStructure + "total " + total);
            return(amount.ToString("C"));
        }
Exemplo n.º 4
0
        public int GetGameFromToggles()
        {
            int gameOption = TacoManager.GetTogglActiveName(gameToggle.GetComponent <ToggleGroup> ());

            int game = 0;

            switch (gameOption)
            {
            case 0:
                game = 3;
                break;

            case 1:
                game = 2;
                break;
            }

            return(game);
        }
Exemplo n.º 5
0
        public string GetOpponentsFromToggles()
        {
            int opponentsOption = TacoManager.GetTogglActiveName(opponentsToggle.GetComponent <ToggleGroup> ());

            string opponents = "";

            switch (opponentsOption)
            {
            case 0:
                opponents = TacoConfig.TacoTournamentOpponentsPublic;
                break;

            case 1:
                opponents = TacoConfig.TacoTournamentOpponentsPrivate;
                break;

            case 2:
                opponents = TacoConfig.TacoTournamentOpponentsChallenge;
                break;
            }

            return(opponents);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
0
        public string GetFeeAmount()
        {
            string amount = TacoManager.GetTogglActiveName(feeToggle.GetComponent <ToggleGroup> ()).ToString();

            return(amount);
        }
Exemplo n.º 9
0
        public void UpdatePrizeText()
        {
            int         playersOption = TacoManager.GetTogglActiveName(playersToggle.GetComponent <ToggleGroup> ());
            ToggleGroup abc           = structureToggle.GetComponent <ToggleGroup> ();

            Toggle[] prizeStrucList = abc.GetComponentsInChildren <Toggle>();

            int         typeCurrencyChoice = TacoManager.GetTogglActiveName(typeCurrencyToggle.GetComponent <ToggleGroup> ());
            ToggleGroup typeCurrencyGroup  = typeCurrencyToggle.GetComponent <ToggleGroup>();
            var         typeCurrencyList   = typeCurrencyGroup.GetComponentsInChildren <Toggle>();

            activeTypeCurrency(typeCurrencyChoice);

            Debug.Log("hear ne");
            for (var i = 0; i < prizeStrucList.Length; i++)
            {
                prizeStrucList[i].enabled = true;
            }
            if (playersOption == 2)
            {
                //prizeStrucList[0].isOn = true;
                for (var i = 1; i < prizeStrucList.Length; i++)
                {
                    if (prizeStrucList[i].isOn)
                    {
                        prizeStrucList[0].isOn = true;
                        prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                        prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                    }
                    prizeStrucList[i].isOn    = false;
                    prizeStrucList[i].enabled = false;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.gray;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.gray;
                }
                for (var i = 0; i < 1; i++)
                {
                    prizeStrucList[i].enabled = true;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                }
                //PrizeText =""+     GetCurrentPrizeFromToggles () ;
            }
            else if (playersOption == 3)
            {
                //prizeStrucList[0].isOn = true;
                for (var i = 2; i < prizeStrucList.Length; i++)
                {
                    if (prizeStrucList[i].isOn)
                    {
                        prizeStrucList[0].isOn = true;
                        prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                        prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                    }
                    prizeStrucList[i].isOn    = false;
                    prizeStrucList[i].enabled = false;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.gray;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.gray;
                }
                for (var i = 0; i < 2; i++)
                {
                    prizeStrucList[i].enabled = true;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                }
                //PrizeText =""+     GetCurrentPrizeFromToggles () ;
            }
            else if (playersOption == 5)
            {
                //prizeStrucList[0].isOn = true;
                for (var i = 3; i < prizeStrucList.Length; i++)
                {
                    if (prizeStrucList[i].isOn)
                    {
                        prizeStrucList[0].isOn = true;
                        prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                        prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                    }
                    prizeStrucList[i].isOn    = false;
                    prizeStrucList[i].enabled = false;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.gray;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.gray;
                }
                for (var i = 0; i < 3; i++)
                {
                    prizeStrucList[i].enabled = true;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                }
                //PrizeText =""+     GetCurrentPrizeFromToggles () ;
            }
            else if (playersOption == 10)
            {
                //prizeStrucList[0].isOn = true;
                for (var i = 4; i < prizeStrucList.Length; i++)
                {
                    if (prizeStrucList[i].isOn)
                    {
                        prizeStrucList[0].isOn = true;
                        prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                        prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                    }
                    prizeStrucList[i].isOn    = false;
                    prizeStrucList[i].enabled = false;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.gray;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.gray;
                }
                for (var i = 0; i < 4; i++)
                {
                    prizeStrucList[i].enabled = true;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                }
                //PrizeText =""+     GetCurrentPrizeFromToggles () ;
            }
            else
            {
                for (var i = 0; i < prizeStrucList.Length; i++)
                {
                    prizeStrucList[i].enabled = true;
                    prizeStrucList[i].GetComponentInChildren <Text>().color = Color.white;
                    prizeStrucList[i].GetComponentInChildren <Text>().GetComponentInChildren <Image>().color = Color.white;
                }
                //PrizeText =""+     GetCurrentPrizeFromToggles () ;
            }
            string OpponentsText = GetOpponentsFromToggles();

            opponentsText.GetComponent <Text> ().text = OpponentsText;


            if (opponentsText.GetComponent <Text>().text == TacoConfig.TacoTournamentOpponentsPrivate)
            {
                InviteFriendsButton.SetActive(true);
            }
            else
            {
                InviteFriendsButton.SetActive(false);
            }
            Button createButton = CreateTournamentButton.GetComponent <Button>();

            if (typeCurrencyChoice == 0)
            {
                string PrizeText = TacoConfig.TournamentFeePrefix + " " + GetCurrentPrizeFromToggles();
                prizeText.GetComponent <Text> ().text = PrizeText;

                TacoConfig.print(TacoManager.User.funds + "  >= " + GetCurrentFeeFromToggles());

                // set the button on/off depending on enough funds
                if (TacoManager.User.funds >= GetCurrentFeeFromToggles())
                {
                    createButton.interactable = true;
                    createStatusText.text     = TacoConfig.TournamentCreateMessage;
                }
                else
                {
                    createButton.interactable = false;
                    createStatusText.text     = TacoConfig.TournamentCreateNotEnoughFunds;
                }
            }
            else
            {
                string PrizeText = TacoConfig.TournamentFeePrefix + " " + CalculateGTokenFromToggles();
                prizeText.GetComponent <Text> ().text = PrizeText;
                TacoConfig.print(TacoManager.User.gToken + "  >= " + CalculateGTokenFromToggles());

                double gTokenOption = GetCurrentGTokenFromToggles() * TacoConfig.gTokenExchange;
                double userGTokens  = double.Parse(TacoManager.User.gToken, NumberStyles.Number);
                TacoConfig.print("GTokenOption: " + gTokenOption + " " + "userGtokens: " + userGTokens);
                if (userGTokens >= gTokenOption)
                {
                    createButton.interactable = true;
                    createStatusText.text     = TacoConfig.TournamentCreateMessage;
                }
                else
                {
                    createButton.interactable = false;
                    createStatusText.text     = TacoConfig.TournamentCreateNotEnoughGTokens;
                }
            }
        }
Exemplo n.º 10
0
        public int GetCurrentCurrencyToConvertFromToggles()
        {
            int gTokensAmount = TacoManager.GetTogglActiveName(currencyToConvertToggle.GetComponent <ToggleGroup> ());

            return(gTokensAmount);
        }
Exemplo n.º 11
0
        public int GetCurrentGTokenFromToggles()
        {
            int gTokensAmount = TacoManager.GetTogglActiveName(createGTokenToggle.GetComponent <ToggleGroup> ());

            return(gTokensAmount);
        }
Exemplo n.º 12
0
        public int GetCurrentFeeFromToggles()
        {
            int feeAmount = TacoManager.GetTogglActiveName(feeToggle.GetComponent <ToggleGroup> ());

            return(feeAmount);
        }