Пример #1
0
    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;
        }
    }
Пример #2
0
	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 override void Reset()
 {
     LeaderboardId = null;
     Timespan = GPBoardTimeSpan.ALL_TIME;
     Collection = GPCollectionType.GLOBAL;
     Score = null;
     Rank = null;
 }
Пример #4
0
 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;
     }
 }
Пример #5
0
	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;
	}
Пример #6
0
	//--------------------------------------
	// 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;

	}
    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 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);
    }
Пример #9
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);
    }
    //--------------------------------------
    // 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();
            }
        });
    }
Пример #11
0
	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);
		}
	}
Пример #12
0
 public void ShowWeek()
 {
     displayTime = GPBoardTimeSpan.WEEK;
     UpdateScoresDisaplay();
 }
Пример #13
0
 public void ShowDay()
 {
     displayTime = GPBoardTimeSpan.TODAY;
     UpdateScoresDisaplay();
 }
Пример #14
0
 public void ShowAllTime()
 {
     displayTime = GPBoardTimeSpan.ALL_TIME;
     UpdateScoresDisaplay();
 }
Пример #15
0
	public GPScore GetCurrentPlayerScore(GPBoardTimeSpan timeSpan, GPCollectionType collection) {
		foreach (GPScore score in CurrentPlayerScore) {
			if (score.TimeSpan == timeSpan && score.Collection == collection) {
				return score;
			}
		}

		return null;
	}
Пример #16
0
	public void ShowDay() {
		displayTime = GPBoardTimeSpan.TODAY;
	}
Пример #17
0
 public void ShowWeek()
 {
     displayTime = GPBoardTimeSpan.WEEK;
     StartWait();
     UpdateScoresDisaplay();
 }
Пример #18
0
 public void loadTopScores(string leaderboardId, GPBoardTimeSpan span, GPCollectionType collection, int maxResults)
 {
     LoadTopScores(leaderboardId, span, collection, maxResults);
 }
Пример #19
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);
    }
Пример #20
0
 public void ShowDay()
 {
     displayTime = GPBoardTimeSpan.TODAY;
 }
Пример #21
0
 public void ShowWeek()
 {
     displayTime = GPBoardTimeSpan.WEEK;
 }
Пример #22
0
 public void ShowAllTime()
 {
     displayTime = GPBoardTimeSpan.ALL_TIME;
 }
Пример #23
0
 public void ShowAllTime()
 {
     displayTime = GPBoardTimeSpan.ALL_TIME;
     StartWait();
     UpdateScoresDisaplay();
 }
Пример #24
0
	public void ShowAllTime() {
		displayTime = GPBoardTimeSpan.ALL_TIME;
	}
Пример #25
0
 public void ShowDay()
 {
     displayTime = GPBoardTimeSpan.TODAY;
     StartWait();
     UpdateScoresDisaplay();
 }
Пример #26
0
	public void ShowWeek() {
		displayTime = GPBoardTimeSpan.WEEK;
	}