public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback) { var leaderboardRequest = new ISN_GKLeaderboard(); leaderboardRequest.Identifier = leaderboardId; var isn_timeSpan = ToIOSSpan(span); var isn_collection = ToIOSCollection(collection); leaderboardRequest.PlayerScope = isn_collection; leaderboardRequest.TimeScope = isn_timeSpan; leaderboardRequest.Range = new ISN_NSRange(1, 1); leaderboardRequest.LoadScores(result => { UM_ScoreLoadResult um_result; if (result.IsSucceeded) { var score = new UM_Score(leaderboardRequest.LocalPlayerScore.Value, leaderboardRequest.LocalPlayerScore.Rank, (int)leaderboardRequest.LocalPlayerScore.Context, leaderboardRequest.LocalPlayerScore.DateUnix); um_result = new UM_ScoreLoadResult(score); } else { um_result = new UM_ScoreLoadResult(result.Error); } callback.Invoke(um_result); }); }
public void SubmitScore(string leaderboardId, long score, int context, Action <SA_Result> callback) { UM_EditorAPIEmulator.WaitForNetwork(() => { UM_Score um_score = new UM_Score(score, 10, context, SA_Unix_Time.ToUnixTime(DateTime.Now)); UM_EditorAPIEmulator.SetString(leaderboardId, JsonUtility.ToJson(um_score)); callback.Invoke(new SA_Result()); }); }
public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback) { UM_EditorAPIEmulator.WaitForNetwork(() => { if (UM_EditorAPIEmulator.HasKey(leaderboardId)) { string json = UM_EditorAPIEmulator.GetString(leaderboardId); UM_Score um_score = JsonUtility.FromJson <UM_Score>(json); callback.Invoke(new UM_ScoreLoadResult(um_score)); } else { var error = new SA_Error(100, "Leaderboard with id: " + leaderboardId + " does not have any scores yet."); callback.Invoke(new UM_ScoreLoadResult(error)); } }); }
public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback) { var leaderboards = AN_Games.GetLeaderboardsClient(); var an_timeSpan = ToAndroidSpan(span); var an_collection = ToAndroidCollection(collection); leaderboards.LoadCurrentPlayerLeaderboardScore(leaderboardId, an_timeSpan, an_collection, res => { UM_ScoreLoadResult um_result; if (res.IsSucceeded) { AN_LeaderboardScore an_score = res.Data; int context; try { context = Convert.ToInt32(an_score.ScoreTag); } catch (Exception ex) { Debug.LogWarning("Failed to convert anroid score tag to int. leaderboardId: " + leaderboardId + " error: " + ex.Message); context = 0; } UM_Score score = new UM_Score(an_score.RawScore, an_score.Rank, context, an_score.TimestampMillis); um_result = new UM_ScoreLoadResult(score); } else { um_result = new UM_ScoreLoadResult(res.Error); } callback.Invoke(um_result); }); }
public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback) { var leaderboards = AN_Games.GetLeaderboardsClient(); AN_Leaderboard.TimeSpan an_timeSpan = AN_Leaderboard.TimeSpan.AllTime; switch (span) { case UM_LeaderboardTimeSpan.AllTime: an_timeSpan = AN_Leaderboard.TimeSpan.AllTime; break; case UM_LeaderboardTimeSpan.Weekly: an_timeSpan = AN_Leaderboard.TimeSpan.Weekly; break; case UM_LeaderboardTimeSpan.Daily: an_timeSpan = AN_Leaderboard.TimeSpan.Daily; break; } AN_Leaderboard.Collection an_collection = AN_Leaderboard.Collection.Public; switch (collection) { case UM_LeaderboardCollection.Public: an_collection = AN_Leaderboard.Collection.Public; break; case UM_LeaderboardCollection.Social: an_collection = AN_Leaderboard.Collection.Social; break; } leaderboards.LoadCurrentPlayerLeaderboardScore(leaderboardId, an_timeSpan, an_collection, (res) => { UM_ScoreLoadResult um_result; if (res.IsSucceeded) { AN_LeaderboardScore an_score = res.Data; int context; try { context = Convert.ToInt32(an_score.ScoreTag); } catch (Exception ex) { Debug.LogWarning("Failed to convert anroid score tag to int. leaderboardId: " + leaderboardId + " error: " + ex.Message); context = 0; } UM_Score score = new UM_Score(an_score.RawScore, an_score.Rank, context, an_score.TimestampMillis); um_result = new UM_ScoreLoadResult(score); } else { um_result = new UM_ScoreLoadResult(res.Error); } callback.Invoke(um_result); }); }
public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback) { var leaderboardRequest = new ISN_GKLeaderboard(); leaderboardRequest.Identifier = leaderboardId; ISN_GKLeaderboardPlayerScope isn_collection = ISN_GKLeaderboardPlayerScope.Global; switch (collection) { case UM_LeaderboardCollection.Public: isn_collection = ISN_GKLeaderboardPlayerScope.Global; break; case UM_LeaderboardCollection.Social: isn_collection = ISN_GKLeaderboardPlayerScope.FriendsOnly; break; } ISN_GKLeaderboardTimeScope isn_timeSpan = ISN_GKLeaderboardTimeScope.AllTime; switch (span) { case UM_LeaderboardTimeSpan.AllTime: isn_timeSpan = ISN_GKLeaderboardTimeScope.AllTime; break; case UM_LeaderboardTimeSpan.Weekly: isn_timeSpan = ISN_GKLeaderboardTimeScope.Week; break; case UM_LeaderboardTimeSpan.Daily: isn_timeSpan = ISN_GKLeaderboardTimeScope.Today; break; } leaderboardRequest.PlayerScope = isn_collection; leaderboardRequest.TimeScope = isn_timeSpan; leaderboardRequest.Range = new ISN_NSRange(1, 1); leaderboardRequest.LoadScores((result) => { UM_ScoreLoadResult um_result; if (result.IsSucceeded) { UM_Score score = new UM_Score(leaderboardRequest.LocalPlayerScore.Value, leaderboardRequest.LocalPlayerScore.Rank, (int)leaderboardRequest.LocalPlayerScore.Context, leaderboardRequest.LocalPlayerScore.DateUnix); um_result = new UM_ScoreLoadResult(score); } else { um_result = new UM_ScoreLoadResult(result.Error); } callback.Invoke(um_result); }); }