Exemple #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);
    }
    //--------------------------------------
    //  EVENTS
    //--------------------------------------


    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]);


        GCBoardTimeSpan  timeSpan   = (GCBoardTimeSpan)System.Convert.ToInt32(data[3]);
        GCCollectionType collection = (GCCollectionType)System.Convert.ToInt32(data[4]);

        GCLeaderBoard board;

        if (_leaderboards.ContainsKey(lbId))
        {
            board = _leaderboards[lbId];
        }
        else
        {
            board = new GCLeaderBoard(lbId);
            _leaderboards.Add(lbId, board);
        }


        GCScore score = new GCScore(scoreVal, rank, timeSpan, collection, lbId, player.playerId);

        board.UpdateScore(score);
        board.UpdateCurrentPlayerRank(rank, timeSpan, collection);


        dispatcher.dispatch(GAME_CENTER_LEADER_BOARD_SCORE_LOADED, score);
    }
Exemple #3
0
 private void OnPlayerScoreLoaded(ISN_PlayerScoreLoadedResult result)
 {
     if (result.IsSucceeded)
     {
         GCScore score = result.loadedScore;
         IOSNativePopUpManager.showMessage("Leader Board " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank);
     }
 }
    private void OnLeaderboardScoreLoaded(CEvent e)
    {
        ISN_PlayerScoreLoadedResult result = e.data as ISN_PlayerScoreLoadedResult;

        if (result.IsSucceeded)
        {
            GCScore score = result.loadedScore;
            IOSNativePopUpManager.showMessage("Leaderboard " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank);
        }
    }
Exemple #5
0
    private void onLeaderBoardScoreListLoaded(string array)
    {
        string[] data;
        data = array.Split("," [0]);

        string           lbId       = data[0];
        GCBoardTimeSpan  timeSpan   = (GCBoardTimeSpan)System.Convert.ToInt32(data[1]);
        GCCollectionType collection = (GCCollectionType)System.Convert.ToInt32(data[2]);

        GCLeaderBoard board;

        if (_leaderboards.ContainsKey(lbId))
        {
            board = _leaderboards[lbId];
        }
        else
        {
            board = new GCLeaderBoard(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]);

            GCScore score = new GCScore(scoreVal, rank, timeSpan, collection, lbId, playerId);
            board.UpdateScore(score);
            if (player != null)
            {
                if (player.playerId.Equals(playerId))
                {
                    board.UpdateCurrentPlayerRank(rank, timeSpan, collection);
                }
            }
        }



        ISN_Result result = new ISN_Result(true);

        OnScoresListLoaded(result);
        dispatcher.dispatch(GAME_CENTER_LEADER_BOARD_SCORE_LIST_LOADED, result);
    }
    private void OnPlayerScoreLoaded(ISN_PlayerScoreLoadedResult result)
    {
        if (result.IsSucceeded)
        {
            GCScore score = result.loadedScore;
            IOSNativePopUpManager.showMessage("Leaderboard " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank);

            Debug.Log("double score representation: " + score.GetDoubleScore());
            Debug.Log("long score representation: " + score.GetLongScore());

            if (score.leaderboardId.Equals(leaderBoardId2))
            {
                Debug.Log("Updating leaderboard 2 score");
                LB2BestScores = score.GetLongScore();
            }
        }
    }
Exemple #7
0
    public void UpdateScore(GCScore s)
    {
        ScoreCollection col = GlobalCollection;

        switch (s.collection)
        {
        case GCCollectionType.GLOBAL:
            col = GlobalCollection;
            break;

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



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

        switch (s.timeSpan)
        {
        case GCBoardTimeSpan.ALL_TIME:
            scoreDict = col.AllTimeScores;
            break;

        case GCBoardTimeSpan.TODAY:
            scoreDict = col.TodayScores;
            break;

        case GCBoardTimeSpan.WEEK:
            scoreDict = col.WeekScores;
            break;
        }


        if (scoreDict.ContainsKey(s.GetRank()))
        {
            scoreDict[s.GetRank()] = s;
        }
        else
        {
            scoreDict.Add(s.GetRank(), s);
        }
    }
	private void onLeaderboardScoreListLoaded(string array) {


		
		string[] data;
		data = array.Split("," [0]);

		string lbId = data[0];
		GCBoardTimeSpan timeSpan = (GCBoardTimeSpan) System.Convert.ToInt32(data[1]);
		GCCollectionType collection = (GCCollectionType) System.Convert.ToInt32(data[2]);

		GCLeaderboard board;
		if(_leaderboards.ContainsKey(lbId)) {
			board = _leaderboards[lbId];
		} else {
			board =  new GCLeaderboard(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]);

			GCScore score =  new GCScore(scoreVal, rank, timeSpan, collection, lbId, playerId);
			board.UpdateScore(score);
			if(Player != null) {
				if(Player.PlayerId.Equals(playerId)) {
					board.UpdateCurrentPlayerRank(rank, timeSpan, collection);
				}
			}
		}
		


		ISN_Result result = new ISN_Result (true);
		OnScoresListLoaded (result);
		Dispatcher.dispatch (GAME_CENTER_LEADERBOARD_SCORE_LIST_LOADED, result);


	}
	private void onLeaderboardScore(string array) {

		string[] data;
		data = array.Split("," [0]);

		string lbId = data[0];
		string scoreVal = data[1];
		int rank = System.Convert.ToInt32(data[2]);


		GCBoardTimeSpan timeSpan = (GCBoardTimeSpan) System.Convert.ToInt32(data[3]);
		GCCollectionType collection = (GCCollectionType) System.Convert.ToInt32(data[4]);

		GCLeaderboard board;
		if(_leaderboards.ContainsKey(lbId)) {
			board = _leaderboards[lbId];
		} else {
			board =  new GCLeaderboard(lbId);
			_leaderboards.Add(lbId, board);
		}


		GCScore score =  new GCScore(scoreVal, rank, timeSpan, collection, lbId, Player.PlayerId);

		board.UpdateScore(score);
		board.UpdateCurrentPlayerRank(rank, timeSpan, collection);
	

		ISN_PlayerScoreLoadedResult result = new ISN_PlayerScoreLoadedResult (score);
		OnPlayerScoreLoaded (result);
		Dispatcher.dispatch (GAME_CENTER_LEADERBOARD_SCORE_LOADED, result);
	}
Exemple #10
0
	public void UpdateScore(GCScore s) {

		ScoreCollection col = GlobalCollection;

		switch(s.collection) {
		case GCCollectionType.GLOBAL:
			col = GlobalCollection;
			break;
		case GCCollectionType.FRIENDS:
			col = SocsialCollection;
			break;
		}




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

		switch(s.timeSpan) {
		case GCBoardTimeSpan.ALL_TIME:
			scoreDict = col.AllTimeScores;
			break;
		case GCBoardTimeSpan.TODAY:
			scoreDict = col.TodayScores;
			break;
		case GCBoardTimeSpan.WEEK:
			scoreDict = col.WeekScores;
			break;
		}


		if(scoreDict.ContainsKey(s.GetRank())) {
			scoreDict[s.GetRank()] = s;
		} else {
			scoreDict.Add(s.GetRank(), s);
		}
	}
	public ISN_PlayerScoreLoadedResult(GCScore score):base(true) {
		_score = score;
	}
Exemple #12
0
    void OnGUI()
    {
        GUI.Label(new Rect(10, 20, 400, 40), "Custom Leader Board GUI Example", headerStyle);

        if (GUI.Button(new Rect(400, 10, 150, 50), "Load Friends Scores"))
        {
            GameCenterManager.loadScore(leaderBoardId, 1, 10, GCBoardTimeSpan.ALL_TIME, GCCollectionType.FRIENDS);
        }

        if (GUI.Button(new Rect(600, 10, 150, 50), "Load Global Scores"))
        {
            GameCenterManager.loadScore(leaderBoardId, 1, 10, GCBoardTimeSpan.ALL_TIME, GCCollectionType.GLOBAL);
        }

        Color defaultColor = GUI.color;

        if (diplayCollection == GCCollectionType.GLOBAL)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(800, 10, 170, 50), "Displying Global Scores"))
        {
            diplayCollection = GCCollectionType.GLOBAL;
        }
        GUI.color = defaultColor;



        if (diplayCollection == GCCollectionType.FRIENDS)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(800, 70, 170, 50), "Displying Friends Scores"))
        {
            diplayCollection = GCCollectionType.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++)
            {
                GCScore score = loadedLeaderBoard.GetScore(i, GCBoardTimeSpan.ALL_TIME, diplayCollection);
                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.GetIntScore().ToString(), boardStyle);
                    GUI.Label(new Rect(200, 90 + 70 * i, 100, 40), score.playerId, boardStyle);


                    GameCenterPlayerTemplate player = GameCenterManager.GetPlayerById(score.playerId);
                    if (player != null)
                    {
                        GUI.Label(new Rect(400, 90 + 70 * i, 100, 40), player.alias, boardStyle);
                        if (player.avatar != null)
                        {
                            GUI.DrawTexture(new Rect(550, 75 + 70 * i, 50, 50), player.avatar);
                        }
                        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), "Chalange"))
                    {
                        GameCenterManager.issueLeaderboardChallenge(leaderBoardId, "Your message here", score.playerId);
                    }
                }
            }
        }
    }
 public ISN_PlayerScoreLoadedResult(GCScore score) : base(true)
 {
     _score = score;
 }
    private void OnLeaderBoarScoreLoaded(CEvent e)
    {
        GCScore score = e.data as GCScore;

        IOSNativePopUpManager.showMessage("Leader Board " + score.leaderboardId, "Score: " + score.score + "\n" + "Rank:" + score.rank);
    }