using System.Threading.Tasks;
namespace Phantom.XRMOD.GameServices.Runtime
{
///
/// Manages the Leaderboard system.
/// Provides methods to add/update scores and retrieve leaderboard rankings.
///
public class LeaderboardSystemManager
{
private ILeaderboardProvider leaderboardProvider;
private static LeaderboardSystemManager _INSTANCE;
///
/// Singleton instance of LeaderboardSystemManager.
///
public static LeaderboardSystemManager GetInstance => _INSTANCE ?? new LeaderboardSystemManager();
private LeaderboardSystemManager()
{
#if USE_UNITY_LEADERBOARD
leaderboardProvider = new UnityLeaderboardProvider();
#endif
}
///
/// To add or update an entry for the player in the specified leaderboard.
///
///
/// Added score data
public async Task AddOrUpdateScore(AddOrUpdateScoreArgs _addOrUpdateScoreArgs)
{
var tmp_Leaderboard = await leaderboardProvider.AddOrUpdateScore(
_leaderboardId: _addOrUpdateScoreArgs.LeaderboardId,
_score: _addOrUpdateScoreArgs.Score, _userName: _addOrUpdateScoreArgs.UserName);
return tmp_Leaderboard;
}
///
/// Players can get the scores from a specified leaderboard with the GetScoresAsync method.
/// You should create your leaderboard first and then substitute the leaderboardId for your own ID.
///
/// Require parameter.
/// List of
public async Task GetScoreList(GetScoreListArgs _getScoreListArgs)
{
return await leaderboardProvider.GetScoreList(_getScoreListArgs.LeaderboardId, _getScoreListArgs.Offset,
_getScoreListArgs.Limit);
}
///
/// Get the score for the player.
///
/// Request player score args.
/// The player score information, more detail
public async Task GetPlayerScore(GetPlayerScoreArgs _getPlayerScoreArgs)
{
return await leaderboardProvider.GetPlayerScore(_getPlayerScoreArgs.LeaderboardId);
}
}
}