/// <summary> /// 服务器断线重连房间消息 /// </summary> /// <param name="obj"></param> private void OnServerReturnReconnectRoom(byte[] obj) { Debug.Log("服务器返回断线重连消息"); UIViewManager.Instance.CloseWait(); NN_ROOM_CREATE proto = NN_ROOM_CREATE.decode(obj); GameStateManager.Instance.InitCurrentRoom(proto); Debug.Log("准备断线重连创建房间,自己ID:" + AccountProxy.Instance.CurrentAccountEntity.passportId); SceneMgr.Instance.LoadScene(SceneType.NiuNiu2D); }
/// <summary> /// 服务器返回创建房间消息 /// </summary> /// <param name="obj"></param> private void OnServerReturnCreateRoom(byte[] obj) { UIViewManager.Instance.CloseWait(); NN_ROOM_CREATE proto = NN_ROOM_CREATE.decode(obj); //收到配置数据存到模型基类 GameStateManager.Instance.InitCurrentRoom(proto); Debug.Log("准备创建房间,自己ID:" + AccountProxy.Instance.CurrentAccountEntity.passportId); SceneMgr.Instance.LoadScene(SceneType.NiuNiu2D); }
/// <summary> /// 初始化房间信息 构建房间 /// </summary> /// <param name="pbRoom"></param> public void InitCurrentRoom(NN_ROOM_CREATE proto) { RoomNiuNiuProxy.Instance.InitCurrentRoom(proto); }
/// <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()); } }