Example #1
0
        // 获取某个玩家的历史战绩总览
        public ActorStatisticInfo GetActorOverview(int actorID, List <int> nMatchTypeIDList = null)
        {
            ActorStatisticInfo info = null;

            if (actorStatistic.TryGetValue(actorID, out info))
            {
                // 1分钟内直接返回
                if (info.lastRequestTime + 60f > Time.unscaledTime)
                {
                    if (nMatchTypeIDList == null)
                    {
                        return(info);
                    }
                    else if (nMatchTypeIDList.Count == 1 && nMatchTypeIDList[0] == 0)
                    {
                        return(info);
                    }
                    else
                    {
                        ActorStatisticInfo result = new ActorStatisticInfo();
                        result.totalStatistic    = info.totalStatistic;
                        result.totalStatisticWar = info.totalStatisticWar.Where(v => (nMatchTypeIDList.Contains(v.nWarType))).Select(v => v).ToList();
                        return(result);
                    }
                }
            }
            else
            {
                info = new ActorStatisticInfo();
                info.totalStatistic     = new cmd_entity_update_warstatistic_total();
                info.totalStatisticWar  = new List <cmd_entity_update_warstatistic_total_warinfo>();
                actorStatistic[actorID] = info;
            }

            // 向服务器请求最新的战绩数据
            info.lastRequestTime = Time.unscaledTime;
            RequestTotalStatistic(actorID);

            return(info);
        }
Example #2
0
        // 收到服务器返回的历史战绩总览
        public void RecvTotalStatistic(IntPtr ptrParam, int nPtrLen)
        {
            IntPtrVaArgParseHelper helper = new IntPtrVaArgParseHelper(ptrParam, nPtrLen);

            cmd_entity_update_warstatistic_total totalStatistic = helper.get <cmd_entity_update_warstatistic_total>();
            ActorStatisticInfo info = null;

            if (actorStatistic.TryGetValue(totalStatistic.nActorID, out info) == false)
            {
                return;
            }
            info.totalStatistic = totalStatistic;

            info.totalStatisticWar.Clear();
            for (int i = 0; i < info.totalStatistic.nWarInfoCount; ++i)
            {
                cmd_entity_update_warstatistic_total_warinfo data = helper.get <cmd_entity_update_warstatistic_total_warinfo>();
                info.totalStatisticWar.Add(data);
            }

            UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_PLAYERWARSTATISTIC_UPDATETOTAL, null);
        }