Exemplo n.º 1
0
 /// <summary>
 /// Downloads the leaderboard for the filter criteria. The p_onDownloadedScores callback is invoked when done.
 /// First all score entries are fetched, then all user names are loaded if they are not yet cached by Steam.
 /// Avatars are loaded as soon as they are requested with SteamLeaderboardsMain.GetAvatarTexture.
 /// See also SteamLeaderboardsMain.OnDownloadedScores.
 /// </summary>
 /// <returns><c>true</c>, if a request was started, <c>false</c> when the request could not have been started due to an error.</returns>
 /// <param name="p_leaderboardName">name of the leaderboard to load.</param>
 /// <param name="p_scoreSource">source of the leaderboard entries (Global, AroundUser, Friends).</param>
 /// <param name="p_rangeStart">score entries range to load. For example, [0,10] for Global, [-4,5] for AroundUser.</param>
 /// <param name="p_rangeEnd">score entries range to load. For example, [0,10] for Global, [-4,5] for AroundUser.</param>
 /// <param name="p_onDownloadedScores">invoked when the leaderboard is either fully loaded or an error has occured.</param>
 public bool DownloadScores(string p_leaderboardName, ELeaderboardDataRequest p_scoreSource, int p_rangeStart, int p_rangeEnd, System.Action <LeaderboardsDownloadedScoresEventArgs> p_onDownloadedScores)
 {
     if (SteamManager.Initialized)
     {
         SetSingleShotEventHandler("OnDownloadedScores", ref OnDownloadedScores, p_onDownloadedScores);
         Execute <LeaderboardFindResult_t>(SteamUserStats.FindLeaderboard(p_leaderboardName), (p_callback, p_bIOFailure) => OnDownloadScoresFindLeaderboardCallCompleted(p_leaderboardName, p_scoreSource, p_rangeStart, p_rangeEnd, p_callback, p_bIOFailure));
         return(true);                // request started
     }
     else
     {
         ErrorEventArgs errorArgs = ErrorEventArgs.CreateSteamNotInit();
         InvokeEventHandlerSafely(p_onDownloadedScores, new LeaderboardsDownloadedScoresEventArgs(errorArgs));
         HandleError("DownloadScores: failed! ", errorArgs);
         return(false);                // no request, because there is no connection to steam
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Upload or update a score entry in the given leaderboard. The p_onUploadedScore callback is invoked when done.<br />
 /// See also SteamLeaderboardsMain.OnUploadedScore.
 /// </summary>
 /// <returns><c>true</c>, if a request was started, <c>false</c> when the request could not have been started due to an error.</returns>
 /// <param name="p_leaderboardName">name of the leaderboard to update.</param>
 /// <param name="p_score">users score to submit.</param>
 /// <param name="p_scoreSorting">if the leaderboard with the given name does not yet exist, then it will be created with the given sorting</param>
 /// <param name="p_scoreType">if the leaderboard with the given name does not yet exist, then it will be created with the given score display type</param>
 /// <param name="p_scoreDetails">additional game-defined information regarding how the user got that score. E.g. a replay, a screenshot, etc...</param>
 /// <param name="p_onUploadedScore">invoked when the score upload is successfull or an error has occured.</param>
 public bool UploadScore(string p_leaderboardName, int p_score, ELeaderboardSortMethod p_scoreSorting, ELeaderboardDisplayType p_scoreType, int[] p_scoreDetails, System.Action <LeaderboardsUploadedScoreEventArgs> p_onUploadedScore)
 {
     if (SteamManager.Initialized)
     {
         if (p_scoreDetails != null && p_scoreDetails.Length > 64)
         {
             Debug.LogError("UploadScore: max. score details array length is 64 integers! Provided '" + p_scoreDetails.Length + "'! Data will be cutoff!");
         }
         SetSingleShotEventHandler(GetEventNameForOnUploadedScore(p_leaderboardName, p_score), ref OnUploadedScore, p_onUploadedScore);
         Execute <LeaderboardFindResult_t>(SteamUserStats.FindOrCreateLeaderboard(p_leaderboardName, p_scoreSorting, p_scoreType), (p_callback, p_bIOFailure) => OnUploadScoreFindOrCreateLeaderboardCallCompleted(p_leaderboardName, p_score, p_scoreSorting, p_scoreType, p_scoreDetails, p_callback, p_bIOFailure));
         return(true);                // request started
     }
     else
     {
         ErrorEventArgs errorArgs = ErrorEventArgs.CreateSteamNotInit();
         InvokeEventHandlerSafely(p_onUploadedScore, new LeaderboardsUploadedScoreEventArgs(errorArgs));
         HandleError("UploadScore: failed! ", errorArgs);
         return(false);                // no request, because there is no connection to steam
     }
 }