/// <summary> /// 设置菜单点击 /// </summary> /// <param name="gameId"></param> private void OnSettingMenuClick(int gameId) { m_nCurrentSelectGame = gameId; List <cfg_settingEntity> lst = cfg_settingDBModel.Instance.GetRuleByGameId(gameId); cfg_gameEntity gameEntity = cfg_gameDBModel.Instance.Get(gameId); if (gameEntity == null) { return; } int payment = gameEntity.Payment; int playerCount = 0; for (int i = 0; i < lst.Count; ++i) { cfg_settingEntity entity = lst[i]; if (entity.tags.Equals("player")) { List <cfg_settingEntity> options = cfg_settingDBModel.Instance.GetOptionsByRuleNameAndGameId(entity.gameId, entity.label); for (int j = 0; j < options.Count; ++j) { if (options[j].init == 1) { playerCount = options[j].value; } } break; } } bool isAA = payment == 1; if (payment == 2) { for (int i = 0; i < lst.Count; ++i) { cfg_settingEntity entity = lst[i]; if (entity.tags.Equals("card")) { List <cfg_settingEntity> options = cfg_settingDBModel.Instance.GetOptionsByRuleNameAndGameId(entity.gameId, entity.label); for (int j = 0; j < options.Count; ++j) { if (options[j].init == 1) { isAA = options[j].value == 2; } } break; } } } m_UICreateRoomView.SetContent(lst, payment, isAA, playerCount); }
/// <summary> /// 设置选项是否选中 /// </summary> /// <param name="option"></param> /// <param name="isSelect"></param> private void SetOptionSelect(cfg_settingEntity option, int isSelect) { option.init = isSelect; TransferData data = new TransferData(); data.SetValue("IsOn", option.init); data.SetValue("Id", option.id); ModelDispatcher.Instance.Dispatch("OnSettingRuleOptionSelectedChange", data); SaveSetting(); }
public void SetUI(string ruleName, bool isRadio, List <cfg_settingEntity> options, Action <int> onToggle, bool isAA, int payment, int playerCount) { m_TextRuleName.SafeSetText(ruleName); if (string.IsNullOrEmpty(ruleName.Trim())) { m_TextRuleName.transform.parent.gameObject.SetActive(false); } else { m_TextRuleName.transform.parent.gameObject.SetActive(true); } for (int i = 0; i < m_Cache.Count; ++i) { m_Cache[i].gameObject.SetActive(false); } UIViewManager.Instance.LoadItemAsync("UIItemSettingOption", (GameObject prefab) => { for (int i = 0; i < options.Count; ++i) { cfg_settingEntity entity = options[i]; UIItemSettingOption item = null; if (i < m_Cache.Count) { item = m_Cache[i]; item.gameObject.SetActive(true); } else { GameObject go = Instantiate(prefab); go.SetParent(m_ToggleGroup.transform); item = go.GetComponent <UIItemSettingOption>(); m_Cache.Add(item); } item.SetUI(entity.id, isRadio, entity.name, entity.value, entity.init == 1, onToggle, entity.tags, isAA, payment, playerCount, entity.cost); } }); }
/// <summary> /// 选择选项 /// </summary> /// <param name="optionName"></param> public void SelectOption(int id) { cfg_settingEntity entity = null; for (int i = 0; i < CurrentSetting.Count; ++i) { if (CurrentSetting[i].id == id) { entity = CurrentSetting[i]; break; } } if (entity != null) { if (entity.mode == 1) { List <cfg_settingEntity> lstEntity = GetOptionsByRuleNameAndGameId(entity.gameId, entity.label); for (int i = 0; i < lstEntity.Count; ++i) { SetOptionSelect(lstEntity[i], 0); } SetOptionSelect(entity, 1); } else { SetOptionSelect(entity, entity.init == 1?0:1); } List <SettingBind> lstBind = null; if (entity.init == 1 && entity.bindSelect != null) { lstBind = entity.bindSelect; } else if (entity.init == 0 && entity.bindUnSelect != null) { lstBind = entity.bindUnSelect; } if (lstBind != null) { foreach (SettingBind bind in lstBind) { //Debug.Log(bind.status); cfg_settingEntity optionEntity = Get(bind.id); if (optionEntity == null) { continue; } optionEntity.status = bind.status; SetOptionSelect(optionEntity, bind.init); //optionEntity.init = bind.init; //if (optionEntity.mode == 1) //{ // List<cfg_settingEntity> lst = GetOptionsByRuleNameAndGameId(optionEntity.gameId, optionEntity.label); // for (int i = 0; i < lst.Count; ++i) // { // SetOptionSelect(lst[i], 0); // } // SetOptionSelect(optionEntity, 1); //} //else //{ // SetOptionSelect(optionEntity, bind.init); //} } } //PlayerPrefs.SetString("RoomSettings", LitJson.JsonMapper.ToJson(m_AllSetting)); } }
public cfg_settingDBModel() : base() { string str = PlayerPrefs.GetString("SettingCache"); if (!string.IsNullOrEmpty(str)) { string[] arr = str.Split(','); for (int i = 0; i < arr.Length; ++i) { string[] arr1 = arr[i].Split(':'); if (arr1.Length == 3) { int id = arr1[0].ToInt(); int init = arr1[2].ToInt(); for (int j = 0; j < m_List.Count; ++j) { if (m_List[j].id == id) { m_List[j].init = init; } } } if (arr1.Length == 2) { int id = arr1[0].ToInt(); int init = arr1[1].ToInt(); for (int j = 0; j < m_List.Count; ++j) { if (m_List[j].id == id) { m_List[j].init = init; } } } } } CurrentSetting = new List <cfg_settingEntity>(m_List); for (int i = 0; i < CurrentSetting.Count; ++i) { cfg_settingEntity entity = CurrentSetting[i]; List <SettingBind> lstBind = null; if (entity.init == 1 && entity.bindSelect != null) { lstBind = entity.bindSelect; } else if (entity.init == 0 && entity.bindUnSelect != null) { lstBind = entity.bindUnSelect; } if (lstBind != null) { foreach (SettingBind bind in lstBind) { //Debug.Log(bind.status); cfg_settingEntity optionEntity = Get(bind.id); if (optionEntity == null) { continue; } optionEntity.status = bind.status; //SetOptionSelect(optionEntity, bind.init); //optionEntity.init = bind.init; //if (optionEntity.mode == 1) //{ // List<cfg_settingEntity> lst = GetOptionsByRuleNameAndGameId(optionEntity.gameId, optionEntity.label); // for (int i = 0; i < lst.Count; ++i) // { // SetOptionSelect(lst[i], 0); // } // SetOptionSelect(optionEntity, 1); //} //else //{ // SetOptionSelect(optionEntity, bind.init); //} } } } }
/// <summary> /// 初始化房间信息 构建房间 /// </summary> /// <param name="proto"></param> public void InitRoom(PAIGOW_ROOM protoRoom) //------------------------使用协议类 接收全部信息 例骰子-------------------------------------------- { BankerSeat = null; CurrentRoom = new PaiJiu.Room() { currentLoop = protoRoom.loop, roomId = protoRoom.roomId, //matchId = protoRoom.matchId,//比赛场 roomStatus = protoRoom.room_status, maxLoop = protoRoom.maxLoop, mahJongSum = protoRoom.mahJongSum, }; if (protoRoom.hasLoopEnd()) { CurrentRoom.loopEnd = protoRoom.loopEnd; } if (protoRoom.hasRemainMahjong()) { CurrentRoom.remainMahjong = protoRoom.remainMahjong; } Debug.Log("初始化房间信息 构建房间 CurrentRoom 房间ID" + CurrentRoom.roomId + "状态:" + CurrentRoom.roomStatus); //收到数据存到模型基类<------------------------------<保存配置>---------------------------------------- CurrentRoom.Config.Clear(); for (int i = 0; i < protoRoom.getSettingIdList().Count; i++) { cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(protoRoom.getSettingId(i)); if (settingEntity != null) { CurrentRoom.Config.Add(settingEntity); } } //NiuNiu.RoomNiuNiuProxy //获得当前游戏模式 for (int i = 0; i < CurrentRoom.Config.Count; i++) { if (CurrentRoom.Config[i].tags.Equals("banker")) { CurrentRoom.roomModel = (ROOM_MODEL)(CurrentRoom.Config[i].value - 1); Debug.Log("服务器发送的房间 庄模式为为:" + CurrentRoom.Config[i].value); } } //------------------------------------------------骰子数据 Debug.Log("-----剩余牌墙具体信息---protoRoom.hasMahjongs_remain()--------" + protoRoom.hasMahjongs_remain()); //剩余牌墙具体信息 if (protoRoom.hasMahjongs_remain()) { Debug.Log("-----剩余牌墙具体信息-----------" + protoRoom.getMahjongs_remainList().Count); List <PAIGOW_MAHJONG> Mahjongs_remain = protoRoom.getMahjongs_remainList(); CurrentRoom.pokerWall.Clear(); for (int i = 0; i < Mahjongs_remain.Count; i++) { Poker poker = new Poker(); poker.SetPoker(Mahjongs_remain[i]); CurrentRoom.pokerWall.Add(poker); Debug.Log("-----剩余牌墙具体信息-----------" + poker.ToChinese()); } } //座位 CurrentRoom.SeatList = new List <PaiJiu.Seat>(); for (int i = 0; i < protoRoom.paigowSeatCount(); ++i) { PAIGOW_SEAT paijiu_Seat = protoRoom.getPaigowSeat(i); PaiJiu.Seat seat = new PaiJiu.Seat(); AppDebug.Log(string.Format("手牌长度" + paijiu_Seat.paigowMahjongCount())); //创建牌 接收 for (int j = 0; j < paijiu_Seat.paigowMahjongCount(); j++) { //添加空牌 seat.PokerList.Add(new Poker((j + 1), 0, 0, PAIGOW_STATUS.HIDE)); } for (int j = 0; j < paijiu_Seat.getPaigowMahjongList().Count; j++) { AppDebug.Log(string.Format("---------------------------手牌" + paijiu_Seat.getPaigowMahjongList()[j].type + "_" + paijiu_Seat.getPaigowMahjongList()[j].size)); } seat.SetSeat(paijiu_Seat); CurrentRoom.SeatList.Add(seat); if (paijiu_Seat.isBanker) { BankerSeat = seat; //庄家Pos } if (paijiu_Seat.isBanker) { Debug.Log(string.Format("庄家pos:{0} 下注{1}", paijiu_Seat.pos, paijiu_Seat.pour)); } } //已操作解散房间座位 if (protoRoom.hasOperatePosList()) { for (int i = 0; i < protoRoom.getOperatePosListList().Count; i++) { CurrentRoom.OperatePosList.Add(protoRoom.getOperatePosListList()[i]); } } //正在选庄座位 if (protoRoom.hasChooseBankerPos()) { CurrentRoom.ChooseBankerSeat = GetSeatBySeatId(protoRoom.chooseBankerPos); } //(时间戳) if (protoRoom.hasUnixtime()) { CurrentRoom.Unixtime = protoRoom.unixtime; } if (protoRoom.hasDealTime()) { CurrentRoom.dealTime = protoRoom.dealTime; } CalculateSeatIndex(CurrentRoom); PeopleCounting(); //同意房间解散人数 //if (CurrentRoom.roomStatus == PAIGOW_ENUM_ROOM_STATUS.DISSOLVE) //{ // //计算当前同意解散人数 // ADHEnterRoom(protoRoom.getPaigowSeatList()); //} //座位抢庄状态 if (BankerSeat != null && CurrentRoom.roomStatus == ROOM_STATUS.GRABBANKER) { for (int i = 0; i < CurrentRoom.SeatList.Count; i++) { CurrentRoom.SeatList[i].isGrabBanker = 0; } } AppDebug.Log(string.Format("第一个玩家信息 位置{0} 庄{1} 转化索引{2} 玩家ID{3}", CurrentRoom.SeatList[0].Pos, CurrentRoom.SeatList[0].IsBanker, CurrentRoom.SeatList[0].Index, CurrentRoom.SeatList[0].PlayerId)); AppDebug.Log(string.Format("自己玩家位置{0}", PlayerSeat.Pos)); }
///// <summary> ///// 当前游戏状态 ///// </summary> //public MahjongGameState CurrentState; ///// <summary> ///// 游戏规则 ///// </summary> //public MahjongRule Rule; #endregion #region InitRoom 初始化房间数据 public void InitRoom(ROOM_INFO protoRoom) { //ROOM_INFO protoRoom = proto.roomInfo; CurrentRoom = new RoomEntity() { //BaseScore = proto.baseScore, roomId = protoRoom.roomId, ownerId = protoRoom.ownerId, currentLoop = protoRoom.loop, //matchId = protoRoom.matchId,//比赛场ID Status = (RoomEntity.RoomStatus)protoRoom.roomStatus, maxLoop = protoRoom.maxLoop, DisbandStartTime = protoRoom.dismissTime, DisbandTime = protoRoom.dismissMaxTime, DisbandTimeMax = (int)(protoRoom.dismissMaxTime - protoRoom.dismissTime), }; CurrentRoom.HistoryPoker = new List <Poker>(); CurrentRoom.SeatList = new List <SeatEntity>(); //收到数据存到模型基类 CurrentRoom.Config.Clear(); for (int i = 0; i < protoRoom.settingIdCount(); ++i) { cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(protoRoom.getSettingId(i)); if (settingEntity != null) { CurrentRoom.Config.Add(settingEntity); } } //获得当前游戏模式 for (int i = 0; i < CurrentRoom.Config.Count; i++) { if (CurrentRoom.Config[i].tags.Equals("mode")) { //CurrentRoom.roomModel = (Room.RoomModel)CurrentRoom.Config[i].value; } } for (int i = 0; i < CurrentRoom.Config.Count; i++) { if (CurrentRoom.Config[i].tags.Equals("roomMode")) { //CurrentRoom.superModel = (Room.SuperModel)CurrentRoom.Config[i].value; //Debug.Log("服务器发送的房间 普通高级场模式为为:" + CurrentRoom.Config[i].value); } } Debug.Log("房间ID为:" + protoRoom.roomId); Debug.Log("服务器发送的房间座位长度为:" + protoRoom.getSeatInfoList().Count); CurrentRoom.SeatCount = protoRoom.getSeatInfoList().Count; CurrentRoom.SeatList = new List <SeatEntity>(); for (int i = 0; i < CurrentRoom.SeatCount; ++i) { SEAT_INFO protoSeat = protoRoom.getSeatInfo(i); SeatEntity seat = new SeatEntity(); //是否同意解散 if (protoSeat.hasSeatStatus()) { seat.DisbandState = (DisbandState)protoSeat.dismiss_status; } //庄 //seat.IsBanker = protoSeat.isBanker; //玩家ID seat.PlayerId = protoSeat.playerId; //房主 seat.isLandlord = seat.PlayerId == protoRoom.ownerId; //pos seat.Pos = protoSeat.pos; //昵称 seat.Nickname = protoSeat.nickname; //头像 seat.Avatar = protoSeat.avatar; //性别 seat.Gender = protoSeat.gender; //是否准备 seat.IsReady = protoSeat.isReady; //已有金币 seat.Gold = protoSeat.gold; //座位状态 seat.Status = (SeatEntity.SeatStatus)protoSeat.seatStatus; ////本局收益 //seat.Earnings = protoSeat.nn_earnings; ////是否是胜利者 //seat.Winner = protoSeat.isWiner; ////纬度 //if (protoSeat.hasLatitude()) seat.Latitude = protoSeat.latitude; ////经度 //if (protoSeat.hasLongitude()) seat.Longitude = protoSeat.longitude; //手牌类型 seat.pokerList = new List <Poker>(); //具体手牌 if (protoSeat.hasPokerInfo()) { List <POKER_INFO> prPokerList = protoSeat.getPokerInfoList(); Debug.Log("prPokerList:" + prPokerList.Count); for (int j = 0; j < prPokerList.Count; ++j) { seat.pokerList.Add(new Poker(prPokerList[j].index, prPokerList[j].size, prPokerList[j].color)); } seat.HandPockerNum = prPokerList.Count; } CurrentRoom.SeatList.Add(seat); if (seat.Status == SeatEntity.SeatStatus.Operate) { CurrentRoom.OperateSeat = seat; } } CalculateSeatIndex(); //上家出牌 List <Poker> recentlyPlayPoker = new List <Poker>(); List <POKER_INFO> leftPoker = new List <POKER_INFO>(); if (protoRoom.hasLeftPoker()) { leftPoker = protoRoom.leftPoker.getPokerInfoList(); } for (int i = 0; i < leftPoker.Count; ++i) { recentlyPlayPoker.Add(new Poker(leftPoker[i].index, leftPoker[i].size, leftPoker[i].color)); } int leftPokerPos = protoRoom.hasLeftPoker() ? protoRoom.leftPoker.pos : 0; CurrentRoom.CurrAlreadyPlayPos = leftPokerPos; CurrentRoom.RecentlyPlayPoker = new CombinationPokersEntity(leftPokerPos, recentlyPlayPoker, PokersType.None, 0); PaoDeKuaiHelper.CheckPokerType(CurrentRoom.RecentlyPlayPoker); Currhint = new HintPokersEntity(CurrentRoom.RecentlyPlayPoker); SeatEntity leftseat = GetSeatBySeatPos(leftPokerPos); if (leftseat != null) { if (recentlyPlayPoker.Count > 0) { leftseat.pokerList.AddRange(recentlyPlayPoker); } } SetSeatPass(CurrentRoom.RecentlyPlayPoker.Pos, CurrentRoom.OperateSeat); //if (proto.nn_room.hasUnixtime()) //{ // CurrentRoom.serverTime = proto.nn_room.unixtime;//(时间戳) //} }
} //目前运营商 #region 初始化房间数据 internal void InitRoom(GP_ROOM_CREATE proto) { CurrentRoom = new RoomEntity() { roomId = proto.room.roomId, //房间ID currentLoop = proto.room.loop, //局数 maxLoop = proto.room.maxLoop, //总局数 roomStatus = proto.room.status, //房间状态 FirstDice = proto.room.firstDice, //第一个骰子 SecondDice = proto.room.secondDice, //第二个骰子 FirstGivePos = proto.room.firstGivePos, //首发牌座位号 TotalPokerNum = proto.room.totalPokerNum, //房间牌的总数量 RemainPokerNum = proto.room.remainPokerNum, //房间剩余牌的数量 PanBase = proto.room.panBase, //锅底 IsAddPanBase = proto.room.isAddPanBase, //是否加锅底 dealSecond = proto.room.dealTime, //每局第几次 fzName = proto.room.ownerNickName, //PlayerID = 111, isGrabBankerNum = 0,//抢庄的人数 }; CurrentRoom.roomPokerList = new List <Poker>(); for (int i = 0; i < proto.room.historyPokerListCount(); i++) { GP_POKER protoPoker = proto.room.getHistoryPokerList(i); CurrentRoom.roomPokerList.Add(new Poker() { Index = protoPoker.index, //索引 Type = protoPoker.type, //花色 Size = protoPoker.size, //大小 }); } CurrentRoom.Config.Clear(); Debug.Log(proto.room.settingIdCount() + " Stting长度"); for (int i = 0; i < proto.room.settingIdCount(); ++i) { cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(proto.room.getSettingId(i)); if (settingEntity != null) { CurrentRoom.Config.Add(settingEntity); if (settingEntity.tags.Equals("isGuiZi")) { CurrentRoom.enumGuiZi = (EnumGuiZi)settingEntity.value; } if (settingEntity.tags.Equals("isTianJiuWang")) { CurrentRoom.enumTianJiuWang = (EnumTianJiuWang)settingEntity.value; } if (settingEntity.tags.Equals("isDiJiuWang")) { CurrentRoom.enumDiJiuWang = (EnumDiJiuWang)settingEntity.value; } if (settingEntity.tags.Equals("banker")) { CurrentRoom.roomMode = (RoomEntity.RoomMode)settingEntity.value; } if (settingEntity.tags.Equals("pourModel")) { CurrentRoom.betModel = (RoomEntity.BetModel)settingEntity.value; if (settingEntity.value == 1) { isBet = true; } else { isBet = false; } } if (settingEntity.tags.Equals("limit")) { CurrentRoom.scoreLimit = settingEntity.value; } if (settingEntity.tags.Equals("defaultScore")) { CurrentRoom.guDScore = settingEntity.value; } if (settingEntity.tags.Equals("isBig")) { CurrentRoom.roomPlay = (EnumPlay)settingEntity.value; } } } CurrentRoom.seatList = new List <SeatEntity>(); for (int i = 0; i < proto.room.seatListCount(); i++) { GP_SEAT op_seat = proto.room.getSeatList(i); SeatEntity seat = new SeatEntity(); seat.PlayerId = op_seat.playerId; //玩家ID seat.Nickname = op_seat.nickname; //玩家名字 seat.Avatar = op_seat.avatar; //玩家头像 seat.Gender = op_seat.gender; //玩家性别 seat.Gold = op_seat.gold; //底分 seat.Pos = op_seat.pos; //座位位置 seat.seatStatus = op_seat.status; ////座位状态 seat.IsBanker = op_seat.isBanker; //是否是庄家 seat.isDismiss = op_seat.isDismiss; //是否同意解散房间 seat.isWin = op_seat.isWin; //是否是赢家 seat.eamings = op_seat.earnings; //本次收益 seat.loopEamings = op_seat.loopEarnings; //每局收益 seat.IP = op_seat.ipAddr; //IP seat.Longitude = op_seat.longitude; //经度 seat.Latitude = op_seat.latitude; //维度 seat.IsFocus = !op_seat.isAfk; //是否在线 seat.firstPour = op_seat.getPourList(0); //一道 seat.secondPour = op_seat.getPourList(1); //二道 seat.threePour = op_seat.getPourList(2); //三道 seat.pokerList = new List <Poker>(); for (int j = 0; j < op_seat.pokerListCount(); ++j) { GP_POKER protoPoker = op_seat.getPokerList(i); seat.pokerList.Add(new Poker() { Index = protoPoker.index, //索引 Type = protoPoker.type, //花色 Size = protoPoker.size, //大小 }); } CurrentRoom.seatList.Add(seat); } CalculateSeatIndexOne(); //普通场计算座位 Index }
/// <summary> /// 字符串转换 /// </summary> /// <param name="str"></param> /// <param name="roomId"></param> /// <param name="gameId"></param> /// <param name="cfgId"></param> /// <param name="groupId"></param> /// <returns></returns> private string StringConvert(string str, int roomId = 0, int gameId = 0, int[] cfgId = null, int groupId = 0) { if (str.IndexOf("[&playerId]") > -1) { str = str.Replace("[&playerId]", AccountProxy.Instance.CurrentAccountEntity.passportId.ToString()); } if (str.IndexOf("[&groupId]") > -1) { if (groupId > 0) { str = str.Replace("[&groupId]", "群Id:" + groupId.ToString()); } else { str = str.Replace("[&groupId]", string.Empty); } } if (str.IndexOf("[&roomId]") > -1) { if (roomId == 0) { roomId = GameCtrl.Instance.GetRoomEntity().roomId; } str = str.Replace("[&roomId]", roomId.ToString()); } if (str.IndexOf("[&gameName]") > -1) { if (gameId == 0) { gameId = GameCtrl.Instance.CurrentGameId; } cfg_gameEntity entity = cfg_gameDBModel.Instance.Get(gameId); if (entity != null) { str = str.Replace("[&gameName]", entity.GameName); } } if (str.IndexOf("[&rule]") > -1) { if (cfgId == null) { List <cfg_settingEntity> lst = GameCtrl.Instance.GetRoomEntity().Config; string temp = string.Empty; for (int i = 0; i < lst.Count; ++i) { temp += lst[i].name + " "; } str = str.Replace("[&rule]", temp); } else { string temp = string.Empty; for (int i = 0; i < cfgId.Length; ++i) { cfg_settingEntity entity = cfg_settingDBModel.Instance.Get(cfgId[i]); if (entity != null) { temp += entity.name + " "; } } str = str.Replace("[&rule]", temp); } } return(str); }
/// <summary> /// 初始化房间信息 构建房间 /// </summary> /// <param name="proto"></param> public void InitCurrentRoom(NN_ROOM_CREATE proto) { BankerSeat = null; CurrentRoom = new NiuNiu.Room(); //收到数据存到模型基类 <------------------------------<保存配置>---------------------------------------- CurrentRoom.Config.Clear(); for (int i = 0; i < proto.nn_room.settingIdCount(); ++i) { cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(proto.nn_room.getSettingId(i)); if (settingEntity != null) { CurrentRoom.Config.Add(settingEntity); } } //获得当前游戏模式 for (int i = 0; i < CurrentRoom.Config.Count; i++) { if (CurrentRoom.Config[i].tags.Equals("mode")) { CurrentRoom.roomModel = (Room.RoomModel)CurrentRoom.Config[i].value; Debug.Log("服务器发送的房间 庄模式为为:" + CurrentRoom.Config[i].value); //#if IS_GUGENG // if (CurrentRoom.roomModel == Room.RoomModel.EveryTime || CurrentRoom.roomModel == Room.RoomModel.WinnerByBanker) // CurrentRoom.roomModel = Room.RoomModel.AutoBanker; //#endif } } for (int i = 0; i < CurrentRoom.Config.Count; i++) { if (CurrentRoom.Config[i].tags.Equals("roomMode")) { CurrentRoom.superModel = (Room.SuperModel)CurrentRoom.Config[i].value; Debug.Log("服务器发送的房间 普通高级场模式为为:" + CurrentRoom.Config[i].value); } } Debug.Log("房间ID为:" + proto.nn_room.roomId); Debug.Log("服务器发送的房间座位长度为:" + proto.nn_room.getNnSeatList().Count); CurrentRoom.roomId = proto.nn_room.roomId; CurrentRoom.roomStatus = proto.nn_room.nn_room_status; CurrentRoom.currentLoop = proto.nn_room.loop; CurrentRoom.maxLoop = proto.nn_room.maxLoop; CurrentRoom.SeatCount = proto.nn_room.getNnSeatList().Count; //CurrentRoom.SeatCount = proto.nn_room.nnSeatCount;//----------------------------------《座位长度《----------------------------------------- CurrentRoom.SeatList = new List <NiuNiu.Seat>(); for (int i = 0; i < CurrentRoom.SeatCount /*proto.nn_room.getNnSeatList().Count*/; ++i) { NN_SEAT nn_seat = proto.nn_room.getNnSeat(i); NiuNiu.Seat seat = new NiuNiu.Seat(); //NiuNiu.Seat seat = new NiuNiu.Seat(proto.nn_room.seatList[i]); //房主 seat.IsHomeowners = nn_seat.IsHomeowners;//----------------------------------《房主《----------------------------------------- //是否同意解散 if (nn_seat.hasDissolve()) { seat.Dissolve = nn_seat.dissolve; } //庄 seat.IsBanker = nn_seat.isBanker; //玩家ID seat.PlayerId = nn_seat.playerId; //pos seat.Pos = nn_seat.pos; //昵称 seat.Nickname = nn_seat.nickname; //头像 seat.Avatar = nn_seat.avatar; //性别 seat.Gender = nn_seat.gender; //是否准备 seat.IsReady = nn_seat.ready; //已有金币 seat.Gold = nn_seat.gold; //本局收益 seat.Earnings = nn_seat.nn_earnings; //是否是胜利者 seat.Winner = nn_seat.isWiner; //下注 seat.Pour = nn_seat.pour; //纬度 if (nn_seat.hasLatitude()) { seat.Latitude = nn_seat.latitude; } //经度 if (nn_seat.hasLongitude()) { seat.Longitude = nn_seat.longitude; } //手牌类型 if (nn_seat.hasNnPokerType()) { if (nn_seat.nn_pokerType != 0) { seat.PockeType = (int)nn_seat.nn_pokerType; } } seat.PokerList = new List <Poker>(); //具体手牌 //if (nn_seat.getNnPokerList() != null && nn_seat.getNnPokerList().Count > 0) //{ for (int j = 0; j < 5; j++)//nn_seat.nnPokerCount() { NN_POKER protoPoker = null; if (nn_seat.nnPokerCount() > j) { protoPoker = nn_seat.getNnPoker(j); } NiuNiu.Poker poker = new NiuNiu.Poker(); if (protoPoker != null && protoPoker.hasIndex() && protoPoker.index != 0) { //seat.PokerList[j].SetPoker(nn_seat.PokerList[j]); poker.color = protoPoker.color; poker.index = protoPoker.index; poker.size = protoPoker.size; poker.status = protoPoker.pokerStatus; } seat.PokerList.Add(poker); } //} if (seat.IsBanker) { BankerSeat = seat; //庄座位 } if (proto.nn_room.pos == seat.Pos) { CurrentRoom.RobBankerSeat = seat; //获得当前抢庄座位 } CurrentRoom.SeatList.Add(seat); } if (proto.nn_room.hasUnixtime()) { CurrentRoom.serverTime = proto.nn_room.unixtime;//(时间戳) } CalculateSeatIndex(CurrentRoom); playerSeatIndex = PlayerSeat.Pos; PeopleCounting(); if (CurrentRoom.roomModel == Room.RoomModel.robBanker && BankerSeat != null) { PlayerSeat.isAlreadyHOG = -1; } if (CurrentRoom.roomStatus == NN_ENUM_ROOM_STATUS.DISSOLVE) { //计算当前同意解散人数 ADHEnterRoom(proto.nn_room.getNnSeatList()); } }
/// <summary> /// 初始化房间 /// </summary> /// <param name="prRoom"></param> public void InitRoom(JY_ROOM prRoom) { //RoomMaJiangProxy.Instance CurrentRoom = new RoomEntity() { currentLoop = prRoom.loop, maxLoop = prRoom.maxLoop, roomId = prRoom.roomId, //matchId = prRoom.matchId, roomStatus = prRoom.status, baseScore = prRoom.baseScore, }; //房间配置 CurrentRoom.Config.Clear(); for (int i = 0; i < prRoom.settingIdCount(); ++i) { cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(prRoom.getSettingId(i)); if (settingEntity != null) { CurrentRoom.Config.Add(settingEntity); } } //RoomPaiJiuProxy //创建座位 CurrentRoom.SeatList = new List <SeatEntity>(); for (int i = 0; i < prRoom.seatListCount(); i++) { JY_SEAT jySeat = prRoom.getSeatList(i); SeatEntity seat = new SeatEntity(); //手牌 for (int j = 0; j < jySeat.pokerListCount(); j++) { seat.PokerList.Add(new Poker()); } seat.SetSeat(jySeat); CurrentRoom.SeatList.Add(seat); if (seat.IsBanker) { BankerSeat = seat; } } //(时间戳) if (prRoom.hasUnixtime()) { CurrentRoom.Unixtime = prRoom.unixtime; } CalculateSeatIndex(); PeopleCounting(); }