Beispiel #1
0
    public long GetCurrentPlayerScore(UM_Leaderboard leaderboard)
    {
        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            GCLeaderboard board = GameCenterManager.GetLeaderboard(leaderboard.IOSId);
            if (board != null)
            {
                GCScore score = board.GetCurrentPlayerScore(GCBoardTimeSpan.ALL_TIME, GCCollectionType.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);
    }
    //--------------------------------------
    // UNITY
    //--------------------------------------

    void UpdateScoresDisaplay()
    {
        if (loadedLeaderBoard != null)
        {
            //Getting current player score
            int displayRank;

            GPScore currentPlayerScore = loadedLeaderBoard.GetCurrentPlayerScore(displayTime, displayCollection);
            if (currentPlayerScore == null)
            {
                //Player does not have rank at this collection / time
                //so let's show the top score
                //since we used loadPlayerCenteredScores function. we should have top scores loaded if player have no scores at this collection / time
                //https://developer.android.com/reference/com/google/android/gms/games/leaderboard/Leaderboards.html#loadPlayerCenteredScores(com.google.android.gms.common.api.GoogleApiClient, java.lang.String, int, int, int)
                //Asynchronously load the player-centered page of scores for a given leaderboard. If the player does not have a score on this leaderboard, this call will return the top page instead.
                displayRank = 1;
            }
            else
            {
                //Let's show 5 results before curent player Rank
                displayRank = Mathf.Clamp(currentPlayerScore.Rank - 5, 1, currentPlayerScore.Rank);

                //let's check if displayRank we what to display before player score is exists
                while (loadedLeaderBoard.GetScore(displayRank, displayTime, displayCollection) == null)
                {
                    displayRank++;
                }
            }

            Debug.Log("Start Display at rank: " + displayRank);

            int i = displayRank;
            foreach (LeaderboardInfoPresenter line in lines)
            {
                GPScore score = loadedLeaderBoard.GetScore(i, displayTime, displayCollection);
                if (score != null)
                {
                    GooglePlayerTemplate player = GooglePlayManager.Instance.GetPlayerById(score.PlayerId);
                    line.SetInfo(i.ToString(),
                                 score.LongScore.ToString(),
                                 score.PlayerId,
                                 player != null ? player.name : "[Empty]",
                                 player != null && player.hasIconImage ? player.icon : defaulttexture.texture);
                }
                else
                {
                    line.Disable();
                }

                i++;
            }
        }
        else
        {
            foreach (LeaderboardInfoPresenter line in lines)
            {
                line.Disable();
            }
        }
    }
Beispiel #3
0
    private void ActionScoreRequestReceived(GooglePlayResult obj)
    {
        SA_StatusBar.text = "Scores Load Finished";

        loadedLeaderBoard = GooglePlayManager.instance.GetLeaderBoard(LEADERBOARD_ID);


        if (loadedLeaderBoard == null)
        {
            Debug.Log("No Leaderboard found");
            return;
        }

        List <GPScore> scoresLB = loadedLeaderBoard.GetScoresList(GPBoardTimeSpan.ALL_TIME, GPCollectionType.GLOBAL);

        foreach (GPScore score in scoresLB)
        {
            Debug.Log("OnScoreUpdated " + score.rank + " " + score.playerId + " " + score.score);
        }

        GPScore currentPlayerScore = loadedLeaderBoard.GetCurrentPlayerScore(displayTime, displayCollection);

        Debug.Log("currentPlayerScore: " + currentPlayerScore.score + " rank:" + currentPlayerScore.rank);


        UpdateScoresDisaplay();
    }
Beispiel #4
0
    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);
    }
Beispiel #6
0
    public void UpdateCurrentPlayerScore(GPScore score)
    {
        GPScore currentScore = GetCurrentPlayerScore(score.TimeSpan, score.Collection);

        CurrentPlayerScore.Remove(currentScore);

        CurrentPlayerScore.Add(score);
    }
    public void UpdateCurrentPlayerScore(GPScore score)
    {
        GPScore currentScore = GetCurrentPlayerScore(score.TimeSpan, score.Collection);

        if (currentScore != null)
        {
            CurrentPlayerScore.Remove(currentScore);
        }
        CurrentPlayerScore.Add(score);
        _CurrentPlayerScoreLoaded = true;
    }
    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);
    }
Beispiel #9
0
    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);
    }
Beispiel #10
0
	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;
			}
		}
	}
Beispiel #11
0
    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 void UpdateScore(GPScore score)
    {
        GPScoreCollection col = GlobalCollection;

        switch (score.collection)
        {
        case GPCollectionType.GLOBAL:
            col = GlobalCollection;
            break;

        case GPCollectionType.FRIENDS:
            col = SocsialCollection;
            break;
        }


        Dictionary <int, GPScore> scoreDict = col.AllTimeScores;

        switch (score.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(score.rank))
        {
            scoreDict[score.rank] = score;
        }
        else
        {
            scoreDict.Add(score.rank, score);
        }
    }
Beispiel #13
0
    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 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 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 UpdateBoardInfo()
    {
        GPLeaderBoard leaderboard = GooglePlayManager.Instance.GetLeaderBoard(LEADERBOARD_ID);

        if (leaderboard != null)
        {
            b_id.text   = "Id: " + leaderboard.Id;
            b_name.text = "Name: " + leaderboard.Name;

            GPScore score = leaderboard.GetCurrentPlayerScore(GPBoardTimeSpan.ALL_TIME, GPCollectionType.FRIENDS);
            if (score != null)
            {
                b_all_time.text = "All Time Score: " + score.LongScore;
            }
            else
            {
                b_all_time.text = "All Time Score: EMPTY";
            }
        }
        else
        {
            b_all_time.text = "All Time Score: " + " -1";
        }
    }
	//--------------------------------------
	// Public Methods
	//--------------------------------------
	
	public void ReportScoreUpdate(GPScore score) {
		Scores.Add(score);
		DispatchUpdate();
	}
	public void UpdateScore(GPScore score) {
	
		GPScoreCollection col = GlobalCollection;
		
		switch(score.collection) {
		case GPCollectionType.GLOBAL:
			col = GlobalCollection;
			break;
		case GPCollectionType.FRIENDS:
			col = SocsialCollection;
			break;
		}

		
		Dictionary<int, GPScore> scoreDict = col.AllTimeScores;
		
		switch(score.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(score.rank)) {
			scoreDict[score.rank] = score;
		} else {
			scoreDict.Add(score.rank, score);
		}

	}
Beispiel #19
0
    public void ReportLocalPlayerScoreUpdate(GPScore score, int requestId)
    {
        GP_LocalPlayerScoreUpdateListener listener = _ScoreUpdateListners[requestId];

        listener.ReportScoreUpdate(score);
    }
Beispiel #20
0
    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);
    }
Beispiel #21
0
    //--------------------------------------
    // UNITY
    //--------------------------------------

    void Update()
    {
        if (loadedLeaderBoard != null)
        {
            //Getting current player score
            int displayRank;

            GPScore currentPlayerScore = loadedLeaderBoard.GetCurrentPlayerScore(displayTime, displayCollection);
            if (currentPlayerScore == null)
            {
                //Player does not have rank at this collection / time
                //so let's show the top score
                //since we used loadPlayerCenteredScores function. we should have top scores loaded if player have no scores at this collection / time
                //https://developer.android.com/reference/com/google/android/gms/games/leaderboard/Leaderboards.html#loadPlayerCenteredScores(com.google.android.gms.common.api.GoogleApiClient, java.lang.String, int, int, int)
                //Asynchronously load the player-centered page of scores for a given leaderboard. If the player does not have a score on this leaderboard, this call will return the top page instead.
                displayRank = 1;
            }
            else
            {
                //Let's show 5 results before curent player Rank
                displayRank = Mathf.Clamp(currentPlayerScore.rank - 5, 1, currentPlayerScore.rank);

                //let's check if dosplayRank we what to display before player score is exists
                while (loadedLeaderBoard.GetScore(displayRank, displayTime, displayCollection) == null)
                {
                    displayRank++;
                }
            }



            int i = 1;
            foreach (CustomLeaderboardFiledsHolder line in lines)
            {
                line.Disable();

                GPScore score = loadedLeaderBoard.GetScore(i, displayTime, displayCollection);
                if (score != null)
                {
                    line.rank.text     = i.ToString();
                    line.score.text    = score.score.ToString();
                    line.playerId.text = score.playerId;

                    GooglePlayerTemplate player = GooglePlayManager.instance.GetPlayerById(score.playerId);
                    if (player != null)
                    {
                        line.playerName.text = player.name;
                        if (player.hasIconImage)
                        {
                            line.avatar.GetComponent <Renderer>().material.mainTexture = player.icon;
                        }
                        else
                        {
                            line.avatar.GetComponent <Renderer>().material.mainTexture = defaulttexture;
                        }
                    }
                    else
                    {
                        line.playerName.text = "--";
                        line.avatar.GetComponent <Renderer>().material.mainTexture = defaulttexture;
                    }
                    line.avatar.GetComponent <Renderer>().enabled = true;
                }
                else
                {
                    line.Disable();
                }

                i++;
            }
        }
        else
        {
            foreach (CustomLeaderboardFiledsHolder line in lines)
            {
                line.Disable();
            }
        }
    }
Beispiel #22
0
	public void UpdateCurrentPlayerScore(GPScore score) {		
		GPScore currentScore = GetCurrentPlayerScore(score.TimeSpan, score.Collection);
		CurrentPlayerScore.Remove(currentScore);		
		
		CurrentPlayerScore.Add(score);		
	}
Beispiel #23
0
    //--------------------------------------
    // UNITY
    //--------------------------------------

    void UpdateScoresDisaplay()
    {
        if (loadedLeaderBoard != null)
        {
            //Getting current player score
            int displayRank;

            GPScore currentPlayerScore = loadedLeaderBoard.GetCurrentPlayerScore(displayTime, displayCollection);


            if (currentPlayerScore == null)
            {
                //Player does not have rank at this collection / time
                //so let's show the top score
                //since we used loadPlayerCenteredScores function. we should have top scores loaded if player have no scores at this collection / time
                //https://developer.android.com/reference/com/google/android/gms/games/leaderboard/Leaderboards.html#loadPlayerCenteredScores(com.google.android.gms.common.api.GoogleApiClient, java.lang.String, int, int, int)
                //Asynchronously load the player-centered page of scores for a given leaderboard. If the player does not have a score on this leaderboard, this call will return the top page instead.
                displayRank = 1;
                lines[5].OnNoData();
            }
            else
            {
                //Let's show 5 results before curent player Rank
                displayRank = Mathf.Clamp(currentPlayerScore.Rank - 5, 1, currentPlayerScore.Rank);
                lines[5].Set(currentPlayerScore.Rank, currentPlayerScore.LongScore, GPGSListener.Instance.userName_string, defaultTexture);
                //let's check if displayRank we what to display before player score is exists
                while (loadedLeaderBoard.GetScore(displayRank, displayTime, displayCollection) == null)
                {
                    displayRank++;
                }
            }


            Debug.Log("Start Display at rank: " + displayRank);


            int i = displayRank;

            foreach (LeaderboardFiledsHolder line in lines)
            {
                if (line.isPlayerRow)
                {
                    break;
                }
                GPScore score = loadedLeaderBoard.GetScore(i, displayTime, displayCollection);
                if (score != null)
                {
                    //順位 i.ToString();
                    //スコア score.LongScore.ToString();
                    GooglePlayerTemplate player = GooglePlayManager.Instance.GetPlayerById(score.PlayerId);
                    if (player != null)
                    {
                        //名前 player.name;
                        //この行は表示する
                        if (player.hasIconImage)
                        {
                            //アイコン有り
                            line.Set(i, score.LongScore, player.name, player.icon);
                        }
                        else
                        {
                            //アイコン無し
                            line.Set(i, score.LongScore, player.name, defaultTexture);
                        }
                    }
                    else
                    {
                        //プレイヤはnull
                        //名前 無し
                        //アイコン無し
                        line.Set(i, score.LongScore, "Angler", defaultTexture);
                    }
                }
                else
                {
                    //この行は表示しない
                    line.StopWait();
                }

                i++;
            }
        }
        else
        {
            //リーダボードは存在しない
            OnNoData();
        }
    }
Beispiel #24
0
	public void ReportLocalPlayerScoreUpdate (GPScore score, int requestId) {
		GP_LocalPlayerScoreUpdateListener listener = _ScoreUpdateListners[requestId];
		listener.ReportScoreUpdate(score);
	}
Beispiel #25
0
    //--------------------------------------
    // EVENTS
    //--------------------------------------

    private void ActionScoreRequestReceived(GooglePlayResult obj)
    {
        GooglePlayManager.ActionScoresListLoaded -= ActionScoreRequestReceived;
        loadedLeaderBoard = GooglePlayManager.Instance.GetLeaderBoard(LEADERBOARD_ID);
        if (loadedLeaderBoard == null)
        {
            OnNoData();
            home.OnScoreLoaded();
            Debug.Log("No Leaderboard found");
            return;
        }

        List <GPScore> scoresLB = loadedLeaderBoard.GetScoresList(GPBoardTimeSpan.ALL_TIME, GPCollectionType.GLOBAL);

        foreach (GPScore score in scoresLB)
        {
            Debug.Log("OnScoreUpdated " + score.Rank + " " + score.PlayerId + " " + score.LongScore);
        }

        int i = 1;

        foreach (LeaderboardFiledsHolder line in lines)
        {
            if (line.isPlayerRow)
            {
                break;
            }
            GPScore score = loadedLeaderBoard.GetScore(i, displayTime, displayCollection);
            if (score != null)
            {
                //順位 i.ToString();
                //スコア score.LongScore.ToString();
                GooglePlayerTemplate player = GooglePlayManager.Instance.GetPlayerById(score.PlayerId);
                if (player != null)
                {
                    //名前 player.name;
                    //この行は表示する
                    if (player.hasIconImage)
                    {
                        //アイコン有り
                        line.Set(i, score.LongScore, player.name, player.icon);
                    }
                    else
                    {
                        //アイコン無し
                        line.Set(i, score.LongScore, player.name, defaultTexture);
                    }
                }
                else
                {
                    //プレイヤはnull
                    //名前 無し
                    //アイコン無し
                    line.Set(i, score.LongScore, "Angler", defaultTexture);
                }
            }
            else
            {
                //この行は表示しない
                line.StopWait();
            }

            i++;
        }

        GPScore currentPlayerScore = loadedLeaderBoard.GetCurrentPlayerScore(displayTime, displayCollection);

        Debug.Log("currentPlayerScore: " + currentPlayerScore.LongScore + " rank:" + currentPlayerScore.Rank);
        if (currentPlayerScore == null)
        {
            lines[5].OnNoData();
        }
        else
        {
            lines[5].Set(currentPlayerScore.Rank, currentPlayerScore.LongScore, "YOU", defaultTexture);
        }
        home.OnScoreLoaded();
        //UpdateScoresDisaplay();
    }
Beispiel #26
0
	public void UpdateCurrentPlayerScore(GPScore score) {		
		GPScore currentScore = GetCurrentPlayerScore(score.TimeSpan, score.Collection);
		if (currentScore != null) {
			CurrentPlayerScore.Remove(currentScore);
		}		
		CurrentPlayerScore.Add(score);
		_CurrentPlayerScoreLoaded = true;
	}
Beispiel #27
0
    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);
    }
Beispiel #28
0
    //--------------------------------------
    // Public Methods
    //--------------------------------------

    public void ReportScoreUpdate(GPScore score)
    {
        Scores.Add(score);
        DispatchUpdate();
    }