示例#1
0
        public static List <ProxyRoom> GetWaitMatchRoom()
        {
            Dictionary <int, ProxyRoom> rooms;

            Monitor.Enter(rooms = ProxyRoomMgr.m_rooms);
            List <ProxyRoom> waitMatchRoomUnsafe;

            try
            {
                waitMatchRoomUnsafe = ProxyRoomMgr.GetWaitMatchRoomUnsafe();
            }
            finally
            {
                Monitor.Exit(rooms);
            }
            return(waitMatchRoomUnsafe);
        }
示例#2
0
        private static void PickUpRooms(long tick)
        {
            List <ProxyRoom> rooms = ProxyRoomMgr.GetWaitMatchRoomUnsafe();

            rooms.Sort();
            int  pairs = 0;
            long begin = TickHelper.GetTickCount();

            if (ProxyRoomMgr.ShowTick)
            {
                log.DebugFormat("-----begin pickup----tick:{0}-----rooms:{1}", begin, rooms.Count);
            }
            foreach (ProxyRoom red in rooms)
            {
                red.PickUpCount++;
                int       maxScore  = -2147483648;
                ProxyRoom matchRoom = null;
                if (!red.IsPlaying)
                {
                    if (red.GameType == eGameType.ALL)
                    {
                        foreach (ProxyRoom blue in rooms)
                        {
                            //判断是不是同一个公会或不是同一个区
                            if (blue.GuildId != red.GuildId || blue.AreaID != red.AreaID)
                            {
                                if (blue != red && !blue.IsPlaying && blue.PlayerCount == red.PlayerCount)
                                {
                                    int score = ProxyRoomMgr.CalculateScore(red, blue);
                                    if (score > maxScore || matchRoom == null)
                                    {
                                        if (red.AreaID == blue.AreaID || red.IsArea && blue.IsArea)
                                        {
                                            maxScore  = score;
                                            matchRoom = blue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (red.GameType == eGameType.Guild)
                        {
                            foreach (ProxyRoom blue in rooms)
                            {
                                if (blue.GuildId == 0 || blue.AreaID != red.AreaID || blue.GuildId != red.GuildId)
                                {
                                    if (blue != red && blue.GameType != eGameType.Free && !blue.IsPlaying && blue.PlayerCount == red.PlayerCount)
                                    {
                                        int score = ProxyRoomMgr.CalculateScore(red, blue);
                                        if (score >= maxScore || matchRoom == null)
                                        {
                                            if (red.AreaID == blue.AreaID || red.IsArea && blue.IsArea)
                                            {
                                                maxScore  = score;
                                                matchRoom = blue;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (ProxyRoom blue in rooms)
                            {
                                if (blue.GuildId == 0 || blue.GuildId != red.GuildId || blue.AreaID != red.AreaID)
                                {
                                    if (blue != red && blue.GameType != eGameType.Guild && !blue.IsPlaying && blue.PlayerCount == red.PlayerCount)
                                    {
                                        int score = ProxyRoomMgr.CalculateScore(red, blue);
                                        if (score >= maxScore || matchRoom == null)
                                        {
                                            if (red.AreaID == blue.AreaID || red.IsArea && blue.IsArea)
                                            {
                                                maxScore  = score;
                                                matchRoom = blue;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (matchRoom != null)
                    {
                        if (red.PickUpCount >= 2)
                        {
                            pairs++;
                            ProxyRoomMgr.StartMatchGame(red, matchRoom);
                        }
                    }
                }
            }
            ProxyRoomMgr.SendInfoToAllGameServer();
            if (ProxyRoomMgr.ShowTick)
            {
                long end = TickHelper.GetTickCount();
                Console.WriteLine("-----end pickup----tick:{0}-----spends:{1} --- pairs:{2}", end, end - begin, pairs);
            }
        }