Example #1
0
        void LeaderboardScoresDownloaded(LeaderboardScoresDownloaded value, bool flag)
        {
            Print(value.EntryCount.ToString() + " leaderboards downloaded.");
            for (int i = 0; i < value.EntryCount; i++)
            {
                LeaderboardEntry entry;
                int[]            details = new int[1];
                if (!Stats.GetDownloadedLeaderboardEntry(value.Entries, i, out entry, null))
                {
                    Failed();
                }
            }

            leaderboardsDone = true;
        }
Example #2
0
        private void HandleQuerryResult(LeaderboardScoresDownloaded scores)
        {
            float playerPosition = 1;

            if (scores.bIOFailure)
            {
                Debug.LogError("Failed to download score from Steam", this);
                return;
            }

            if (Entries == null)
            {
                Entries = new List <ExtendedLeaderboardEntry>();
            }
            else
            {
                Entries.Clear();
            }

            //Clear the collection if we have one
            if (collection != null)
            {
                var dList = new List <GameObject>();
                foreach (Transform t in collection)
                {
                    dList.Add(t.gameObject);
                }

                while (dList.Count > 0)
                {
                    var t = dList[0];
                    dList.RemoveAt(0);
                    Destroy(t);
                }
            }

            var userId = SteamUser.GetSteamID();

            for (int i = 0; i < scores.scoreData.m_cEntryCount; i++)
            {
                ExtendedLeaderboardEntry record = new ExtendedLeaderboardEntry();
                LeaderboardEntry_t       buffer;

                if (Settings.MaxDetailEntries < 1)
                {
                    SteamUserStats.GetDownloadedLeaderboardEntry(scores.scoreData.m_hSteamLeaderboardEntries, i, out buffer, null, 0);
                    record.Base = buffer;
                }
                else
                {
                    var details = new int[Settings.MaxDetailEntries];
                    SteamUserStats.GetDownloadedLeaderboardEntry(scores.scoreData.m_hSteamLeaderboardEntries, i, out buffer, details, Settings.MaxDetailEntries);
                    record.Base    = buffer;
                    record.Details = details;
                }

                Entries.Add(record);

                if (focusPlayer)
                {
                    if (userId.m_SteamID == buffer.m_steamIDUser.m_SteamID)
                    {
                        playerPosition = i / (float)scores.scoreData.m_cEntryCount;
                    }
                }

                if (entryPrototype != null && collection != null)
                {
                    var go    = Instantiate(entryPrototype, collection);
                    var entry = go.GetComponent <HeathenSteamLeaderboardEntry>();
                    if (entry != null)
                    {
                        entry.selfTransform.localPosition = Vector3.zero;
                        entry.selfTransform.localRotation = Quaternion.identity;
                        entry.selfTransform.localScale    = Vector3.one;
                        entry.ApplyEntry(record);
                    }
                }
            }

            if (focusPlayer && scrollRect != null)
            {
                Canvas.ForceUpdateCanvases();
                scrollRect.verticalNormalizedPosition = playerPosition;
                Canvas.ForceUpdateCanvases();
            }
        }