public void SyncronizeToSteamLeaderBoardIfNeeded()
    {
        // try fetch the players leaderboard score one time
        if (fetchSteamLeaderboardEntry && steamLeaderboard.foundLeaderboard && steamLeaderboard.downloadedLeaderboard && !steamLeaderboard.downLoadingUserEntry)
        {
            int fetchedMMR = steamLeaderboard.ReadDownloadedUserLeaderboardEntry(); // read user mmr
            intro_playerMMR.text       = fetchedMMR.ToString();                     // syncronize the ui with the fetched value
            playerController.playerMMR = fetchedMMR;
            fetchSteamLeaderboardEntry = false;
        }

        // try fetch the top 10 leaderboard scores one time
        if (fetchSteamLeaderboardTop100Entries && steamLeaderboard.foundLeaderboard && steamLeaderboard.downloadedLeaderboard && !steamLeaderboard.downLoadingTop100Entries)
        {
            steamLeaderboard.top100Entries = steamLeaderboard.ReadDownloadedTop100Entries(); // read top 10 entries
            for (int i = 0; i < steamLeaderboard.top100Entries.Length; i++)
            {
                LeaderboardEntry leaderboardEntryPrefab = steamLeaderBoardTop100EntriesUIPrefabsList.ToArray()[i]; // syncronize the ui with the fetched values
                LeaderEntry      top100Entry            = steamLeaderboard.top100Entries[i];
                leaderboardEntryPrefab.rank               = top100Entry.globalRank;
                leaderboardEntryPrefab.mmrText.text       = top100Entry.score.ToString();
                leaderboardEntryPrefab.nameText.text      = SteamFriends.GetFriendPersonaName(top100Entry.id);
                leaderboardEntryPrefab.rankText.text      = top100Entry.globalRank.ToString() + ")";
                leaderboardEntryPrefab.steamAvatar.sprite = top100Entry.avatar;
                if (top100Entry.globalRank == 1 || top100Entry.globalRank == 2 || top100Entry.globalRank == 3)
                {
                    leaderboardEntryPrefab.trophyIcon.gameObject.SetActive(true);
                    leaderboardEntryPrefab.trophyIcon.sprite = top100Entry.trophyIcon;
                }
            }
            fetchSteamLeaderboardTop100Entries = false;
        }
    }
Example #2
0
    public LeaderEntry[] ReadDownloadedTop100Entries()
    {
        Debug.Log("[LeaderBoard] reading top 100 entries");
        LeaderEntry[] vals = new LeaderEntry[topEntriesCount];

        for (int i = 0; i < topEntriesCount; i++)
        {
            LeaderboardEntry_t entry_T;
            SteamUserStats.GetDownloadedLeaderboardEntry(hSteamTop100Entries, i, out entry_T, pScoreDetails, cScoreDetailsCount);
            vals[i] = new LeaderEntry(entry_T.m_steamIDUser, entry_T.m_nGlobalRank, entry_T.m_nScore);
        }
        return(vals);
    }