Exemplo n.º 1
0
    void UpdateLevelLeardBoard(string leardid)
    {
        if (rankZone == null || rankItem == null)
        {
            return;
        }
        rankZone.transform.DetachChildren();
        List <SocialObject> socials = SocialManager.Instance.GetObjectsById(leardid);


        if (socials != null)
        {
            int itemCount = socials.Count;
            if (itemCount > 0)
            {
                for (int i = 0; i < itemCount; i++)
                {
                    //添加排名
                    SocialObject social = socials[i];
                    if (social != null)
                    {
                        GameObject item = Instantiate(rankItem);
                        SetChildText(item.transform, "TextRank", social.Rank.ToString());
                        SetChildText(item.transform, "TextUserName", social.UserName);
                        SetChildText(item.transform, "TexBestScore", social.Score);
                        //item.transform.parent = rankZone.transform;
                        item.transform.SetParent(rankZone.transform);
                    }
                }
                //if (itemCount > 5)
                //{
                //    float itemHight = rankZone.GetComponent<VerticalLayoutGroup>().cellSize.y;

                //}
            }
            rankZone.sizeDelta = new Vector2(rankZone.sizeDelta.x, itemCount * rankItemHight);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 从service里获取排名信息
    /// </summary>
    void GetRankFromService()
    {
        updating = true;
        foreach (KeyValuePair <int, string> keyVal in GameGlobalValue.LevelBoardMap)
        {
            updateUserCount += 1;
            string boardId = keyVal.Value;
            //更新用户信息
            this.GetMyScore(boardId, (ok, s) =>
            {
                if (ok)
                {
                    Player.CurrentPlayer.UpdateRank(boardId, s);
                    updatedUserCount += 1;
                    CheckUpdateStatu();
                }
            });

            if (!onlyUpdatePlayer)
            {
                updateRankCount += 1;
                //更新排行榜
                this.GetTopByByLeaderboardID(boardId, new Range(1, 25), (ok, scores) =>
                {
                    Debug.Log(ok);
                    if (ok)
                    {
                        List <SocialObject> objs = new List <SocialObject>();
                        List <string> UserIds    = new List <string>();
                        foreach (IScore s in scores)
                        {
                            if (s != null)
                            {
                                UserIds.Add(s.userID);
                            }
                        }
                        Social.LoadUsers(UserIds.ToArray(), users =>
                        {
                            foreach (IScore s in scores)
                            {
                                SocialObject obj  = new SocialObject(s);
                                IUserProfile user = FindUser(users, s.userID);
                                if (user != null)
                                {
                                    obj.UserName = FindUser(users, s.userID).userName;
                                }
                                objs.Add(obj);
                            }
                            if (SocialObjects.ContainsKey(boardId))
                            {
                                SocialObjects[boardId] = objs;
                            }
                            else
                            {
                                SocialObjects.Add(boardId, objs);
                            }
                            updatedRankCount += 1;
                            CheckUpdateStatu();
                        });
                    }
                });
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 从service里获取排名信息
    /// </summary>
    void GetRankFromService()
    {
        updating = true;
        foreach (KeyValuePair<int, string> keyVal in GameGlobalValue.LevelBoardMap)
        {
            updateUserCount += 1;
            string boardId = keyVal.Value;
            //更新用户信息
            this.GetMyScore(boardId, (ok, s) =>
            {
                if (ok)
                {
                    Player.CurrentPlayer.UpdateRank(boardId, s);
                    updatedUserCount += 1;
                    CheckUpdateStatu();
                }
            });

            if (!onlyUpdatePlayer)
            {
                updateRankCount += 1;
                //更新排行榜
                this.GetTopByByLeaderboardID(boardId, new Range(1, 25), (ok, scores) =>
                {
                    Debug.Log(ok);
                    if (ok)
                    {
                        List<SocialObject> objs = new List<SocialObject>();
                        List<string> UserIds = new List<string>();
                        foreach (IScore s in scores)
                        {
                            if(s != null)
                                UserIds.Add(s.userID);
                        }
                        Social.LoadUsers(UserIds.ToArray(), users =>
                        {
                            foreach (IScore s in scores)
                            {
                                SocialObject obj = new SocialObject(s);
                                IUserProfile user = FindUser(users, s.userID);
                                if(user != null)
                                {
                                    obj.UserName = FindUser(users, s.userID).userName;
                                }
                                objs.Add(obj);
                            }
                            if (SocialObjects.ContainsKey(boardId))
                            {
                                SocialObjects[boardId] = objs;
                            }
                            else
                            {
                                SocialObjects.Add(boardId, objs);
                            }
                            updatedRankCount += 1;
                            CheckUpdateStatu();
                        });
                    }
                });
            }
        }
    }