Ejemplo n.º 1
0
        protected override void CreateSubObjects(ListViewItem item, string columnName)
        {
            ListViewItem.ListViewSubItem subItem = item.SubItems [ColumnNames.IndexOf(columnName)];
            LeaderboardRow itemData = item.Tag as LeaderboardRow;

            if (columnName == TacoConfig.LeaderboardTournamentPlayerColumn)
            {
                GameObject            button = Instantiate(ItemLeaderboardButtonPrefab);
                LeaderboardItemButton leaderboardItemButton = button.GetComponent <LeaderboardItemButton> ();
                leaderboardItemButton.Setup(itemData.rank, itemData.picture, subItem.Text, ListView.DefaultItemFontSize);
                subItem.CustomControl = button.transform as RectTransform;
            }
        }
Ejemplo n.º 2
0
        protected void AddListViewItem(LeaderboardRow leaderboardRow, bool isEven, bool isEndedTournament)
        {
            int rankInt = int.Parse(leaderboardRow.rank);

            string[] subItemTexts =
            {
                string.Empty,
                isEndedTournament ? (rankInt > 3 ? leaderboardRow.rank : string.Empty) : "N/A",
                leaderboardRow.email,
                leaderboardRow.score.ToString()
            };

            ListViewItem listViewItem = new ListViewItem(subItemTexts);

            if (leaderboardRow.email == TacoManager.User.name)
            {
                listViewItem.SubItems [0].ImageKey = "currentUser";
            }

            var subItem = listViewItem.SubItems [ColumnNames.IndexOf("RANK")];

            if (!isEndedTournament)
            {
                //subItem.ImageKey = "na";
            }
            else if (rankInt < 4)
            {
                subItem.ImageKey = leaderboardRow.rank;
            }
            else
            {
                //subItem.ImageKey = "0";
            }

            listViewItem.Tag = leaderboardRow;
            listViewItem.UseItemStyleForSubItems = false;

            var backgroundColor = TacoConfig.ListViewOddRow;

            if (isEven)
            {
                backgroundColor = TacoConfig.ListViewEvenRow;
            }

            for (int i = 0; i < listViewItem.SubItems.Count; i++)
            {
                listViewItem.SubItems [i].BackColor = backgroundColor;
            }

            ListView.Items.Add(listViewItem);
        }
Ejemplo n.º 3
0
        private void createCustomObjects(ListViewItem item)
        {
            var subItem = item.SubItems [1];
            // int index = this.ListView.SelectedIndices[0];
            // var t = Items[index];


            LeaderboardRow itemData = item.Tag as LeaderboardRow;

            GameObject button = GameObject.Instantiate(ItemLeaderboardButtonPrefab) as GameObject;

            subItem.CustomControl = button.transform as RectTransform;

            LeaderboardItemButton leaderboardItemButton = button.GetComponent <LeaderboardItemButton> ();

            // TODO get avatar from user
            int avatar = UnityEngine.Random.Range(0, 7);

            leaderboardItemButton.Setup(itemData.rank, avatar);
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        protected void AddListViewItem(LeaderboardRow leaderboardRow)
        {
            bool winner = false;

            string rankString = leaderboardRow.rank;

            if (leaderboardRow.rank == "1")
            {
                if (TacoManager.Target.status == TournamentStatus.Ended)
                {
                    winner     = true;
                    rankString = "";
                }
                else
                {
                    rankString = TacoConfig.CurrentLeader;
                }
            }


            string[] subItemTexts = new string[]
            {
                "",
                "",
                leaderboardRow.email,
                leaderboardRow.score.ToString(),
                rankString,
                ""
            };

            ListViewItem listViewItem = new ListViewItem(subItemTexts);

            if (winner)
            {
                listViewItem.SubItems [4].ImageKey = "winner";
                listViewItem.SubItems[4].Width     = 256;
            }


            //listViewItem.SubItems[0].ImageKey = "bannerEnd";
            //listViewItem.SubItems[1].ImageKey = "banner";
            //listViewItem.SubItems[2].ImageKey = "banner";
            //listViewItem.SubItems[3].ImageKey = "banner";
            //listViewItem.SubItems[4].ImageKey = "banner";
            //listViewItem.SubItems[5].ImageKey = "bannerEnd";



            listViewItem.SubItems[0].Width = 45;
            //listViewItem.SubItems[1].Width = 380;
            //listViewItem.SubItems[3].Width = 45;
            listViewItem.SubItems[1].Height = 233;

            //listViewItem.SubItems[0].Width = 92;
            //listViewItem.SubItems[0].Height = 233;


            listViewItem.Tag = leaderboardRow;

            createCustomObjects(listViewItem);

            listViewItem.UseItemStyleForSubItems = false;

            this.ListView.Items.Add(listViewItem);
        }