Beispiel #1
0
        private bool ProcessScoresDownloaded(LeaderboardScoresDownloaded_t param, bool bIOFailure)
        {
            bool playerIncluded = false;

            ///Check for the current users data in the record set and update accordingly
            if (!bIOFailure)
            {
                var userId = SteamUser.GetSteamID();

                for (int i = 0; i < param.m_cEntryCount; i++)
                {
                    LeaderboardEntry_t buffer;
                    int[] details = null;

                    if (MaxDetailEntries < 1)
                    {
                        SteamUserStats.GetDownloadedLeaderboardEntry(param.m_hSteamLeaderboardEntries, i, out buffer, details, MaxDetailEntries);
                    }
                    else
                    {
                        details = new int[MaxDetailEntries];
                        SteamUserStats.GetDownloadedLeaderboardEntry(param.m_hSteamLeaderboardEntries, i, out buffer, details, MaxDetailEntries);
                    }

                    if (buffer.m_steamIDUser.m_SteamID == userId.m_SteamID)
                    {
                        playerIncluded = true;
                        if (!UserEntry.HasValue || UserEntry.Value.m_nGlobalRank != buffer.m_nGlobalRank)
                        {
                            var l = new LeaderboardUserData()
                            {
                                leaderboardName = leaderboardName,
                                leaderboardId   = LeaderboardId.Value,
                                entry           = buffer,
                                details         = details
                            };

                            var lc = new LeaderboardRankChangeData()
                            {
                                leaderboardName = leaderboardName,
                                leaderboardId   = LeaderboardId.Value,
                                newEntry        = buffer,
                                oldEntry        = UserEntry.HasValue ? new LeaderboardEntry_t?(UserEntry.Value) : null
                            };

                            UserEntry = buffer;

                            UserRankLoaded.Invoke(l);
                            UserRankChanged.Invoke(lc);

                            if (lc.newEntry.m_nGlobalRank < (lc.oldEntry.HasValue ? lc.oldEntry.Value.m_nGlobalRank : int.MaxValue))
                            {
                                UserNewHighRank.Invoke(lc);
                            }
                        }
                        else
                        {
                            var l = new LeaderboardUserData()
                            {
                                leaderboardName = leaderboardName,
                                leaderboardId   = LeaderboardId.Value,
                                entry           = buffer,
                                details         = details
                            };

                            UserEntry = buffer;
                            UserRankLoaded.Invoke(l);
                        }
                    }
                }
            }

            return(playerIncluded);
        }
Beispiel #2
0
 /// <summary>
 /// This is set to the <see cref="HeathenEngineering.SteamApi.PlayerServices.SteamworksLeaderboardData.UserNewHighRank"/> event in <see cref="RegisterForBoardEvents"/> method
 /// </summary>
 /// <param name="eventData">The change rank data loaded as a result of the operation</param>
 void handleUserNewHighRank(HeathenEngineering.SteamApi.PlayerServices.LeaderboardRankChangeData eventData)
 {
     Debug.Log("Local user's rank has changed for the better");
     // You can find the old entry data in eventData.oldEntry, this is a Nullable<T> so check if eventData.oldEntry.HasValue and if so read from eventData.oldEntry.Value
     // You can find the new entry data in eventData.newEntry, this is not nullable so always have a value.
 }
Beispiel #3
0
 private void HandleLeaderboardNewHighRank(LeaderboardRankChangeData arg0)
 {
     LeaderboardNewHighRank.Invoke(arg0);
 }
Beispiel #4
0
 /// <summary>
 /// Get the leaderboard referenced by the change data
 /// </summary>
 /// <param name="chageData">A Leaderboard Rank Change Data object, most commonly had from Rank Change events</param>
 /// <returns>Returns the leaderboard found if any else returns null</returns>
 public SteamworksLeaderboardData GetLeaderboard(LeaderboardRankChangeData chageData)
 {
     return(Leaderboards.FirstOrDefault(p => p.leaderboardName == chageData.leaderboardName));
 }
Beispiel #5
0
 private void HandleLeaderboardRankChanged(LeaderboardRankChangeData arg0)
 {
     LeaderboardRankChanged.Invoke(arg0);
 }