Exemple #1
0
        public async static void RefreshWealthRank()
        {
            DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();

            rankList.Clear();
            playerBaseInfoList.Clear();
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            playerBaseInfoList.AddRange(await proxyComponent.QueryJsonRank(1));
            List <WealthRank> wealthList = Game.Scene.GetComponent <RankDataComponent>().GetWealthRankData();

            for (int i = 0; i < playerBaseInfoList.Count; ++i)
            {
                List <PlayerBaseInfo> playerbaseinfos = await proxyComponent.QueryJsonDB <PlayerBaseInfo>($"{{_id:{playerBaseInfoList[i].UId}}}");

                WealthRank rank = new WealthRank();
                rank.PlayerName = playerbaseinfos[0].Name;
                rank.GoldNum    = playerBaseInfoList[i].Wealth;
                rank.Icon       = playerbaseinfos[0].Icon;
                rank.UId        = playerbaseinfos[0].Id;
                rankList.Add(rank);
            }

            Game.Scene.GetComponent <RankDataComponent>().SetWealthRankData(rankList);
            stopwatch.Stop();
            TimeSpan timespan     = stopwatch.Elapsed;
            double   sencond      = timespan.Seconds;
            double   milliseconds = timespan.TotalMilliseconds;
        }
 protected void GetWealthRank(G2C_Rank response, WealthRank wealthRank)
 {
     for (int i = 0; i < Game.Scene.GetComponent <RankDataComponent>().GetWealthRankData().Count; ++i)
     {
         if (Game.Scene.GetComponent <RankDataComponent>().GetWealthRankData()[i].GoldNum > 0)
         {
             response.RankList.Add(Game.Scene.GetComponent <RankDataComponent>().GetWealthRankData()[i]);
         }
     }
 }
        private static async void InitWealthRankInfo()
        {
            DBProxyComponent  proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
            List <Log_Rank>   logRanklist    = new List <Log_Rank>();
            List <WealthRank> rankList       = new List <WealthRank>();

            logRanklist.AddRange(await proxyComponent.QueryJsonRank(1));
            for (int i = 0; i < logRanklist.Count; ++i)
            {
                List <PlayerBaseInfo> info = await proxyComponent.QueryJsonDB <PlayerBaseInfo>($"{{_id:{logRanklist[i].UId}}}");

                WealthRank rank = new WealthRank();
                rank.PlayerName = info[0].Name;
                rank.GoldNum    = logRanklist[i].Wealth;
                rank.Icon       = info[0].Icon;
                rank.UId        = info[0].Id;
                rankList.Add(rank);
            }
            Game.Scene.GetComponent <RankDataComponent>().SetWealthRankData(rankList);
            logRanklist = null;
            rankList    = null;
        }
Exemple #4
0
        public void SetGoldItem(WealthRank wealth, int index)
        {
            RankImg.gameObject.SetActive(index < 3);
            RankTxt.gameObject.SetActive(index >= 3);
            if (RankTxt.gameObject.activeInHierarchy)
            {
                RankTxt.text = (index + 1).ToString();
            }
            NameTxt.text = wealth.PlayerName;
            GoldTxt.text = new StringBuilder().Append(wealth.GoldNum)
                           .ToString();
            Img.sprite = CommonUtil.getSpriteByBundle("image_shop", "icon_jinbi");
            HeadManager.setHeadSprite(Icon, wealth.Icon);
            string rIcon = new StringBuilder().Append("Rank_")
                           .Append(index + 1)
                           .ToString();

            if (RankImg.gameObject.activeInHierarchy)
            {
                RankImg.sprite = CommonUtil.getSpriteByBundle("image_main", rIcon);
            }
        }
Exemple #5
0
        /// <summary>
        /// 设置排行榜信息
        /// </summary>
        public async void GetRankInfo()
        {
            UINetLoadingComponent.showNetLoading();
            G2C_Rank g2cRank = (G2C_Rank)await Game.Scene.GetComponent <SessionComponent>()
                               .Session.Call(new C2G_Rank {
                Uid = PlayerInfoComponent.Instance.uid, RankType = 0
            });

            UINetLoadingComponent.closeNetLoading();

            //设置排行榜信息
            wealthRankList = g2cRank.RankList;
            gameRankList   = g2cRank.GameRankList;

            isOwnRank  = IsInRank(PlayerInfoComponent.Instance.uid);
            isGameRank = IsInGameRank(PlayerInfoComponent.Instance.uid);

            ownRank = GetWealthIndext(PlayerInfoComponent.Instance.uid);
            ownGame = GetGameIndext(PlayerInfoComponent.Instance.uid);
            ShowGameRank();
            ownWealthRank = g2cRank.OwnWealthRank;
            ownGameRank   = g2cRank.OwnGameRank;
            SetMyGameRank();
        }
        protected override async void Run(Session session, C2G_Rank message, Action <G2C_Rank> reply)
        {
            G2C_Rank response = new G2C_Rank();

            try
            {
                DBProxyComponent      proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
                List <PlayerBaseInfo> mys            = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{message.Uid}}}");

                if (mys.Count > 0)
                {
                    List <Log_Rank> ranks = await proxyComponent.QueryJson <Log_Rank>($"{{UId:{message.Uid}}}");

                    response.RankList     = new List <WealthRank>();
                    response.GameRankList = new List <GameRank>();
                    WealthRank wealthRank = new WealthRank();
                    GameRank   gameRank   = new GameRank();
                    wealthRank.Icon       = mys[0].Icon;
                    wealthRank.PlayerName = mys[0].Name;
                    if (ranks.Count > 0)
                    {
                        wealthRank.GoldNum = ranks[0].Wealth;
                        gameRank.WinCount  = ranks[0].WinGameCount;
                    }
                    else
                    {
                        wealthRank.GoldNum = 0;
                        gameRank.WinCount  = 0;
                    }
                    wealthRank.UId      = mys[0].Id;
                    gameRank.PlayerName = mys[0].Name;
                    gameRank.Icon       = mys[0].Icon;
                    gameRank.UId        = mys[0].Id;

                    if (message.RankType == 1)
                    {
                        GetWealthRank(response, wealthRank);
                        response.OwnWealthRank = wealthRank;
                    }
                    else if (message.RankType == 2)
                    {
                        GetGameRank(response, gameRank);
                        response.OwnGameRank = gameRank;
                    }
                    else
                    {
                        GetWealthRank(response, wealthRank);
                        GetGameRank(response, gameRank);
                        response.OwnGameRank   = gameRank;
                        response.OwnWealthRank = wealthRank;
                    }
                }
                else
                {
                    Log.Error($"玩家{message.Uid}playerbaseinfo为空");
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }