Ejemplo n.º 1
0
    //Create leaderboard entries for each profile then load them onto the panel
    public void DisplayLoaderboard()
    {
        DownloadLeaderProfiles();
        Debug.Log("Displaying Leaderboard");
        float entryPos = 0.0f;
        bool  topDown  = true;

        SortLeaderboard(topDown);
        SortLeaders(topDown);
        //Insert First, second and third game items.
        int count = 1;

        foreach (Dictionary <string, object> scoreEntry in Leaderboard)
        {
            string           name = "#" + count + "   " + scoreEntry["name"].ToString();
            LeaderboardEntry e    = (LeaderboardEntry)scoreEntry["entry"];
            //Display rank e.g. "#1   Kyle    30000"
            e.SetName(name);
            e.MakeGameObject();
            GameObject    entry = e.GetEntryObj();
            RectTransform rf    = entry.GetComponent <RectTransform>();
            rf.SetParent(LeaderboardHolder.transform);
            rf.localPosition = new Vector3(0.0f, entryPos, 0.0f);
            rf.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
            entryPos        -= 200.0f;
            //Increase Leaderboard content height
            RectTransform r = Content.GetComponent <RectTransform>();
            r.sizeDelta = new Vector2(r.sizeDelta.x, r.sizeDelta.y + 200.0f);

            //You know the three big circles on the left side of the leaderboard panel?
            //The below if statements populate those :)
            if (count == 1)
            {
                FirstName.GetComponent <Text>().text = scoreEntry["name"].ToString();
                e.AddTopLeaderPic(FirstPic);
            }
            else if (count == 2)
            {
                SecondName.GetComponent <Text>().text = scoreEntry["name"].ToString();
                e.AddTopLeaderPic(SecondPic);
            }
            else if (count == 3)
            {
                ThirdName.GetComponent <Text>().text = scoreEntry["name"].ToString();
                e.AddTopLeaderPic(ThirdPic);
            }
            count++;
        }
    }