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); }
private static void PickUpRooms(long tick) { List <ProxyRoom> waitMatchRoomUnsafe = ProxyRoomMgr.GetWaitMatchRoomUnsafe(); foreach (ProxyRoom current in waitMatchRoomUnsafe) { int num = -2147483648; ProxyRoom proxyRoom = null; if (!current.IsPlaying) { if (current.GameType == eGameType.ALL) { using (List <ProxyRoom> .Enumerator enumerator2 = waitMatchRoomUnsafe.GetEnumerator()) { while (enumerator2.MoveNext()) { ProxyRoom current2 = enumerator2.Current; if ((current2.GuildId == 0 || current2.GuildId != current.GuildId) && current2 != current && !current2.IsPlaying && current2.PlayerCount == current.PlayerCount) { int num2 = GuildMgr.FindGuildRelationShip(current.GuildId, current2.GuildId) + 1; int gameType = (int)current2.GameType; int num3 = Math.Abs(current.AvgLevel - current2.AvgLevel); int num4 = Math.Abs(current.FightPower - current2.FightPower); int num5 = num2 * 10000 + gameType * 1000 + num4 + num3; if (num5 > num) { proxyRoom = current2; } } } goto IL_2A7; } goto IL_114; } goto IL_114; IL_2A7: if (proxyRoom != null) { ProxyRoomMgr.StartMatchGame(current, proxyRoom); continue; } continue; IL_114: if (current.GameType == eGameType.Guild) { using (List <ProxyRoom> .Enumerator enumerator3 = waitMatchRoomUnsafe.GetEnumerator()) { while (enumerator3.MoveNext()) { ProxyRoom current3 = enumerator3.Current; if ((current3.GuildId == 0 || current3.GuildId != current.GuildId) && current3 != current && current3.GameType != eGameType.Free && !current3.IsPlaying && current3.PlayerCount == current.PlayerCount) { int num6 = GuildMgr.FindGuildRelationShip(current.GuildId, current3.GuildId) + 1; int gameType2 = (int)current3.GameType; int num7 = Math.Abs(current.FightPower - current3.FightPower); int num8 = Math.Abs(current.AvgLevel - current3.AvgLevel); int num9 = num6 * 10000 + gameType2 * 1000 + num7 + num8; if (num9 > num) { proxyRoom = current3; } } } goto IL_2A7; } } foreach (ProxyRoom current4 in waitMatchRoomUnsafe) { if (current4 != current && current4.GameType != eGameType.Guild && !current4.IsPlaying && current4.PlayerCount == current.PlayerCount) { int gameType3 = (int)current4.GameType; int num10 = Math.Abs(current.AvgLevel - current4.AvgLevel); int num11 = Math.Abs(current.FightPower - current4.FightPower); int num12 = gameType3 * 1000 + num11 + num10; if (num12 > num) { proxyRoom = current4; } } } goto IL_2A7; } break; } }
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); } }