//-------------------------------------- // INITIALIZATION //-------------------------------------- public void UpdateScores(string ID) { this.LEADERBOARD_ID = ID; displayCollection = GPCollectionType.GLOBAL; //ここで回転を始める。 StartWait(); //Same events, one with C# actions, one with FLE GooglePlayManager.ActionScoresListLoaded += ActionScoreRequestReceived; if (GooglePlayConnection.State == GPConnectionState.STATE_CONNECTED) { //checking if player already connected if (GooglePlayManager.Instance.player.icon != null) { PlayerIconTexture = GooglePlayManager.Instance.player.icon; } else { //プレイヤのテクスチャをデフォルトにする PlayerIconTexture = null; } home.stats.SetPlayerTex(PlayerIconTexture); LoadScore(); } else { //コネクトされていない OnNoData(); home.OnScoreLoaded(); } }
public GPScore GetScore(int rank, GPBoardTimeSpan timeSpan, GPCollectionType collection) { GPScoreCollection col = GlobalCollection; switch(collection) { case GPCollectionType.GLOBAL: col = GlobalCollection; break; case GPCollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary<int, GPScore> scoreDict = col.AllTimeScores; switch(timeSpan) { case GPBoardTimeSpan.ALL_TIME: scoreDict = col.AllTimeScores; break; case GPBoardTimeSpan.TODAY: scoreDict = col.TodayScores; break; case GPBoardTimeSpan.WEEK: scoreDict = col.WeekScores; break; } if(scoreDict.ContainsKey(rank)) { return scoreDict[rank]; } else { return null; } }
//-------------------------------------- // METHODS //-------------------------------------- public void LoadScore() { GPBoardTimeSpan displayTime = GPBoardTimeSpan.ALL_TIME; GPCollectionType displayCollection = GPCollectionType.FRIENDS; GooglePlayManager.instance.LoadPlayerCenteredScores(LEADERBOARD_ID, displayTime, displayCollection, 10); }
public List<GPScore> GetScoresList(GPBoardTimeSpan timeSpan, GPCollectionType collection) { GPScoreCollection col = GlobalCollection; switch(collection) { case GPCollectionType.GLOBAL: col = GlobalCollection; break; case GPCollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary<int, GPScore> scoreDict = col.AllTimeScores; switch(timeSpan) { case GPBoardTimeSpan.ALL_TIME: scoreDict = col.AllTimeScores; break; case GPBoardTimeSpan.TODAY: scoreDict = col.TodayScores; break; case GPBoardTimeSpan.WEEK: scoreDict = col.WeekScores; break; } List<GPScore> scores = new List<GPScore>(); scores.AddRange(scoreDict.Values); return scores; }
public void LoadTopScores(string leaderboardId, GPBoardTimeSpan span, GPCollectionType collection, int maxResults) { if (!GooglePlayConnection.CheckState()) { return; } AN_GMSGeneralProxy.loadTopScores(leaderboardId, (int)span, (int)collection, maxResults); }
public void UpdatePlayerScore(string leaderboardId, GPBoardTimeSpan span, GPCollectionType collection) { if (!GooglePlayConnection.CheckState()) { return; } AN_GMSGeneralProxy.UpdatePlayerScore(leaderboardId, (int)span, (int)collection); }
public override void Reset() { LeaderboardId = null; Timespan = GPBoardTimeSpan.ALL_TIME; Collection = GPCollectionType.GLOBAL; Score = null; Rank = null; }
//-------------------------------------- // INITIALIZE //-------------------------------------- public LeaderBoardScoreVariant(string vScore, string vRank, string vTimeSpan, string sCollection) { _score = System.Convert.ToInt32(vScore); _rank = System.Convert.ToInt32(vRank); _timeSpan = PlayServiceUtil.GetTimeSpanByInt(System.Convert.ToInt32(vTimeSpan)); _collection = PlayServiceUtil.GetCollectionTypeByInt(System.Convert.ToInt32(sCollection)); }
public GPScore GetScoreByPlayerId(string playerId, GPBoardTimeSpan timeSpan, GPCollectionType collection) { List<GPScore> scores = GetScoresList(timeSpan, collection); foreach(GPScore s in scores) { if(s.playerId.Equals(playerId)) { return s; } } return null; }
public GPScore GetCurrentPlayerScore(GPBoardTimeSpan timeSpan, GPCollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if(currentPlayerRank.ContainsKey(key)) { int rank = currentPlayerRank[key]; return GetScore(rank, timeSpan, collection); } else { return null; } }
public GPScore GetCurrentPlayerScore(GPBoardTimeSpan timeSpan, GPCollectionType collection) { foreach (GPScore score in CurrentPlayerScore) { if (score.TimeSpan == timeSpan && score.Collection == collection) { return(score); } } return(null); }
public int GetRank(GPCollectionType collection, GPBoardTimeSpan timeSpan) { foreach (LeaderBoardScoreVariant variant in _scores) { if (variant.collection == collection && variant.timeSpan == timeSpan) { return(variant.rank); } } return(-1); }
public LeaderBoardScoreVariant GetVariant(GPCollectionType collection, GPBoardTimeSpan timeSpan) { foreach (LeaderBoardScoreVariant variant in _scores) { if (variant.collection == collection && variant.timeSpan == timeSpan) { return(variant); } } return(null); }
//-------------------------------------- // INITIALIZE //-------------------------------------- public GPScore(int vScore, int vRank, GPBoardTimeSpan vTimeSpan, GPCollectionType sCollection, string lid, string pid) { _score = vScore; _rank = vRank; _playerId = pid; _leaderboardId = lid; _timeSpan = vTimeSpan; _collection = sCollection; }
//-------------------------------------- // INITIALIZE //-------------------------------------- public GPScore(long vScore, int vRank, GPBoardTimeSpan vTimeSpan, GPCollectionType sCollection, string lid, string pid) { _score = vScore; _rank = vRank; _playerId = pid; _leaderboardId = lid; _timeSpan = vTimeSpan; _collection = sCollection; }
public static UM_CollectionType Get_UM_Collection(this GPCollectionType type) { switch (type) { case GPCollectionType.GLOBAL: return(UM_CollectionType.GLOBAL); case GPCollectionType.FRIENDS: return(UM_CollectionType.FRIENDS); default: return(UM_CollectionType.GLOBAL); } }
public void UpdateCurrentPlayerRank(int rank, GPBoardTimeSpan timeSpan, GPCollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if (currentPlayerRank.ContainsKey(key)) { currentPlayerRank[key] = rank; } else { currentPlayerRank.Add(key, rank); } }
public GPScore GetCurrentPlayerScore(GPBoardTimeSpan timeSpan, GPCollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if (currentPlayerRank.ContainsKey(key)) { int rank = currentPlayerRank[key]; return(GetScore(rank, timeSpan, collection)); } else { return(null); } }
public GPScore GetScoreByPlayerId(string playerId, GPBoardTimeSpan timeSpan, GPCollectionType collection) { List <GPScore> scores = GetScoresList(timeSpan, collection); foreach (GPScore s in scores) { if (s.PlayerId.Equals(playerId)) { return(s); } } return(null); }
private void OnLeaderboardDataLoaded(string data) { Debug.Log("OnLeaderboardDataLoaded " + data); string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GooglePlayResult result = new GooglePlayResult(storeData [0]); if (result.IsSucceeded) { for (int i = 1; i < storeData.Length; i += 32) { if (storeData[i] == AndroidNative.DATA_EOF) { break; } string leaderboardId = storeData[i]; string leaderboardName = storeData [i + 1]; GPLeaderBoard lb = GetLeaderBoard(leaderboardId); lb.UpdateName(leaderboardName); int start = i + 2; for (int j = 0; j < 6; j++) { long score = System.Convert.ToInt64(storeData[start]); int rank = System.Convert.ToInt32(storeData[start + 1]); GPBoardTimeSpan timeSpan = (GPBoardTimeSpan)System.Convert.ToInt32(storeData[start + 2]); GPCollectionType collection = (GPCollectionType)System.Convert.ToInt32(storeData[start + 3]); string tag = storeData[start + 4]; //Debug.Log("timeSpan: " + timeSpan + " collection: " + collection + " score:" + score + " rank:" + rank); GPScore s = new GPScore(score, rank, timeSpan, collection, lb.Id, player.playerId, tag); start = start + 5; lb.UpdateScore(s); lb.UpdateCurrentPlayerScore(s); } } Debug.Log("Loaded: " + LeaderBoards.Count + " Leaderboards"); } _IsLeaderboardsDataLoaded = true; ActionLeaderboardsLoaded(result); }
private void OnScoreDataRecevied(string data) { Debug.Log("OnScoreDataRecevide"); string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GP_LeaderboardResult result = new GP_LeaderboardResult(null, storeData[0]); if (result.IsSucceeded) { GPBoardTimeSpan timeSpan = (GPBoardTimeSpan)System.Convert.ToInt32(storeData[1]); GPCollectionType collection = (GPCollectionType)System.Convert.ToInt32(storeData[2]); string leaderboardId = storeData[3]; string leaderboardName = storeData[4]; GPLeaderBoard lb = GetLeaderBoard(leaderboardId); lb.UpdateName(leaderboardName); result = new GP_LeaderboardResult(lb, storeData [0]); for (int i = 5; i < storeData.Length; i += 8) { if (storeData[i] == AndroidNative.DATA_EOF) { break; } long score = System.Convert.ToInt64(storeData[i]); int rank = System.Convert.ToInt32(storeData[i + 1]); string playerId = storeData[i + 2]; if (!players.ContainsKey(playerId)) { GooglePlayerTemplate p = new GooglePlayerTemplate(playerId, storeData[i + 3], storeData[i + 4], storeData[i + 5], storeData[i + 6], storeData[i + 7]); AddPlayer(p); } GPScore s = new GPScore(score, rank, timeSpan, collection, lb.Id, playerId); lb.UpdateScore(s); if (playerId.Equals(player.playerId)) { lb.UpdateCurrentPlayerScore(s); } } } ActionScoresListLoaded(result); }
private void OnPlayerScoreUpdated(string data) { if (data.Equals(string.Empty)) { Debug.Log("GooglePlayManager OnPlayerScoreUpdated, no data avaiable"); return; } Debug.Log("OnPlayerScoreUpdated"); string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GP_GamesResult result = new GP_GamesResult(storeData [0]); if (result.isSuccess) { GPBoardTimeSpan timeSpan = (GPBoardTimeSpan)System.Convert.ToInt32(storeData[1]); GPCollectionType collection = (GPCollectionType)System.Convert.ToInt32(storeData[2]); string leaderboardId = storeData[3]; long score = System.Convert.ToInt64(storeData[4]); int rank = System.Convert.ToInt32(storeData[5]); GPLeaderBoard lb; if (_leaderBoards.ContainsKey(leaderboardId)) { lb = _leaderBoards[leaderboardId]; } else { lb = new GPLeaderBoard(leaderboardId, ""); _leaderBoards.Add(leaderboardId, lb); } GPScore variant = new GPScore(score, rank, timeSpan, collection, lb.id, player.playerId); lb.UpdateScore(variant); lb.UpdateCurrentPlayerRank(rank, timeSpan, collection); } ActionPlayerScoreUpdated(result); dispatch(SCORE_UPDATED, result); }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- public GPScore GetScore(int rank, GPBoardTimeSpan timeSpan, GPCollectionType collection) { GPScoreCollection col = GlobalCollection; switch (collection) { case GPCollectionType.GLOBAL: col = GlobalCollection; break; case GPCollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary <int, GPScore> scoreDict = col.AllTimeScores; switch (timeSpan) { case GPBoardTimeSpan.ALL_TIME: scoreDict = col.AllTimeScores; break; case GPBoardTimeSpan.TODAY: scoreDict = col.TodayScores; break; case GPBoardTimeSpan.WEEK: scoreDict = col.WeekScores; break; } if (scoreDict.ContainsKey(rank)) { return(scoreDict[rank]); } else { return(null); } }
//-------------------------------------- // INITIALIZATION //-------------------------------------- public void UpdateScores(string ID) { this.LEADERBOARD_ID = ID; displayCollection = GPCollectionType.GLOBAL; //ここで回転を始める。 StartWait(); //Same events, one with C# actions, one with FLE GooglePlayManager.ActionScoresListLoaded += ActionScoreRequestReceived; if (GooglePlayConnection.State == GPConnectionState.STATE_CONNECTED) { //checking if player already connected LoadScore(); } else { //コネクトされていない OnNoData(); } }
public List <GPScore> GetScoresList(GPBoardTimeSpan timeSpan, GPCollectionType collection) { GPScoreCollection col = GlobalCollection; switch (collection) { case GPCollectionType.GLOBAL: col = GlobalCollection; break; case GPCollectionType.FRIENDS: col = SocsialCollection; break; } Dictionary <int, GPScore> scoreDict = col.AllTimeScores; switch (timeSpan) { case GPBoardTimeSpan.ALL_TIME: scoreDict = col.AllTimeScores; break; case GPBoardTimeSpan.TODAY: scoreDict = col.TodayScores; break; case GPBoardTimeSpan.WEEK: scoreDict = col.WeekScores; break; } List <GPScore> scores = new List <GPScore>(); scores.AddRange(scoreDict.Values); return(scores); }
private void OnPlayerScoreUpdated(string data) { if (data.Equals(string.Empty)) { Debug.Log("GooglePlayManager OnPlayerScoreUpdated, no data avaiable"); return; } Debug.Log("OnPlayerScoreUpdated " + data); string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GP_ScoreResult result = new GP_ScoreResult(storeData [0]); string leaderboardId = storeData[1]; int requestId = System.Convert.ToInt32(storeData[2]); GPLeaderBoard lb = GetLeaderBoard(leaderboardId); if (result.IsSucceeded) { GPBoardTimeSpan timeSpan = (GPBoardTimeSpan)System.Convert.ToInt32(storeData[3]); GPCollectionType collection = (GPCollectionType)System.Convert.ToInt32(storeData[4]); long score = System.Convert.ToInt64(storeData[5]); int rank = System.Convert.ToInt32(storeData[6]); string tag = storeData [7]; GPScore s = new GPScore(score, rank, timeSpan, collection, lb.Id, player.playerId, tag); result.score = s; lb.ReportLocalPlayerScoreUpdate(s, requestId); } else { lb.ReportLocalPlayerScoreUpdateFail(storeData[0], requestId); } }
public void ShowLocal() { displayCollection = GPCollectionType.FRIENDS; UpdateScoresDisaplay(); }
public void ShowGlobal() { displayCollection = GPCollectionType.GLOBAL; }
private void OnScoreDataRecevied(string data) { Debug.Log("OnScoreDataRecevide"); string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GooglePlayResult result = new GooglePlayResult(storeData [0]); if (result.isSuccess) { GPBoardTimeSpan timeSpan = (GPBoardTimeSpan)System.Convert.ToInt32(storeData[1]); GPCollectionType collection = (GPCollectionType)System.Convert.ToInt32(storeData[2]); string leaderboardId = storeData[3]; string leaderboardName = storeData[4]; GPLeaderBoard lb; if (_leaderBoards.ContainsKey(leaderboardId)) { lb = _leaderBoards[leaderboardId]; } else { lb = new GPLeaderBoard(leaderboardId, leaderboardName); Debug.Log("Added: " + leaderboardId); _leaderBoards.Add(leaderboardId, lb); } lb.UpdateName(leaderboardName); for (int i = 5; i < storeData.Length; i += 8) { if (storeData[i] == AndroidNative.DATA_EOF) { break; } long score = System.Convert.ToInt64(storeData[i]); int rank = System.Convert.ToInt32(storeData[i + 1]); string playerId = storeData[i + 2]; if (!players.ContainsKey(playerId)) { GooglePlayerTemplate p = new GooglePlayerTemplate(playerId, storeData[i + 3], storeData[i + 4], storeData[i + 5], storeData[i + 6], storeData[i + 7]); AddPlayer(p); } GPScore s = new GPScore(score, rank, timeSpan, collection, lb.id, playerId); lb.UpdateScore(s); if (playerId.Equals(player.playerId)) { lb.UpdateCurrentPlayerRank(rank, timeSpan, collection); } } } ActionScoreRequestReceived(result); dispatch(SCORE_REQUEST_RECEIVED, result); }
public GPScore GetCurrentPlayerScore(GPBoardTimeSpan timeSpan, GPCollectionType collection) { foreach (GPScore score in CurrentPlayerScore) { if (score.TimeSpan == timeSpan && score.Collection == collection) { return score; } } return null; }
public void ShowLocal() { displayCollection = GPCollectionType.FRIENDS; }
private void OnLeaderboardDataLoaded(string data) { Debug.Log("OnLeaderboardDataLoaded"); string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GooglePlayResult result = new GooglePlayResult(storeData [0]); if (result.isSuccess) { for (int i = 1; i < storeData.Length; i += 26) { if (storeData[i] == AndroidNative.DATA_EOF) { break; } string leaderboardId = storeData[i]; string leaderboardName = storeData [i + 1]; GPLeaderBoard lb; if (_leaderBoards.ContainsKey(leaderboardId)) { lb = _leaderBoards[leaderboardId]; } else { lb = new GPLeaderBoard(leaderboardId, leaderboardName); _leaderBoards.Add(leaderboardId, lb); } lb.UpdateName(leaderboardName); int start = i + 2; for (int j = 0; j < 6; j++) { long score = System.Convert.ToInt64(storeData[start]); int rank = System.Convert.ToInt32(storeData[start + 1]); GPBoardTimeSpan timeSpan = (GPBoardTimeSpan)System.Convert.ToInt32(storeData[start + 2]); GPCollectionType collection = (GPCollectionType)System.Convert.ToInt32(storeData[start + 3]); //Debug.Log("timeSpan: " + timeSpan + " collection: " + collection + " score:" + score + " rank:" + rank); GPScore variant = new GPScore(score, rank, timeSpan, collection, lb.id, player.playerId); start = start + 4; lb.UpdateScore(variant); lb.UpdateCurrentPlayerRank(rank, timeSpan, collection); } } Debug.Log("Loaded: " + _leaderBoards.Count + " Leaderboards"); } _IsLeaderboardsDataLoaded = true; ActionLeaderboardsLoaded(result); dispatch(LEADERBOARDS_LOADED, result); }
public void loadTopScores(string leaderboardId, GPBoardTimeSpan span, GPCollectionType collection, int maxResults) { LoadTopScores(leaderboardId, span, collection, maxResults); }
//-------------------------------------- // INITIALIZATION //-------------------------------------- void Start() { playerLabel.text = "Player Disconnected"; defaulttexture = avatar.sprite; SA_StatusBar.text = "Custom Leader-board example scene loaded"; foreach (LeaderboardInfoPresenter line in lines) { line.Disable(); } //listen for GooglePlayConnection events GooglePlayConnection.ActionPlayerConnected += OnPlayerConnected; GooglePlayConnection.ActionPlayerDisconnected += OnPlayerDisconnected; GooglePlayConnection.ActionConnectionResultReceived += OnConnectionResult; GooglePlayManager.ActionScoreSubmited += OnScoreSbumitted; //Same events, one with C# actions, one with FLE GooglePlayManager.ActionScoresListLoaded += ActionScoreRequestReceived; if (GooglePlayConnection.State == GPConnectionState.STATE_CONNECTED) { //checking if player already connected OnPlayerConnected(); } GlobalButton.onValueChanged.AddListener((b) => { if (b) { displayCollection = GPCollectionType.GLOBAL; UpdateScoresDisaplay(); } }); FriendsButton.onValueChanged.AddListener((b) => { if (b) { displayCollection = GPCollectionType.FRIENDS; UpdateScoresDisaplay(); } }); AllTimeButton.onValueChanged.AddListener((b) => { if (b) { displayTime = GPBoardTimeSpan.ALL_TIME; UpdateScoresDisaplay(); } }); WeekButton.onValueChanged.AddListener((b) => { if (b) { displayTime = GPBoardTimeSpan.WEEK; UpdateScoresDisaplay(); } }); TodayButton.onValueChanged.AddListener((b) => { if (b) { displayTime = GPBoardTimeSpan.TODAY; UpdateScoresDisaplay(); } }); }
public void ShowGlobal() { displayCollection = GPCollectionType.GLOBAL; UpdateScoresDisaplay(); }
public void ShowFriend() { displayCollection = GPCollectionType.FRIENDS; StartWait(); UpdateScoresDisaplay(); }
public void ShowGlobal() { displayCollection = GPCollectionType.GLOBAL; StartWait(); UpdateScoresDisaplay(); }
public void UpdateCurrentPlayerRank(int rank, GPBoardTimeSpan timeSpan, GPCollectionType collection) { string key = timeSpan.ToString() + "_" + collection.ToString(); if(currentPlayerRank.ContainsKey(key)) { currentPlayerRank[key] = rank; } else { currentPlayerRank.Add(key, rank); } }