Esempio n. 1
0
    private void OnPlayersLoaded(string 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 += 6)
            {
                if (storeData[i] == AndroidNative.DATA_EOF)
                {
                    break;
                }


                GooglePlayerTemplate p = new GooglePlayerTemplate(storeData[i], storeData[i + 1], storeData[i + 2], storeData[i + 3], storeData[i + 4], storeData[i + 5]);
                AddPlayer(p);
                if (!_friendsList.Contains(p.playerId))
                {
                    _friendsList.Add(p.playerId);
                }
            }
        }



        Debug.Log("OnPlayersLoaded, total:" + players.Count.ToString());
        ActionFriendsListLoaded(result);
    }
Esempio n. 2
0
    //--------------------------------------
    // PRIVATE METHODS
    //--------------------------------------

    private void AddPlayer(GooglePlayerTemplate p)
    {
        if (!_players.ContainsKey(p.playerId))
        {
            _players.Add(p.playerId, p);
        }
    }
    public UM_PlayerTemplate GetPlayer(string playerId)
    {
        UM_PlayerTemplate player = null;

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            GK_Player gk_player = GameCenterManager.GetPlayerById(playerId);
            if (gk_player != null)
            {
                player = new UM_PlayerTemplate(gk_player, null);
            }
            break;

        case RuntimePlatform.Android:
            GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(playerId);
            if (gp_player != null)
            {
                player = new UM_PlayerTemplate(null, gp_player);
            }
            break;
        }

        return(player);
    }
    //--------------------------------------
    // 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();
            }
        }
    }
Esempio n. 5
0
    public void SetParticipant(GP_Participant p)
    {
        id.text         = "";
        playerId.text   = "";
        playerName.text = "";
        status.text     = GP_RTM_ParticipantStatus.STATUS_UNRESPONSIVE.ToString();

        GooglePlayerTemplate player = GooglePlayManager.Instance.GetPlayerById(p.playerId);

        if (player != null)
        {
            playerId.text   = "Player Id: " + p.playerId;
            playerName.text = "Name: " + player.name;

            if (player.icon != null)
            {
                if (!_id.Equals(p.playerId))
                {
                    icon          = Sprite.Create(player.icon, new Rect(0.0f, 0.0f, player.icon.width, player.icon.height), new Vector2(0.5f, 0.5f));
                    avatar.sprite = icon;
                    _id           = p.playerId;
                }
            }
        }
        else
        {
            avatar.sprite = defaulttexture;
            icon          = null;
            _id           = string.Empty;
        }
        id.text     = "ID: " + p.id;
        status.text = "Status: " + p.Status.ToString();
    }
Esempio n. 6
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;
            }
        }
    }
Esempio n. 7
0
    public void SetPartisipant(GP_Partisipant p)
    {
        id.text         = "";
        playerId.text   = "";
        playerName.text = "";
        status.text     = GP_RTM_ParticipantStatus.STATUS_UNRESPONSIVE.ToString();

        avatar.GetComponent <Renderer>().material.mainTexture = defaulttexture;


        GooglePlayerTemplate player = GooglePlayManager.instance.GetPlayerById(p.playerId);

        if (player != null)
        {
            playerId.text   = "Player Id: " + p.playerId;
            playerName.text = "Name: " + player.name;

            if (player.icon != null)
            {
                avatar.GetComponent <Renderer>().material.mainTexture = player.icon;
            }
        }
        id.text     = "ID: " + p.id;
        status.text = "Status: " + p.status.ToString();
    }
Esempio n. 8
0
    void Update()
    {
        foreach (CustomPlayerUIRow row in rows)
        {
            row.Disable();
        }

        if (GooglePlayConnection.State != GPConnectionState.STATE_CONNECTED)
        {
            return;
        }

        int i = 0;

        foreach (string fId in GooglePlayManager.instance.friendsList)
        {
            GooglePlayerTemplate p = GooglePlayManager.instance.GetPlayerById(fId);
            if (p != null)
            {
                rows[i].playerId.text   = p.playerId;
                rows[i].playerName.text = p.name;
                if (p.hasIconImage && p.icon != null)
                {
                    rows[i].hasIcon.text = "Yes";
                }
                else
                {
                    rows[i].hasIcon.text = "No";
                }

                if (p.hasHiResImage && p.image != null)
                {
                    rows[i].hasImage.text = "Yes";
                }
                else
                {
                    rows[i].hasImage.text = "No";
                }

                rows[i].avatar.GetComponent <Renderer>().enabled = true;
                if (p.hasIconImage && p.icon != null)
                {
                    rows[i].avatar.GetComponent <Renderer>().material.mainTexture = p.icon;
                }
                else
                {
                    rows[i].avatar.GetComponent <Renderer>().material.mainTexture = defaulttexture;
                }
            }

            i++;

            if (i > 5)
            {
                return;
            }
        }
    }
Esempio n. 9
0
	//--------------------------------------
	// Init
	//--------------------------------------

	public UM_PlayerTemplate(GK_Player gk, GooglePlayerTemplate gp) {
		_GK_Player = gk;
		_GP_Player = gp;

		if(_GK_Player != null) {
			_GK_Player.OnPlayerPhotoLoaded += HandleOnPlayerPhotoLoaded;
		}

		if(_GP_Player != null) {
			_GP_Player.BigPhotoLoaded += HandleBigPhotoLoaded;
			_GP_Player.SmallPhotoLoaded += HandleSmallPhotoLoaded;
		}
	}
Esempio n. 10
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);
    }
Esempio n. 11
0
    //--------------------------------------
    // Init
    //--------------------------------------

    public UM_Player(GK_Player gk, GooglePlayerTemplate gp)
    {
        _GK_Player = gk;
        _GP_Player = gp;

        if (_GK_Player != null)
        {
            _GK_Player.OnPlayerPhotoLoaded += HandleOnPlayerPhotoLoaded;
        }

        if (_GP_Player != null)
        {
            _GP_Player.BigPhotoLoaded   += HandleBigPhotoLoaded;
            _GP_Player.SmallPhotoLoaded += HandleSmallPhotoLoaded;
        }
    }
Esempio n. 12
0
    private void OnPlayerDataLoaded(string data)
    {
        Debug.Log("OnPlayerDataLoaded");
        if (data.Equals(string.Empty))
        {
            Debug.Log("GooglePlayManager OnPlayerLoaded, no data avaiable");
            return;
        }

        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

        _player = new GooglePlayerTemplate(storeData [0], storeData [1], storeData [2], storeData [3], storeData [4], storeData [5]);
        AddPlayer(_player);

        _currentAccount = storeData [6];
    }
Esempio n. 13
0
    private void OnPlayerLoaded(string data)
    {
        if (data.Equals(string.Empty))
        {
            Debug.Log("GooglePlayManager OnPlayerLoaded, no data avaiable");
            return;
        }

        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

        GooglePlayResult result = new GooglePlayResult(storeData [0]);

        _player = new GooglePlayerTemplate(storeData [1], storeData [2]);

        dispatch(PLAYER_LOADED, result);
        Debug.Log("GooglePlayManager -> PLAYER_LOADED");
    }
Esempio n. 14
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;
            }
        }
    }
    public void SetFriendId(string pId)
    {
        _pId = pId;

        playerId.text   = "";
        playerName.text = "";

        avatar.sprite = defaulttexture;

        GooglePlayerTemplate player = GooglePlayManager.Instance.GetPlayerById(pId);

        if (player != null)
        {
            playerId.text   = "Player Id: " + _pId;
            playerName.text = "Name: " + player.name;

            if (player.icon != null)
            {
                avatar.GetComponent <Renderer>().material.mainTexture = player.icon;
            }
        }
    }
Esempio n. 16
0
    //--------------------------------------
    // Init
    //--------------------------------------

    public UM_Player(GK_Player gk, GooglePlayerTemplate gp, GC_Player gc)
    {
        _GK_Player = gk;
        _GP_Player = gp;
        _GC_Player = gc;

        if (_GK_Player != null)
        {
            _GK_Player.OnPlayerPhotoLoaded += HandleOnPlayerPhotoLoaded;
        }

        if (_GP_Player != null)
        {
            _GP_Player.BigPhotoLoaded   += HandleBigPhotoLoaded;
            _GP_Player.SmallPhotoLoaded += HandleSmallPhotoLoaded;
        }

        if (_GC_Player != null)
        {
            _GC_Player.AvatarLoaded += AmazonPlayerAvatarLoaded;
        }
    }
Esempio n. 17
0
    private void OnGCDataReceived(GP_RTM_Network_Package package)
    {
                #if (UNITY_ANDROID && !UNITY_EDITOR) || SA_DEBUG_MODE
        System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
        string str = enc.GetString(package.buffer);


        string name = package.participantId;


        GP_Participant p = GooglePlayRTM.instance.currentRoom.GetParticipantById(package.participantId);
        if (p != null)
        {
            GooglePlayerTemplate player = GooglePlayManager.instance.GetPlayerById(p.playerId);
            if (player != null)
            {
                name = player.name;
            }
        }

        AndroidMessage.Create("Data Eeceived", "player " + name + " \n " + "data: " + str);
                #endif
    }
    void Update()
    {
        if (GooglePlayConnection.State != GPConnectionState.STATE_CONNECTED)
        {
            return;
        }

        int i = 0;

        foreach (string fId in GooglePlayManager.Instance.friendsList)
        {
            GooglePlayerTemplate p = GooglePlayManager.Instance.GetPlayerById(fId);
            if (p != null)
            {
                rows[i].SetInfo(p.playerId, p.name, p.hasIconImage && p.icon != null, p.hasHiResImage && p.image != null, p.icon);
            }

            i++;
            if (i > 7)
            {
                return;
            }
        }
    }
    public UM_Player GetPlayer(string playerId)
    {
        UM_Player player = null;

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            GK_Player gk_player = GameCenterManager.GetPlayerById(playerId);
            if (gk_player != null)
            {
                player = new UM_Player(gk_player, null, null);
            }
            break;

        case RuntimePlatform.Android:
            if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
            {
                GC_Player gc_player = SA_AmazonGameCircleManager.Instance.GetPlayerById(playerId);
                if (gc_player != null)
                {
                    player = new UM_Player(null, null, gc_player);
                }
            }
            else
            {
                GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(playerId);
                if (gp_player != null)
                {
                    player = new UM_Player(null, gp_player, null);
                }
            }
            break;
        }

        return(player);
    }
Esempio n. 20
0
    //--------------------------------------
    // init
    //--------------------------------------

    public GameServicePlayerTemplate(GK_Player gc, GooglePlayerTemplate ps)
    {
        gc_player = gc;
        ps_player = ps;
    }
Esempio n. 21
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();
    }
	//--------------------------------------
	// init
	//--------------------------------------

	public GameServicePlayerTemplate(GK_Player gc, GooglePlayerTemplate ps) {
		gc_player = gc;
		ps_player = ps;

	}
Esempio n. 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();
        }
    }
Esempio n. 24
0
    //--------------------------------------
    // init
    //--------------------------------------

    public GameServicePlayerTemplate(GameCenterPlayerTemplate gc, GooglePlayerTemplate ps)
    {
        gc_player = gc;
        ps_player = ps;
    }
Esempio n. 25
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();
            }
        }
    }
Esempio n. 26
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);
    }
	//--------------------------------------
	// init
	//--------------------------------------

	public GameServicePlayerTemplate(GameCenterPlayerTemplate gc, GooglePlayerTemplate ps) {
		gc_player = gc;
		ps_player = ps;

	}