Exemple #1
0
        private void UpdateUIValue(LeaderboardResult r)
        {
            Tournament t = r.tournament;

            string tournamentType = t.Type;
            double prizePool      = t.PrizePool;
            double entryFee       = double.Parse(t.entryFee.ToString());

            LeaderboardRow currentUserRank = r.leaderboard.First(x => x.userId == TacoManager.User.userId);
            string         infos           = string.Empty;
            string         details;
            double         moneyValue = 0;
            int            winnerNb   = r.winner.Length;

            prizeIcon.sprite        = TacoConfig.currencySprites [t.typeCurrency];
            tournamentTypeText.text = TacoConfig.LeaderboardTournamentType.Replace("&type", tournamentType).Replace("&gameName", TacoSetup.Instance.gameName);
            details = TacoConfig.LeaderboardResultDetails.Replace("&player", t.size.ToString()).Replace("&winner", TacoConfig.Pluralize(t.prize_structure, "Winner"));
            if (!string.IsNullOrEmpty(t.endDate))
            {
                FinishedButtons.SetActive(true);
                endedLeaderboardFooter.SetActive(true);
                rankIcon.transform.parent.gameObject.SetActive(true);
                int userRank = int.Parse(currentUserRank.rank);
                if (userRank < 4)
                {
                    rankIcon.gameObject.SetActive(true);
                    rankIcon.sprite = imageList.Images [currentUserRank.rank];
                }
                else
                {
                    rankText.transform.parent.gameObject.SetActive(true);
                    rankText.text = TacoConfig.ToShortOrdinal(userRank);
                }
                string formatedDay = t.endDate.Substring(5, 2) + "-" + t.endDate.Substring(8, 2) + "-" + t.endDate.Substring(0, 4);
                infos += TacoConfig.LeaderboardResultEndOn.Replace("&day", formatedDay);
                if (userRank <= t.prize_structure)
                {
                    resultStatus.text = "You Won!";
                    prizeAmount.text  = "+ ";
                    moneyValue        = t.PrizePool / winnerNb;
                    int rpModifier = 0;
                    if (t.typeCurrency == 0)
                    {
                        rpModifier = 50;
                    }
                    else
                    {
                        rpModifier = 5;
                    }
                    redeemAmount.text = "+ " + TacoManager.FormatRP(Mathf.RoundToInt((float)(moneyValue * rpModifier)));
                }
                else
                {
                    resultStatus.text = "You Lost!";
                    prizeAmount.text  = "+ ";
                    moneyValue        = 0;
                    redeemAmount.text = "+ " + TacoManager.FormatRP(0);
                }
            }
            else
            {
                resultStatus.text = "Beautiful Job!";
                playingLeaderboardFooter.SetActive(true);

                /*if (currentUserRank.playable)
                 *                      {
                 *                              FinishedButtons.SetActive(true);
                 *                      }
                 *                      else
                 *                      {
                 *                              UnfinishedButtons.SetActive(true);
                 *                      }*/
                rankIcon.transform.parent.gameObject.SetActive(false);
                countdownTime = Mathf.Max((float)t.RemainingTimeSpan.TotalSeconds, -1);
                if (countdownTime < 0)
                {
                    remainingTime.text = "00:00:00";
                }
            }

            if (t.typeCurrency == 0)
            {
                prizePoolText.text = TacoManager.FormatCash(prizePool);
                entryFeeText.text  = TacoManager.FormatCash(entryFee);
                prizeAmount.text  += TacoManager.FormatCash(moneyValue);
            }
            else
            {
                prizePoolText.text = TacoManager.FormatGTokens(prizePool);
                entryFeeText.text  = TacoManager.FormatGTokens(entryFee);
                prizeAmount.text  += TacoManager.FormatGTokens(moneyValue);
            }

            for (int i = 0; i < LeaderBoardMoneyTypeImages.Count; i++)
            {
                LeaderBoardMoneyTypeImages [i].sprite = TacoConfig.currencySprites [t.typeCurrency];
            }

            infos += TacoConfig.LeaderboardResultTournamentID.Replace("&id", t.id.ToString());

            resultScore.text            = "Score: " + currentUserRank.score.ToString();
            tournamentDetailsText0.text = infos;
            tournamentDetailsText1.text = details;

            /*playAgain.onClick.RemoveAllListeners();
             *                playAgain.onClick.AddListener (() => {
             *                        TacoManager.OpenModalReEnterPanel (
             *                                TacoConfig.ReEnterNotice.Replace ("&type", tournamentType).Replace("&gameName", t.accessType == "public" ? "Public" : "Private"),
             *                                entryFeeText.text);
             *                });*/
            Reload(r.leaderboard, !string.IsNullOrEmpty(t.endDate));
        }