Esempio n. 1
0
    void RequestMyLeaderboardFinish(string param)
    {
        loading.SetActive(false);

        KTPlayLeaderboard.KTLeaderboardCallbackParams leaderParams = new KTPlayLeaderboard.KTLeaderboardCallbackParams(param);
        switch (leaderParams.leaderboardEventResult)
        {
        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.KTPlayLeaderboardEventFriendsLeaderboard:
        {
        }
        break;

        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.KTPlayLeaderboardEventGlobalLeaderboard:
        {
            RecycleAllMyRankItem();

            ArrayList users = leaderParams.globalLeaderboardPaginator.items;

            Debug.Log("RequestMyLeaderboardFinish rank item count : " + users.Count.ToString());

            int index = 0;
            foreach (KTUser user in users)
            {
                RankItem rankItem = GetRankItem(myRankTable.gameObject);
                rankItem.name = string.Format("RankItem{0}", index);
                rankItem.Data = new RankData(user.nickname, (int)user.rank, user.score);

                bool isPlayer = (user.userId.Equals(KTAccountManager.CurrentAccount().userId));
                rankItem.IsPlayer = isPlayer;
                myRankItems.Add(rankItem);
                index++;
            }
            myRankTable.repositionNow = true;
        }
        break;

        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.KTPlayLeaderboardEventReportScore:
        {
            Debug.Log("KTPlayParams.KTPlayLeaderboardEventReportScore");
            Debug.Log("[reportScore requestInfo] leaderboardId = " + leaderParams.leaderboardId + " score = " + leaderParams.score);
        }
        break;

        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.OnKTError:
        {
            KTError error = (KTError)leaderParams.playError;
            Debug.Log("KTPlayParams.OnKTPlayError:" + "   code:" + error.code + "    description:" + error.description);
        }
        break;
        }
    }
Esempio n. 2
0
    void RequestGameLeaderboardFinish(string param)
    {
        loading.SetActive(false);
        KTPlayLeaderboard.KTLeaderboardCallbackParams leaderParams = new KTPlayLeaderboard.KTLeaderboardCallbackParams(param);
        switch (leaderParams.leaderboardEventResult)
        {
        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.KTPlayLeaderboardEventFriendsLeaderboard:
        {
        }
        break;

        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.KTPlayLeaderboardEventGlobalLeaderboard:
        {
            RecycleAllTopRankItem();

            ArrayList users = leaderParams.globalLeaderboardPaginator.items;
            Debug.Log("RequestGameLeaderboardFinish rank item count : " + users.Count.ToString());

            int index = 0;
            foreach (KTUser user in users)
            {
                RankItem rankItem = GetRankItem(topRankTable.gameObject);
                rankItem.name = string.Format("RankItem{0}", index);
                rankItem.Data = new RankData(user.nickname, (int)user.rank, user.score);
                topRankItems.Add(rankItem);
                index++;
            }
            topRankTable.repositionNow = true;

            if (KTAccountManager.IsLoggedIn())
            {
                Debug.Log("Start Load My Rank");
                loginButton.SetActive(false);
                int myRank     = (int)KTAccountManager.CurrentAccount().rank;
                int startIndex = myRank - 4;
                if (startIndex < 0)
                {
                    startIndex = 0;
                }
                loading.SetActive(true);
                LeaderboardManager.RequestGameLeaderboard(GameSystem.GetInstance().CurrentMode, GameSystem.GetInstance().CurrentModeType, this, RequestMyLeaderboardFinish, startIndex);
            }
            else
            {
                loginButton.SetActive(true);
                RecycleAllMyRankItem();
            }
        }
        break;

        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.KTPlayLeaderboardEventReportScore:
        {
            Debug.Log("KTPlayParams.KTPlayLeaderboardEventReportScore");
            Debug.Log("[reportScore requestInfo] leaderboardId = " + leaderParams.leaderboardId + " score = " + leaderParams.score);
        }
        break;

        case KTPlayLeaderboard.KTLeaderboardCallbackParams.KTLeaderboardEvent.OnKTError:
        {
            KTError error = (KTError)leaderParams.playError;
            Debug.Log("KTPlayParams.OnKTPlayError:" + "   code:" + error.code + "    description:" + error.description);
        }
        break;
        }
    }