public static int JoinMatchQueue(this MatchRoomComponent matchRoomComponent, long matchRoomId, User user, IResponse iResponse) { try { if (matchRoomComponent.mUserInQueue.ContainsKey(user.UserId)) { iResponse.Message = "用户已经在队列里面"; return(1);//用户已经在队列里面 } else { if (!matchRoomComponent.mAllQueueDics.ContainsKey(matchRoomId)) { iResponse.Message = "要加入的匹配房间不存在"; return(2);//要加入的匹配房间不存在 } MatchRoomConfig matchRoomConfig = Game.Scene.GetComponent <GameMatchRoomConfigComponent>().GetMatachRoomInfo(matchRoomId); if (user.Beans < matchRoomConfig.BesansLowest) { iResponse.Message = "豆子不足"; return(2);//豆子数不足 } matchRoomComponent.mUserInQueue.Add(user.UserId, matchRoomId); matchRoomComponent.mAllQueueDics[matchRoomId].Add(user); iResponse.Message = string.Empty; return(0);//成功加入 } } catch (Exception e) { Log.Error(e); throw; } }
public static MatchRoomConfig Create(int number, int roomId, long toyGameId, RepeatedField <int> configs) { MatchRoomConfig matchRoomConfig = ComponentFactory.Create <MatchRoomConfig>(); matchRoomConfig.GameNumber = number; matchRoomConfig.RoomConfigs = configs; matchRoomConfig.MatchRoomId = roomId; matchRoomConfig.ToyGameId = toyGameId; return(matchRoomConfig); }
//开始匹配 public async ETTask <bool> StartMatch(int roomId) { MatchRoomConfig matchRoomConfig = await GetMatchRoomConfig(roomId); if (IsHaveReliefPayment && UserComponent.Ins.pSelfUser.Beans < 1000) { L2C_GetReliefPayment l2CGetReliefPayment = (L2C_GetReliefPayment)await SessionComponent.Instance.Call(new C2L_GetReliefPayment()); if (!string.IsNullOrEmpty(l2CGetReliefPayment.Message)) { IsHaveReliefPayment = false; UIComponent.GetUiView <NormalHintPanelComponent>().ShowHintPanel(l2CGetReliefPayment.Message); } else { UIComponent.GetUiView <PopUpHintPanelComponent>().ShowOptionWindow("成功领取救济金 每日三次", null, PopOptionType.Single); } } if (matchRoomConfig.BesansLowest > UserComponent.Ins.pSelfUser.Beans) { UIComponent.GetUiView <PopUpHintPanelComponent>().ShowOptionWindow("豆子数低于房间最低限制 是否购买", ShowShop); return(false); } M2C_StartMatch m2CStartMatch = (M2C_StartMatch)await SessionComponent.Instance.Call(new C2M_StartMatch() { MatchRoomId = roomId }); if (!string.IsNullOrEmpty(m2CStartMatch.Message)) { UIComponent.GetUiView <NormalHintPanelComponent>().ShowHintPanel(m2CStartMatch.Message); return(false); } else { return(true); } }
//检测能不能匹配成功 public static void DetectionMatchCondition(this MatchRoomComponent matchRoomComponent, long matchRoomId) { try { MatchRoomConfig matchRoomConfig = Game.Scene.GetComponent <GameMatchRoomConfigComponent>().GetMatachRoomInfo(matchRoomId); while (matchRoomComponent.mAllQueueDics[matchRoomId].Count >= matchRoomConfig.GameNumber) { M2S_StartGame m2SStartGame = new M2S_StartGame(); m2SStartGame.RoomConfig = matchRoomConfig; for (int i = 0; i < matchRoomConfig.GameNumber; i++) { _TemporarayActorId = 0; _IsAI = false; if (matchRoomComponent.mAllQueueDics[matchRoomId][i].GetComponent <UserGateActorIdComponent>() != null) { _TemporarayActorId = matchRoomComponent.mAllQueueDics[matchRoomId][i].GetComponent <UserGateActorIdComponent>().ActorId; } else { _IsAI = true; } MatchPlayerInfo matchPlayer = MatchPlayerInfoFactory.Create(matchRoomComponent.mAllQueueDics[matchRoomId][i], _TemporarayActorId, i, _IsAI); m2SStartGame.MatchPlayerInfos.Add(matchPlayer); } matchRoomComponent.PlayerStartGame(matchRoomId, matchRoomConfig.GameNumber); //随机分配一个游戏服务器并告知他开始一局游戏 long toyGameId = Game.Scene.GetComponent <GameMatchRoomConfigComponent>().GetMatachRoomInfo(matchRoomId).ToyGameId; matchRoomComponent.RoomStartGame(toyGameId, m2SStartGame); } } catch (Exception e) { Log.Error(e); throw; } }
public static void CheckMatchCondition(this MatchRoomComponent matchRoomComponent, long matchRoomId) { try { MatchRoomConfig matchRoomConfig = Game.Scene.GetComponent <MatchRoomConfigComponent>().GetMatchRoomInfo(matchRoomId); while (matchRoomComponent.mAllQueue[matchRoomId].Count >= matchRoomConfig.GameNumber) { M2S_StartGame m2S_StartGame = new M2S_StartGame(); m2S_StartGame.RoomConfig = matchRoomConfig; for (int i = 0; i < matchRoomConfig.GameNumber; i++) { _TempActorId = 0; _IsAI = false; if (matchRoomComponent.mAllQueue[matchRoomId][i].GetComponent <UserGateActorIdComponent>() != null) { _TempActorId = matchRoomComponent.mAllQueue[matchRoomId][i].GetComponent <UserGateActorIdComponent>().ActorId; } else { _IsAI = true; } MatchPlayerInfo matchPlayerInfo = MatchPlayerInfoFactory.Create(matchRoomComponent.mAllQueue[matchRoomId][i], _TempActorId, i, _IsAI);; m2S_StartGame.MatchPlayerInfos.Add(matchPlayerInfo); } matchRoomComponent.MatchStartGame(matchRoomId, matchRoomConfig.GameNumber); long toyGameId = Game.Scene.GetComponent <MatchRoomConfigComponent>().GetMatchRoomInfo(matchRoomId).ToyGameId; matchRoomComponent.RoomStartGame(toyGameId, m2S_StartGame); } } catch (System.Exception ex) { Log.Error(ex); throw; } }
//创建房卡匹房间 public static MatchRoom Create(RepeatedField <int> roomConfigLists, long toyGameId, int roomId, int friendsCircleId, long userJewelNum, IResponse iResponse) { int needJeweNumCount = 0; int number = 0; bool isAADeductJewel = false; //效验房间配置正不正确 不正确的值会修改为默认值 会赋值 需要的钻石数 和房间配置人数 if (!RoomConfigIntended.IntendedRoomConfigParameter(roomConfigLists, toyGameId, ref needJeweNumCount, ref number, ref isAADeductJewel)) { iResponse.Message = "房间配置表错误"; return(null); } //如果是亲友圈房间亲友圈的 圈主钻石数要大于100 if (friendsCircleId > 0 && userJewelNum < 100) { iResponse.Message = "亲友圈主人钻石不足100"; return(null); } if (userJewelNum < needJeweNumCount) { iResponse.Message = "钻石不足"; return(null); } MatchRoom matchRoom = ComponentFactory.Create <MatchRoom>(); MatchRoomConfig roomConfig = MatchRoomConfigFactory.Create(number, roomId, toyGameId, roomConfigLists); matchRoom.RoomId = roomId; matchRoom.FriendsCircleId = friendsCircleId; matchRoom.RoomConfig = roomConfig; matchRoom.RoomType = RoomType.RoomCard; matchRoom.NeedJeweNumCount = needJeweNumCount; matchRoom.IsAADeductJewel = isAADeductJewel; return(matchRoom); }
public static MatchRoom CreateRandomMatchRoom(int roomId, RepeatedField <MatchPlayerInfo> matchPlayerInfos, MatchRoomConfig config) { try { MatchRoom matchRoom = ComponentFactory.Create <MatchRoom>(); matchRoom.RoomId = roomId; matchRoom.RoomConfig = config; for (int i = 0; i < matchPlayerInfos.Count; i++) { matchRoom.PlayerInfoDic[matchPlayerInfos[i].SeatIndex] = matchPlayerInfos[i]; } return(matchRoom); } catch (System.Exception ex) { Log.Error(ex); throw; } }
//创建随机匹配房间 public static MatchRoom CreateRandomMatchRoom(long toyGameId, int roomId, RepeatedField <MatchPlayerInfo> matchPlayerInfos, MatchRoomConfig matchRoomConfig) { try { MatchRoom matchRoom = ComponentFactory.Create <MatchRoom>(); matchRoom.RoomId = roomId; matchRoom.RoomType = RoomType.Match; matchRoom.RoomConfig = matchRoomConfig; for (int i = 0; i < matchPlayerInfos.Count; i++) { matchRoom.PlayerInfoDic[matchPlayerInfos[i].SeatIndex] = matchPlayerInfos[i]; } return(matchRoom); } catch (Exception e) { Log.Error(e); throw; } }