public long GetCurrentPlayerScore(UM_Leaderboard leaderboard) { switch (Application.platform) { case RuntimePlatform.IPhonePlayer: GK_Leaderboard board = GameCenterManager.GetLeaderboard(leaderboard.IOSId); if (board != null) { GK_Score score = board.GetCurrentPlayerScore(GK_TimeSpan.ALL_TIME, GK_CollectionType.GLOBAL); if (score != null) { return(score.GetLongScore()); } } break; case RuntimePlatform.Android: GPLeaderBoard gBoard = GooglePlayManager.instance.GetLeaderBoard(leaderboard.AndroidId); if (gBoard != null) { GPScore score = gBoard.GetCurrentPlayerScore(GPBoardTimeSpan.ALL_TIME, GPCollectionType.GLOBAL); if (score != null) { return(score.score); } } break; } return(0); }
private void OnLoaderBoardInfoRetrived(string data) { string[] DataArray = data.Split(new string[] { SA.Common.Data.Converter.DATA_SPLITTER2 }, StringSplitOptions.None); string leaderboardId = DataArray[0]; GK_TimeSpan timeSpan = (GK_TimeSpan)System.Convert.ToInt32(DataArray[1]); GK_CollectionType collection = (GK_CollectionType)System.Convert.ToInt32(DataArray[2]); int requestId = System.Convert.ToInt32(DataArray[3]); long scoreVal = System.Convert.ToInt64(DataArray[4]); int rank = System.Convert.ToInt32(DataArray[5]); int context = System.Convert.ToInt32(DataArray[6]); int maxRange = System.Convert.ToInt32(DataArray[7]); string title = DataArray[8]; string describtion = DataArray[9]; GK_Leaderboard board = GetLeaderboard(leaderboardId); board.UpdateMaxRange(maxRange); board.Info.Title = title; board.Info.Description = describtion; GK_Score score = new GK_Score(scoreVal, rank, context, timeSpan, collection, leaderboardId, Player.Id); board.ReportLocalPlayerScoreUpdate(score, requestId); }
public UM_Score(GK_Score gkScore, GPScore gpScore, GC_Score gcScore) { _GK_Score = gkScore; _GP_Score = gpScore; _GC_Score = gcScore; if (IsValid) { switch (Application.platform) { case RuntimePlatform.Android: if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon) { GC_Player gc_player = SA_AmazonGameCircleManager.Instance.GetPlayerById(_GC_Score.PlayerId); player = new UM_Player(null, null, gc_player); } else { GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(_GP_Score.PlayerId); player = new UM_Player(null, gp_player, null); } break; case RuntimePlatform.IPhonePlayer: GK_Player gk_player = GameCenterManager.GetPlayerById(_GK_Score.PlayerId); player = new UM_Player(gk_player, null, null); break; } } }
public UM_Score GetScore(int rank, UM_TimeSpan scope, UM_CollectionType collection) { UM_Score umScore = null; if (IsValid) { switch (Application.platform) { case RuntimePlatform.Android: GPScore gp = gp_Leaderboard.GetScore(rank, scope.Get_GP_TimeSpan(), collection.Get_GP_CollectionType()); if (gp != null) { umScore = new UM_Score(null, gp); } break; case RuntimePlatform.IPhonePlayer: GK_Score gk = gk_Leaderboard.GetScore(rank, scope.Get_GK_TimeSpan(), collection.Get_GK_CollectionType()); if (gk != null) { umScore = new UM_Score(gk, null); } break; } } return(umScore); }
void HandleOnPlayerScoreLoaded(GK_PlayerScoreLoadedResult result) { if (result.IsSucceeded) { GK_Score score = result.loadedScore; IOSNativePopUpManager.showMessage("Leaderboard " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank); } }
void OnScoreSubmitted(GK_LeaderboardResult result) { if (result.IsSucceeded) { GK_Score score = result.Leaderboard.GetCurrentPlayerScore(GK_TimeSpan.ALL_TIME, GK_CollectionType.GLOBAL); IOSNativePopUpManager.showMessage("Leaderboard " + score.LeaderboardId, "Score: " + score.LongScore + "\n" + "Rank:" + score.Rank); } }
public void UpdateCurrentPlayerScore(GK_Score score) { GK_Score currentScore = GetCurrentPlayerScore(score.TimeSpan, score.Collection); CurrentPlayerScore.Remove(currentScore); CurrentPlayerScore.Add(score); }
private void OnLeaderboardScoreLoaded(CEvent e) { GK_PlayerScoreLoadedResult result = e.data as GK_PlayerScoreLoadedResult; if (result.IsSucceeded) { GK_Score score = result.loadedScore; // IOSNativePopUpManager.showMessage("Leaderboard " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank); } }
public void UpdateCurrentPlayerScore(GK_Score score) { GK_Score currentScore = GetCurrentPlayerScore(score.TimeSpan, score.Collection); if (currentScore != null) { CurrentPlayerScore.Remove(currentScore); } CurrentPlayerScore.Add(score); _CurrentPlayerScoreLoaded = true; }
private void OnLeadrboardInfoLoaded(GK_LeaderboardResult result) { if (result.IsSucceeded) { GK_Score score = result.Leaderboard.GetCurrentPlayerScore(GK_TimeSpan.ALL_TIME, GK_CollectionType.GLOBAL); //IOSNativePopUpManager.showMessage("Leaderboard " + score.LeaderboardId, "Score: " + score.LongScore + "\n" + "Rank:" + score.Rank); Debug.Log("double score representation: " + score.DecimalFloat_2); Debug.Log("long score representation: " + score.LongScore); } }
private void OnPlayerScoreLoaded(GK_PlayerScoreLoadedResult result) { if (result.IsSucceeded) { GK_Score score = result.loadedScore; // IOSNativePopUpManager.showMessage("Leaderboard " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank); // Debug.Log("double score representation: " + score.GetDoubleScore()); // Debug.Log("long score representation: " + score.GetLongScore()); SettingManager.Instance.HighestScore = (int)Mathf.Max(score.GetLongScore(), SettingManager.Instance.HighestScore); } }
public UM_Score(GK_Score gkScore, GPScore gpScore) { _GK_Score = gkScore; _GP_Score = gpScore; if (IsValid) { switch(Application.platform) { case RuntimePlatform.Android: GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(_GP_Score.PlayerId); player = new UM_PlayerTemplate(null, gp_player); break; case RuntimePlatform.IPhonePlayer: GK_Player gk_player = GameCenterManager.GetPlayerById(_GK_Score.PlayerId); player = new UM_PlayerTemplate(gk_player, null); break; } } }
private void onLeaderboardScoreListLoaded(string array) { string[] data; data = array.Split("," [0]); string lbId = data[0]; GK_TimeSpan timeSpan = (GK_TimeSpan)System.Convert.ToInt32(data[1]); GK_CollectionType collection = (GK_CollectionType)System.Convert.ToInt32(data[2]); GK_Leaderboard board; if (_leaderboards.ContainsKey(lbId)) { board = _leaderboards[lbId]; } else { board = new GK_Leaderboard(lbId); _leaderboards.Add(lbId, board); } for (int i = 3; i < data.Length; i += 3) { string playerId = data[i]; string scoreVal = data[i + 1]; int rank = System.Convert.ToInt32(data[i + 2]); GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, lbId, playerId); board.UpdateScore(score); if (Player != null) { if (Player.Id.Equals(playerId)) { board.UpdateCurrentPlayerRank(rank, timeSpan, collection); } } } ISN_Result result = new ISN_Result(true); OnScoresListLoaded(result); Dispatcher.dispatch(GAME_CENTER_LEADERBOARD_SCORE_LIST_LOADED, result); }
private void OnPlayerScoreLoaded(GK_PlayerScoreLoadedResult result) { if (result.IsSucceeded) { GK_Score score = result.loadedScore; IOSNativePopUpManager.showMessage("Leaderboard " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank); Debug.Log("double score representation: " + score.GetDoubleScore()); Debug.Log("long score representation: " + score.GetLongScore()); if (score.leaderboardId.Equals(leaderBoardId2)) { Debug.Log("Updating leaderboard 2 score"); LB2BestScores = score.GetLongScore(); } } }
private void OnLeadrboardInfoLoaded(GK_LeaderboardResult result) { if (result.IsSucceeded) { GK_Score score = result.Leaderboard.GetCurrentPlayerScore(GK_TimeSpan.ALL_TIME, GK_CollectionType.GLOBAL); IOSNativePopUpManager.showMessage("Leaderboard " + score.LeaderboardId, "Score: " + score.LongScore + "\n" + "Rank:" + score.Rank); ISN_Logger.Log("double score representation: " + score.DecimalFloat_2); ISN_Logger.Log("long score representation: " + score.LongScore); if (score.LeaderboardId.Equals(TEST_LEADERBOARD_2)) { ISN_Logger.Log("Updating leaderboard 2 score"); LB2BestScores = score.LongScore; } } }
public void UpdateScore(GK_Score s) { GK_ScoreCollection col = GlobalCollection; switch (s.Collection) { case GK_CollectionType.GLOBAL: col = GlobalCollection; break; case GK_CollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary <int, GK_Score> scoreDict = col.AllTimeScores; switch (s.TimeSpan) { case GK_TimeSpan.ALL_TIME: scoreDict = col.AllTimeScores; break; case GK_TimeSpan.TODAY: scoreDict = col.TodayScores; break; case GK_TimeSpan.WEEK: scoreDict = col.WeekScores; break; } if (scoreDict.ContainsKey(s.Rank)) { scoreDict[s.Rank] = s; } else { scoreDict.Add(s.Rank, s); } }
public UM_Score(GK_Score gkScore, GPScore gpScore) { _GK_Score = gkScore; _GP_Score = gpScore; if (IsValid) { switch (Application.platform) { case RuntimePlatform.Android: GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(_GP_Score.PlayerId); player = new UM_Player(null, gp_player); break; case RuntimePlatform.IPhonePlayer: GK_Player gk_player = GameCenterManager.GetPlayerById(_GK_Score.PlayerId); player = new UM_Player(gk_player, null); break; } } }
private void OnLeaderboardScoreListLoaded(string data) { string[] DataArray = data.Split(new string[] { SA.Common.Data.Converter.DATA_SPLITTER2 }, StringSplitOptions.None); string leaderboardId = DataArray[0]; GK_TimeSpan timeSpan = (GK_TimeSpan)System.Convert.ToInt32(DataArray[1]); GK_CollectionType collection = (GK_CollectionType)System.Convert.ToInt32(DataArray[2]); GK_Leaderboard board = GetLeaderboard(leaderboardId); for (int i = 3; i < DataArray.Length; i += 4) { string playerId = DataArray[i]; long scoreVal = System.Convert.ToInt64(DataArray[i + 1]); int rank = System.Convert.ToInt32(DataArray[i + 2]); int context = System.Convert.ToInt32(DataArray[i + 3]); GK_Score score = new GK_Score(scoreVal, rank, context, timeSpan, collection, leaderboardId, playerId); board.UpdateScore(score); if (Player != null) { if (Player.Id.Equals(playerId)) { board.UpdateCurrentPlayerScore(score); } } } GK_LeaderboardResult result = new GK_LeaderboardResult(board); OnScoresListLoaded(result); }
public UM_Score GetScore(int rank, UM_TimeSpan scope, UM_CollectionType collection) { UM_Score umScore = null; if (IsValid) { switch (Application.platform) { case RuntimePlatform.Android: if (UltimateMobileSettings.Instance.PlatformEngine.Equals(UM_PlatformDependencies.Android)) { GPScore gp = gp_Leaderboard.GetScore(rank, scope.Get_GP_TimeSpan(), collection.Get_GP_CollectionType()); if (gp != null) { umScore = new UM_Score(null, gp, null); } } else { GC_Score gc = gc_Leaderboard.GetScore(rank, scope.Get_GC_TimeSpan()); if (gc != null) { umScore = new UM_Score(null, null, gc); } } break; case RuntimePlatform.IPhonePlayer: GK_Score gk = gk_Leaderboard.GetScore(rank, scope.Get_GK_TimeSpan(), collection.Get_GK_CollectionType()); if (gk != null) { umScore = new UM_Score(gk, null, null); } break; } } return(umScore); }
private void onLeaderboardScore(string array) { string[] data; data = array.Split("," [0]); string lbId = data[0]; string scoreVal = data[1]; int rank = System.Convert.ToInt32(data[2]); GK_TimeSpan timeSpan = (GK_TimeSpan)System.Convert.ToInt32(data[3]); GK_CollectionType collection = (GK_CollectionType)System.Convert.ToInt32(data[4]); GK_Leaderboard board; if (_leaderboards.ContainsKey(lbId)) { board = _leaderboards[lbId]; } else { board = new GK_Leaderboard(lbId); _leaderboards.Add(lbId, board); } GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, lbId, Player.Id); board.UpdateScore(score); board.UpdateCurrentPlayerRank(rank, timeSpan, collection); GK_PlayerScoreLoadedResult result = new GK_PlayerScoreLoadedResult(score); OnPlayerScoreLoaded(result); Dispatcher.dispatch(GAME_CENTER_LEADERBOARD_SCORE_LOADED, result); }
private void OnLoaderBoardInfoRetrived(string data) { string[] DataArray = data.Split(new string[] { IOSNative.DATA_SPLITTER2 }, StringSplitOptions.None); string leaderboardId = DataArray[0]; GK_TimeSpan timeSpan = (GK_TimeSpan) System.Convert.ToInt32(DataArray[1]); GK_CollectionType collection = (GK_CollectionType) System.Convert.ToInt32(DataArray[2]); int requestId = System.Convert.ToInt32(DataArray[3]); long scoreVal = System.Convert.ToInt64(DataArray[4]); int rank = System.Convert.ToInt32(DataArray[5]); int maxRange = System.Convert.ToInt32(DataArray[6]); string title = DataArray[7]; string describtion = DataArray[8]; GK_Leaderboard board = GetLeaderboard(leaderboardId); board.UpdateMaxRange(maxRange); board.Info.Title = title; board.Info.Description = describtion; GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, leaderboardId, Player.Id); board.ReportLocalPlayerScoreUpdate(score, requestId); }
public void UpdateScore(GK_Score s) { GK_ScoreCollection col = GlobalCollection; switch(s.Collection) { case GK_CollectionType.GLOBAL: col = GlobalCollection; break; case GK_CollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary<int, GK_Score> scoreDict = col.AllTimeScores; switch(s.TimeSpan) { case GK_TimeSpan.ALL_TIME: scoreDict = col.AllTimeScores; break; case GK_TimeSpan.TODAY: scoreDict = col.TodayScores; break; case GK_TimeSpan.WEEK: scoreDict = col.WeekScores; break; } if(scoreDict.ContainsKey(s.Rank)) { scoreDict[s.Rank] = s; } else { scoreDict.Add(s.Rank, s); } }
public void ReportLocalPlayerScoreUpdate (GK_Score score, int requestId) { GK_LocalPlayerScoreUpdateListener listener = ScoreUpdateListners[requestId]; listener.ReportScoreUpdate(score); }
//-------------------------------------- // Public Methods //-------------------------------------- public void ReportScoreUpdate(GK_Score score) { Scores.Add(score); DispatchUpdate(); }
void OnGUI() { GUI.Label(new Rect(10, 20, 400, 40), "Custom Leaderboard GUI Example", headerStyle); if (GUI.Button(new Rect(400, 10, 150, 50), "Load Friends Scores")) { GameCenterManager.LoadScore(leaderboardId, 1, 10, GK_TimeSpan.ALL_TIME, GK_CollectionType.FRIENDS); } if (GUI.Button(new Rect(600, 10, 150, 50), "Load Global Scores")) { GameCenterManager.LoadScore(leaderboardId, 50, 150, GK_TimeSpan.ALL_TIME, GK_CollectionType.GLOBAL); } Color defaultColor = GUI.color; if (displayCollection == GK_CollectionType.GLOBAL) { GUI.color = Color.green; } if (GUI.Button(new Rect(800, 10, 170, 50), "Displaying Global Scores")) { displayCollection = GK_CollectionType.GLOBAL; } GUI.color = defaultColor; if (displayCollection == GK_CollectionType.FRIENDS) { GUI.color = Color.green; } if (GUI.Button(new Rect(800, 70, 170, 50), "Displaying Friends Scores")) { displayCollection = GK_CollectionType.FRIENDS; } GUI.color = defaultColor; GUI.Label(new Rect(10, 90, 100, 40), "rank", boardStyle); GUI.Label(new Rect(100, 90, 100, 40), "score", boardStyle); GUI.Label(new Rect(200, 90, 100, 40), "playerId", boardStyle); GUI.Label(new Rect(400, 90, 100, 40), "name ", boardStyle); GUI.Label(new Rect(550, 90, 100, 40), "avatar ", boardStyle); if (loadedLeaderboard != null) { for (int i = 1; i < 10; i++) { GK_Score score = loadedLeaderboard.GetScore(i, GK_TimeSpan.ALL_TIME, displayCollection); if (score != null) { GUI.Label(new Rect(10, 90 + 70 * i, 100, 40), i.ToString(), boardStyle); GUI.Label(new Rect(100, 90 + 70 * i, 100, 40), score.GetLongScore().ToString(), boardStyle); GUI.Label(new Rect(200, 90 + 70 * i, 100, 40), score.playerId, boardStyle); GK_Player player = GameCenterManager.GetPlayerById(score.playerId); if (player != null) { GUI.Label(new Rect(400, 90 + 70 * i, 100, 40), player.Alias, boardStyle); if (player.SmallPhoto != null) { GUI.DrawTexture(new Rect(550, 75 + 70 * i, 50, 50), player.SmallPhoto); } else { GUI.Label(new Rect(550, 90 + 70 * i, 100, 40), "no photo ", boardStyle); } } if (GUI.Button(new Rect(650, 90 + 70 * i, 100, 30), "Challenge")) { GameCenterManager.IssueLeaderboardChallenge(leaderboardId, "Your message here", score.playerId); } } } } }
public void ReportLocalPlayerScoreUpdate(GK_Score score, int requestId) { GK_LocalPlayerScoreUpdateListener listener = ScoreUpdateListners[requestId]; listener.ReportScoreUpdate(score); }
public GK_PlayerScoreLoadedResult(GK_Score score):base(true) { _score = score; }
private void onLeaderboardScoreListLoaded(string array) { string[] data; data = array.Split("," [0]); string lbId = data[0]; GK_TimeSpan timeSpan = (GK_TimeSpan) System.Convert.ToInt32(data[1]); GK_CollectionType collection = (GK_CollectionType) System.Convert.ToInt32(data[2]); GK_Leaderboard board; if(_leaderboards.ContainsKey(lbId)) { board = _leaderboards[lbId]; } else { board = new GK_Leaderboard(lbId); _leaderboards.Add(lbId, board); } for(int i = 3; i < data.Length; i+=3) { string playerId = data[i]; string scoreVal = data[i + 1]; int rank = System.Convert.ToInt32(data[i + 2]); GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, lbId, playerId); board.UpdateScore(score); if(Player != null) { if(Player.Id.Equals(playerId)) { board.UpdateCurrentPlayerRank(rank, timeSpan, collection); } } } ISN_Result result = new ISN_Result (true); OnScoresListLoaded (result); }
public GK_PlayerScoreLoadedResult(GK_Score score) : base(true) { _score = score; }
private void OnLeaderboardScoreListLoaded(string data) { string[] DataArray = data.Split(new string[] { IOSNative.DATA_SPLITTER2 }, StringSplitOptions.None); string leaderboardId = DataArray[0]; GK_TimeSpan timeSpan = (GK_TimeSpan) System.Convert.ToInt32(DataArray[1]); GK_CollectionType collection = (GK_CollectionType) System.Convert.ToInt32(DataArray[2]); GK_Leaderboard board = GetLeaderboard(leaderboardId); for(int i = 3; i < DataArray.Length; i+=3) { string playerId = DataArray[i]; long scoreVal = System.Convert.ToInt64 (DataArray[i + 1]); int rank = System.Convert.ToInt32(DataArray[i + 2]); GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, leaderboardId, playerId); board.UpdateScore(score); if(Player != null) { if(Player.Id.Equals(playerId)) { board.UpdateCurrentPlayerScore(score); } } } GK_LeaderboardResult result = new GK_LeaderboardResult (board); OnScoresListLoaded (result); }
private void onLeaderboardScore(string array) { string[] data; data = array.Split("," [0]); string lbId = data[0]; string scoreVal = data[1]; int rank = System.Convert.ToInt32(data[2]); GK_TimeSpan timeSpan = (GK_TimeSpan) System.Convert.ToInt32(data[3]); GK_CollectionType collection = (GK_CollectionType) System.Convert.ToInt32(data[4]); GK_Leaderboard board; if(_leaderboards.ContainsKey(lbId)) { board = _leaderboards[lbId]; } else { board = new GK_Leaderboard(lbId); _leaderboards.Add(lbId, board); } GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, lbId, Player.Id); board.UpdateScore(score); board.UpdateCurrentPlayerRank(rank, timeSpan, collection); GK_PlayerScoreLoadedResult result = new GK_PlayerScoreLoadedResult (score); OnPlayerScoreLoaded (result); }