Ejemplo n.º 1
0
    private void SetLeaderboardEntryToUi(GameObject cell, LeaderboardEntry entry)
    {
        LeaderboardItemController cellController = cell.GetComponent <LeaderboardItemController>();

        cellController.textName.text  = entry.Name;
        cellController.textRank.text  = entry.Rank.ToString();
        cellController.textScore.text = entry.Score.ToString();

        cell.SetActive(true);
    }
    private LeaderboardItemController GetLeaderboardItemControl()
    {
        //Find in the list
        LeaderboardItemController item = listLeaderboardItemControl.Where(a => !a.gameObject.activeInHierarchy).FirstOrDefault();

        if (item == null)
        {
            //Didn't find one -> create new one
            item = Instantiate(leaderboardItemControlPrefab, Vector3.zero, Quaternion.identity);
            item.gameObject.SetActive(false);
            listLeaderboardItemControl.Add(item);
        }

        return(item);
    }
    private IEnumerator CRCreatingLeaderboardItems(List <PlayerLeaderboardData> data, int maxItem)
    {
        for (int i = 0; i < maxItem; i++)
        {
            //Create items
            LeaderboardItemController itemController = GetLeaderboardItemControl();
            itemController.transform.SetParent(contentTrans);
            itemController.gameObject.SetActive(true);
            itemController.OnSetup(i + 1, data[i]);

            //Set local user
            if (data[i].Name.Equals(PlayerPrefs.GetString(LeaderboardManager.SAVED_USER_NAME_PPK)))
            {
                localUsernameTxt.text = (i + 1).ToString() + "." + " " + data[i].Name;
                localLevelTxt.text    = "Level: " + data[i].HighestLevel.ToString();
            }

            yield return(new WaitForSeconds(0.05f));
        }
    }