Exemplo n.º 1
0
        public override void DoAction(IEventArgs args)
        {
            SimpleProto builder = FreePool.Allocate();

            builder.Key = FreeMessageConstant.GroupTechStatUI;

            builder.Ins.Add(args.GameContext.player.count);

            List <TechStat> list = new List <TechStat>();

            int  index    = 0;
            bool needSort = true;

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                TechStat ts = new TechStat(p, index++);
                builder.Ps.Add(ts.ToMessage());
                list.Add(ts);
                if (!p.statisticsData.Statistics.DataCollectSwitch)
                {
                    needSort = false;
                }
            }

            if (needSort)
            {
                list.Sort(KillComparater);
                if (list.Count > 0 && list[0].kill > 0)
                {
                    TechStat ts = list[0];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Ace);
                }
                if (list.Count > 1 && list[1].kill > 0)
                {
                    TechStat ts = list[1];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Second);
                }
                if (list.Count > 2 && list[2].kill > 0)
                {
                    TechStat ts = list[2];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Third);
                }

                list.Sort(KdComparater);
                if (list.Count > 0 && list[0].kd > 0)
                {
                    TechStat ts = list[0];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.KdKing);
                }
            }

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                FreeMessageSender.SendMessage(p, builder);
            }
        }
        public override void DoAction(IEventArgs args)
        {
            SimpleProto builder = FreePool.Allocate();

            builder.Key = FreeMessageConstant.GroupTechStatUI;

            bool            needSort      = true;
            bool            rescueEnabled = args.GameContext.session.commonSession.RoomInfo.TeamCapacity > 1;
            List <TechStat> list          = new List <TechStat>();
            int             index         = 0;

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                TechStat ts = new TechStat(p, index++, rescueEnabled);
                builder.Ps.Add(ts.ToMessage());
                list.Add(ts);
                if (!p.statisticsData.Statistics.DataCollectSwitch)
                {
                    needSort = false;
                }
            }
            builder.Ins.Add(index);

            if (needSort)
            {
                if (rescueEnabled)
                {
                    list.Sort(HitDownComparater);
                }
                else
                {
                    list.Sort(KillComparater);
                }

                if (list.Count > 0 && ((list[0].kill > 0 && !rescueEnabled) || (list[0].hitDownCount > 0 && rescueEnabled)))
                {
                    builder.Ps[list[0].index].Ins[2] |= 1 << (int)EUIGameTitleType.Ace;
                }
                if (list.Count > 1 && ((list[1].kill > 0 && !rescueEnabled) || (list[1].hitDownCount > 0 && rescueEnabled)))
                {
                    builder.Ps[list[1].index].Ins[2] |= 1 << (int)EUIGameTitleType.Second;
                }
                if (list.Count > 2 && ((list[2].kill > 0 && !rescueEnabled) || (list[2].hitDownCount > 0 && rescueEnabled)))
                {
                    builder.Ps[list[2].index].Ins[2] |= 1 << (int)EUIGameTitleType.Third;
                }

                if (rescueEnabled)
                {
                    list.Sort(HdComparater);
                }
                else
                {
                    list.Sort(KdComparater);
                }

                if (list.Count > 0 && list[0].kd > 0)
                {
                    builder.Ps[list[0].index].Ins[2] |= 1 << (int)EUIGameTitleType.KdKing;
                }
            }

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                FreeMessageSender.SendMessage(p, builder);
            }
        }