示例#1
0
	public List<GK_Score> GetScoresList(GK_TimeSpan timeSpan, GK_CollectionType collection) {
		GK_ScoreCollection col = GlobalCollection;
		
		switch(collection) {
		case GK_CollectionType.GLOBAL:
			col = GlobalCollection;
			break;
		case GK_CollectionType.FRIENDS:
			col = SocsialCollection;
			break;
		}
		
		
		Dictionary<int, GK_Score> scoreDict = col.AllTimeScores;
		
		switch(timeSpan) {
		case GK_TimeSpan.ALL_TIME:
			scoreDict = col.AllTimeScores;
			break;
		case GK_TimeSpan.TODAY:
			scoreDict = col.TodayScores;
			break;
		case GK_TimeSpan.WEEK:
			scoreDict = col.WeekScores;
			break;
		}
		
		List<GK_Score> scores = new List<GK_Score>();
		scores.AddRange(scoreDict.Values);

		return scores;
	}
    private void OnLoaderBoardInfoRetrived(string data)
    {
        string[] DataArray = data.Split(new string[] { SA.Common.Data.Converter.DATA_SPLITTER2 }, StringSplitOptions.None);


        string            leaderboardId = DataArray[0];
        GK_TimeSpan       timeSpan      = (GK_TimeSpan)System.Convert.ToInt32(DataArray[1]);
        GK_CollectionType collection    = (GK_CollectionType)System.Convert.ToInt32(DataArray[2]);
        int requestId = System.Convert.ToInt32(DataArray[3]);

        long   scoreVal    = System.Convert.ToInt64(DataArray[4]);
        int    rank        = System.Convert.ToInt32(DataArray[5]);
        int    context     = System.Convert.ToInt32(DataArray[6]);
        int    maxRange    = System.Convert.ToInt32(DataArray[7]);
        string title       = DataArray[8];
        string describtion = DataArray[9];



        GK_Leaderboard board = GetLeaderboard(leaderboardId);

        board.UpdateMaxRange(maxRange);
        board.Info.Title       = title;
        board.Info.Description = describtion;


        GK_Score score = new GK_Score(scoreVal, rank, context, timeSpan, collection, leaderboardId, Player.Id);

        board.ReportLocalPlayerScoreUpdate(score, requestId);
    }
	public void UpdateCurrentPlayerRank(int rank, GK_TimeSpan timeSpan, GK_CollectionType collection) {
		string key = timeSpan.ToString() + "_" + collection.ToString();
		if(currentPlayerRank.ContainsKey(key)) {
			currentPlayerRank[key] = rank;
		} else {
			currentPlayerRank.Add(key, rank);
		}
	}
	public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType 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 Methods
	//--------------------------------------

	

	public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType collection) {

		foreach(GK_Score score in CurrentPlayerScore) {
			if(score.TimeSpan == timeSpan && score.Collection == collection) {
				return score;
			}
		}

		return null;
	}
示例#6
0
    public GK_Score(string vScore, int vRank, GK_TimeSpan vTimeSpan, GK_CollectionType sCollection, string lid, string pid)
    {
        _score = vScore;
        _rank  = vRank;

        _playerId      = pid;
        _leaderboardId = lid;


        _timeSpan   = vTimeSpan;
        _collection = sCollection;
    }
示例#7
0
    public GK_Score(long vScore, int vRank, GK_TimeSpan vTimeSpan, GK_CollectionType sCollection, string lid, string pid)
    {
        _Score = vScore;
        _Rank  = vRank;

        _PlayerId      = pid;
        _LeaderboardId = lid;


        _TimeSpan   = vTimeSpan;
        _Collection = sCollection;
    }
示例#8
0
	public GK_Score(string vScore, int vRank, GK_TimeSpan vTimeSpan, GK_CollectionType sCollection, string lid, string pid) {
		_score = vScore;
		_rank = vRank;
		
		_playerId = pid;
		_leaderboardId = lid;
		
		
		_timeSpan  = vTimeSpan;
		_collection = sCollection;
		
	}
示例#9
0
	public GK_Score(long vScore, int vRank, GK_TimeSpan vTimeSpan, GK_CollectionType sCollection, string lid, string pid) {
		_Score = vScore; 
		_Rank = vRank;
		
		_PlayerId = pid;
		_LeaderboardId = lid;
		
		
		_TimeSpan  = vTimeSpan;
		_Collection = sCollection;
		
	}
示例#10
0
    //--------------------------------------
    // Public Methods
    //--------------------------------------



    public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType collection)
    {
        foreach (GK_Score score in CurrentPlayerScore)
        {
            if (score.TimeSpan == timeSpan && score.Collection == collection)
            {
                return(score);
            }
        }

        return(null);
    }
示例#11
0
    public void UpdateCurrentPlayerRank(int rank, GK_TimeSpan timeSpan, GK_CollectionType collection)
    {
        string key = timeSpan.ToString() + "_" + collection.ToString();

        if (currentPlayerRank.ContainsKey(key))
        {
            currentPlayerRank[key] = rank;
        }
        else
        {
            currentPlayerRank.Add(key, rank);
        }
    }
示例#12
0
    public GK_Score GetCurrentPlayerScore(GK_TimeSpan timeSpan, GK_CollectionType collection)
    {
        string key = timeSpan.ToString() + "_" + collection.ToString();

        if (currentPlayerRank.ContainsKey(key))
        {
            int rank = currentPlayerRank[key];
            return(GetScore(rank, timeSpan, collection));
        }
        else
        {
            return(null);
        }
    }
示例#13
0
	public GK_Score GetScoreByPlayerId(string playerId, GK_TimeSpan timeSpan, GK_CollectionType collection) {

		if(playerId.Equals(GameCenterManager.Player.Id)) {
			return GetCurrentPlayerScore(timeSpan, collection);
		}

		List<GK_Score> scores = GetScoresList(timeSpan, collection);
		foreach(GK_Score s in scores) {
			if(s.PlayerId.Equals(playerId)) {
				return s;
			}
		}
		
		return null;
	}
示例#14
0
    private void onLeaderboardScoreListLoaded(string array)
    {
        string[] data;
        data = array.Split("," [0]);

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

        GK_Leaderboard board;

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

            GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, lbId, playerId);
            board.UpdateScore(score);
            if (Player != null)
            {
                if (Player.Id.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);
    }
    public static UM_TimeSpan Get_UM_TimeSpan(this GK_TimeSpan type)
    {
        switch (type)
        {
        case GK_TimeSpan.ALL_TIME:
            return(UM_TimeSpan.ALL_TIME);

        case GK_TimeSpan.TODAY:
            return(UM_TimeSpan.TODAY);

        case GK_TimeSpan.WEEK:
            return(UM_TimeSpan.WEEK);

        default:
            return(UM_TimeSpan.ALL_TIME);
        }
    }
示例#16
0
    public GK_Score GetScore(int rank, GK_TimeSpan scope, GK_CollectionType collection)
    {
        GK_ScoreCollection col = GlobalCollection;

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

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



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

        switch (scope)
        {
        case GK_TimeSpan.ALL_TIME:
            scoreDict = col.AllTimeScores;
            break;

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

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



        if (scoreDict.ContainsKey(rank))
        {
            return(scoreDict[rank]);
        }
        else
        {
            return(null);
        }
    }
示例#17
0
    public GK_Score GetScoreByPlayerId(string playerId, GK_TimeSpan timeSpan, GK_CollectionType collection)
    {
        if (playerId.Equals(GameCenterManager.Player.Id))
        {
            return(GetCurrentPlayerScore(timeSpan, collection));
        }

        List <GK_Score> scores = GetScoresList(timeSpan, collection);

        foreach (GK_Score s in scores)
        {
            if (s.PlayerId.Equals(playerId))
            {
                return(s);
            }
        }

        return(null);
    }
    private void OnLeaderboardScoreListLoaded(string data)
    {
        string[] DataArray = data.Split(new string[] { SA.Common.Data.Converter.DATA_SPLITTER2 }, StringSplitOptions.None);



        string            leaderboardId = DataArray[0];
        GK_TimeSpan       timeSpan      = (GK_TimeSpan)System.Convert.ToInt32(DataArray[1]);
        GK_CollectionType collection    = (GK_CollectionType)System.Convert.ToInt32(DataArray[2]);

        GK_Leaderboard board = GetLeaderboard(leaderboardId);



        for (int i = 3; i < DataArray.Length; i += 4)
        {
            string   playerId = DataArray[i];
            long     scoreVal = System.Convert.ToInt64(DataArray[i + 1]);
            int      rank     = System.Convert.ToInt32(DataArray[i + 2]);
            int      context  = System.Convert.ToInt32(DataArray[i + 3]);
            GK_Score score    = new GK_Score(scoreVal, rank, context, timeSpan, collection, leaderboardId, playerId);
            board.UpdateScore(score);


            if (Player != null)
            {
                if (Player.Id.Equals(playerId))
                {
                    board.UpdateCurrentPlayerScore(score);
                }
            }
        }



        GK_LeaderboardResult result = new GK_LeaderboardResult(board);

        OnScoresListLoaded(result);
    }
	public GK_Score GetScore(int rank, GK_TimeSpan scope, GK_CollectionType collection) {

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



		Dictionary<int, GK_Score> scoreDict = col.AllTimeScores;
		
		switch(scope) {
		case GK_TimeSpan.ALL_TIME:
			scoreDict = col.AllTimeScores;
			break;
		case GK_TimeSpan.TODAY:
			scoreDict = col.TodayScores;
			break;
		case GK_TimeSpan.WEEK:
			scoreDict = col.WeekScores;
			break;
		}



		if(scoreDict.ContainsKey(rank)) {
			return scoreDict[rank];
		} else {
			return null;
		}

	}
示例#20
0
    public List <GK_Score> GetScoresList(GK_TimeSpan timeSpan, GK_CollectionType collection)
    {
        GK_ScoreCollection col = GlobalCollection;

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

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


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

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

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

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

        List <GK_Score> scores = new List <GK_Score>();

        scores.AddRange(scoreDict.Values);

        return(scores);
    }
示例#21
0
    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]);


        GK_TimeSpan       timeSpan   = (GK_TimeSpan)System.Convert.ToInt32(data[3]);
        GK_CollectionType collection = (GK_CollectionType)System.Convert.ToInt32(data[4]);

        GK_Leaderboard board;

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


        GK_Score score = new GK_Score(scoreVal, rank, timeSpan, collection, lbId, Player.Id);

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


        GK_PlayerScoreLoadedResult result = new GK_PlayerScoreLoadedResult(score);

        OnPlayerScoreLoaded(result);
        Dispatcher.dispatch(GAME_CENTER_LEADERBOARD_SCORE_LOADED, result);
    }
 public static void ShowLeaderboard(string leaderboardId, GK_TimeSpan timeSpan)
 {
             #if ((UNITY_IPHONE || UNITY_TVOS) && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE
     _showLeaderboard(leaderboardId, (int)timeSpan);
             #endif
 }
示例#23
0
	public static void LoadCurrentPlayerScore(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL)  {
		LoadLeaderboardInfo(leaderboardId);
	}
	private IEnumerator LoadCurrentPlayerScoreLocal(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL ) {
		yield return new WaitForSeconds(4f);
		LoadCurrentPlayerScore(leaderboardId, timeSpan, collection);
	}
 public static void LoadScore(string leaderboardId, int startIndex, int length, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL)
 {
             #if ((UNITY_IPHONE || UNITY_TVOS) && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE
     _ISN_loadLeaderboardScore(leaderboardId, (int)timeSpan, (int)collection, startIndex, length);
             #endif
 }
	public static void LoadScore(string leaderboardId, int from, int to, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) {

		#if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
			_loadLeaderboardScore(leaderboardId, (int) timeSpan, (int) collection, from, to);
		#endif

	}
 public static void LoadCurrentPlayerScore(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL)
 {
     LoadLeaderboardInfo(leaderboardId);
 }
示例#28
0
 public static void ShowLeaderboard(string leaderboardId, GK_TimeSpan timeSpan)
 {
             #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
     _showLeaderboard(leaderboardId, (int)timeSpan);
             #endif
 }
示例#29
0
 public static void LoadCurrentPlayerScore(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL)
 {
             #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
     _getLeaderboardScore(leaderboardId, (int)timeSpan, (int)collection);
             #endif
 }
示例#30
0
    private IEnumerator LoadCurrentPlayerScoreLocal(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL)
    {
        yield return(new WaitForSeconds(4f));

        LoadCurrentPlayerScore(leaderboardId, timeSpan, collection);
    }
示例#31
0
	public static void ShowLeaderboard(string leaderboardId, GK_TimeSpan timeSpan) {
		#if (UNITY_IPHONE && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE
			_showLeaderboard(leaderboardId, (int) timeSpan);
		#endif
	}
示例#32
0
 public static void LoadScore(string leaderboardId, int from, int to, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL)
 {
             #if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
     _loadLeaderboardScore(leaderboardId, (int)timeSpan, (int)collection, from, to);
             #endif
 }
示例#33
0
	public static void LoadScore(string leaderboardId, int startIndex, int length, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL) {


		#if (UNITY_IPHONE && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE
		_ISN_loadLeaderboardScore(leaderboardId, (int) timeSpan, (int) collection, startIndex, length);
		#endif

	}
	public static void LoadCurrentPlayerScore(string leaderboardId, GK_TimeSpan timeSpan = GK_TimeSpan.ALL_TIME, GK_CollectionType collection = GK_CollectionType.GLOBAL)  {
		#if (UNITY_IPHONE && !UNITY_EDITOR) || SA_DEBUG_MODE
		_getLeaderboardScore(leaderboardId, (int) timeSpan, (int) collection);
		#endif
	}