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 List<GK_Score> GetScoresList(GK_TimeSpan timeSpan, GK_CollectionType collection) { GK_ScoreCollection col = GlobalCollection; switch(collection) { case GK_CollectionType.GLOBAL: col = GlobalCollection; break; case GK_CollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary<int, GK_Score> scoreDict = col.AllTimeScores; switch(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; } List<GK_Score> scores = new List<GK_Score>(); scores.AddRange(scoreDict.Values); return scores; }
public void UpdateCurrentPlayerRank(int rank, GK_TimeSpan timeSpan, GK_CollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if(currentPlayerRank.ContainsKey(key)) { currentPlayerRank[key] = rank; } else { currentPlayerRank.Add(key, rank); } }
public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if(currentPlayerRank.ContainsKey(key)) { int rank = currentPlayerRank[key]; return GetScore(rank, timeSpan, collection); } else { return null; } }
//-------------------------------------- // Public Methods //-------------------------------------- public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType collection) { foreach(GK_Score score in CurrentPlayerScore) { if(score.TimeSpan == timeSpan && score.Collection == collection) { return score; } } return null; }
public GK_Score(string vScore, int vRank, GK_TimeSpan vTimeSpan, GK_CollectionType sCollection, string lid, string pid) { _score = vScore; _rank = vRank; _playerId = pid; _leaderboardId = lid; _timeSpan = vTimeSpan; _collection = sCollection; }
public GK_Score(long vScore, int vRank, GK_TimeSpan vTimeSpan, GK_CollectionType sCollection, string lid, string pid) { _Score = vScore; _Rank = vRank; _PlayerId = pid; _LeaderboardId = lid; _TimeSpan = vTimeSpan; _Collection = sCollection; }
//-------------------------------------- // Public Methods //-------------------------------------- public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType collection) { foreach (GK_Score score in CurrentPlayerScore) { if (score.TimeSpan == timeSpan && score.Collection == collection) { return(score); } } return(null); }
public static UM_CollectionType Get_UM_Collection(this GK_CollectionType type) { switch (type) { case GK_CollectionType.GLOBAL: return(UM_CollectionType.GLOBAL); case GK_CollectionType.FRIENDS: return(UM_CollectionType.FRIENDS); default: return(UM_CollectionType.GLOBAL); } }
public void UpdateCurrentPlayerRank(int rank, GK_TimeSpan timeSpan, GK_CollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if (currentPlayerRank.ContainsKey(key)) { currentPlayerRank[key] = rank; } else { currentPlayerRank.Add(key, rank); } }
public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if (currentPlayerRank.ContainsKey(key)) { int rank = currentPlayerRank[key]; return(GetScore(rank, timeSpan, collection)); } else { return(null); } }
public GK_Score GetScoreByPlayerId(string playerId, GK_TimeSpan timeSpan, GK_CollectionType collection) { if(playerId.Equals(GameCenterManager.Player.Id)) { return GetCurrentPlayerScore(timeSpan, collection); } List<GK_Score> scores = GetScoresList(timeSpan, collection); foreach(GK_Score s in scores) { if(s.PlayerId.Equals(playerId)) { return s; } } return null; }
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); }
public GK_Score GetScore(int rank, GK_TimeSpan scope, GK_CollectionType collection) { GK_ScoreCollection col = GlobalCollection; switch (collection) { case GK_CollectionType.GLOBAL: col = GlobalCollection; break; case GK_CollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary <int, GK_Score> scoreDict = col.AllTimeScores; switch (scope) { 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(rank)) { return(scoreDict[rank]); } else { return(null); } }
public GK_Score GetScoreByPlayerId(string playerId, GK_TimeSpan timeSpan, GK_CollectionType collection) { if (playerId.Equals(GameCenterManager.Player.Id)) { return(GetCurrentPlayerScore(timeSpan, collection)); } List <GK_Score> scores = GetScoresList(timeSpan, collection); foreach (GK_Score s in scores) { if (s.PlayerId.Equals(playerId)) { return(s); } } return(null); }
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 List <GK_Score> GetScoresList(GK_TimeSpan timeSpan, GK_CollectionType collection) { GK_ScoreCollection col = GlobalCollection; switch (collection) { case GK_CollectionType.GLOBAL: col = GlobalCollection; break; case GK_CollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary <int, GK_Score> scoreDict = col.AllTimeScores; switch (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; } List <GK_Score> scores = new List <GK_Score>(); scores.AddRange(scoreDict.Values); return(scores); }
public GK_Score GetScore(int rank, GK_TimeSpan scope, GK_CollectionType collection) { GK_ScoreCollection col = GlobalCollection; switch(collection) { case GK_CollectionType.GLOBAL: col = GlobalCollection; break; case GK_CollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary<int, GK_Score> scoreDict = col.AllTimeScores; switch(scope) { 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(rank)) { return scoreDict[rank]; } else { return null; } }
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); }
public static void LoadScore(string leaderboardId, int from, int to, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE _loadLeaderboardScore(leaderboardId, (int) timeSpan, (int) collection, from, to); #endif }
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); } } } } }
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, 1, 10, GK_TimeSpan.ALL_TIME, GK_CollectionType.FRIENDS); } if(GUI.Button(new Rect(600, 10, 150, 50), "Load Global Scores")) { GameCenterManager.LoadScore(leaderboardId_1, 1, 20, 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.LongScore.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_1, "Your message here", score.PlayerId); } } } } }
private IEnumerator LoadCurrentPlayerScoreLocal(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL ) { yield return new WaitForSeconds(4f); LoadCurrentPlayerScore(leaderboardId, timeSpan, collection); }
public static void LoadCurrentPlayerScore(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { LoadLeaderboardInfo(leaderboardId); }
public static void LoadScore(string leaderboardId, int startIndex, int length, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { #if ((UNITY_IPHONE || UNITY_TVOS) && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE _ISN_loadLeaderboardScore(leaderboardId, (int)timeSpan, (int)collection, startIndex, length); #endif }
public static void LoadCurrentPlayerScore(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE _getLeaderboardScore(leaderboardId, (int)timeSpan, (int)collection); #endif }
private IEnumerator LoadCurrentPlayerScoreLocal(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { yield return(new WaitForSeconds(4f)); LoadCurrentPlayerScore(leaderboardId, timeSpan, collection); }
public static void LoadScore(string leaderboardId, int from, int to, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE _loadLeaderboardScore(leaderboardId, (int)timeSpan, (int)collection, from, to); #endif }
public static void LoadScore(string leaderboardId, int startIndex, int length, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { #if (UNITY_IPHONE && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE _ISN_loadLeaderboardScore(leaderboardId, (int) timeSpan, (int) collection, startIndex, length); #endif }
public static void LoadCurrentPlayerScore(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) { #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE _getLeaderboardScore(leaderboardId, (int) timeSpan, (int) collection); #endif }