private void SwitchEnableAllowStartBtn(NiuNiu.Room room, int playerNumber) { Debug.Log("设置开始游戏按钮遮罩 Loop:" + room.currentLoop); if (room.currentLoop != 0) { if (startBtnMask != null) { startBtnMask.gameObject.SetActive(false); } } else { for (int i = 0; i < room.SeatList.Count; i++) { if (room.SeatList[i].PlayerId > 0 && !room.SeatList[i].IsReady) { if (startBtnMask != null) { startBtnMask.gameObject.SetActive(true); } return; } } if (startBtnMask != null) { startBtnMask.gameObject.SetActive(false); } } }
/// <summary> /// 计算座位的客户端序号 /// </summary> /// <param name="room">房间信息</param> private void CalculateSeatIndex(NiuNiu.Room room) { PlayerSeat = null; if (room == null) { return; } for (int i = 0; i < room.SeatList.Count; ++i) { if (room.SeatList[i].PlayerId == AccountProxy.Instance.CurrentAccountEntity.passportId) { PlayerSeat = room.SeatList[i]; for (int j = 0; j < room.SeatCount; ++j) { NiuNiu.Seat seat = room.SeatList[j]; int seatIndex = seat.Pos - PlayerSeat.Pos; seatIndex = seatIndex < 0 ? seatIndex + ROOM_SEAT_COUNT : seatIndex; seat.Index = seatIndex; } break; } } if (PlayerSeat == null) { PlayerSeat = room.SeatList[0]; for (int j = 0; j < room.SeatCount; ++j) { NiuNiu.Seat seat = room.SeatList[j]; int seatIndex = seat.Pos - PlayerSeat.Pos; seatIndex = seatIndex < 0 ? seatIndex + ROOM_SEAT_COUNT : seatIndex; seat.Index = seatIndex; } } }
/// <summary> ///开启8局结算 /// </summary> public void ShowConclusionClusionPanel(NiuNiu.Room room) { //设置微信分享显影 SetWeiXinShartBtn(); //根据人数加载结算Item LoadConclusionItem(room); //开启自动跳转场景协调程序 OnOffExitRoom(true); NiuNiuWindWordAni.GameOverViewAni(_ConclusionClusionPanel); //_ConclusionClusionPanel.gameObject.SetActive(true); }
/// <summary> /// 显影 准备按钮 /// </summary> /// <param name="room"></param> /// <param name="PlayerSeat"></param> void SwitchReadyBtn(NiuNiu.Room room, NiuNiu.Seat PlayerSeat) { if (room.currentLoop == 0 && room.roomStatus == NN_ENUM_ROOM_STATUS.IDLE && !PlayerSeat.IsBanker && !PlayerSeat.IsReady) { if (_ReadyBtn.gameObject.activeSelf == false) { _ReadyBtn.gameObject.SetActive(true); } } else { if (_ReadyBtn.gameObject.activeSelf == true) { _ReadyBtn.gameObject.SetActive(false); } } }
void LoadConclusionItem(NiuNiu.Room room) { int num = 0; for (int i = 0; i < room.SeatList.Count; i++) { if (room.SeatList[i].PlayerId > 0) { num++; } } if (num <= 0) { return; } if (num > 0) { itemInfoList = NiuNiuSort.Instance.SortList(room.SeatList, (int)NiuNiu.sortRule.score); } if (itemInfoList.Count <= 0) { return; } for (int i = _mountPoint.childCount - 1; i >= 0; i++) { GameObject go = _mountPoint.GetChild(i).gameObject; Destroy(go); } for (int i = 0; i < itemInfoList.Count; i++) { GameObject go = Instantiate(_itemConclusionTemplate, _mountPoint); go.SetActive(true); //设置其中具体信息 go.GetComponent <NiuNiuConclusionItem>().SetConclusionItem(itemInfoList[i], (i + 1)); } }
/// <summary> /// //开关房间倒计时 /// </summary> /// <param name="room"></param> void OnCountDownUpdate(TransferData data) { NiuNiu.Room room = data.GetValue <Room>("CurrentRoom"); if (room.roomStatus == NN_ENUM_ROOM_STATUS.POUR || room.roomStatus == NN_ENUM_ROOM_STATUS.LOOKPOCKER || room.roomStatus == NN_ENUM_ROOM_STATUS.HOG || room.roomStatus == NN_ENUM_ROOM_STATUS.IDLE) { //计算倒计时剩余时间 TalculateRemainingTime(room.serverTime); _Countdown.gameObject.SetActive(true); countdownNoOff = true; SetCountdownUI((int)countdownTime); } else { if (_Countdown.gameObject.activeSelf == true) { //初始倒计时 InitCountdownUI(); } } }
/// <summary> /// 处理开关 换庄系列(换庄 抢庄等) /// </summary> /// <param name="seat"></param> /// <param name="room"></param> public void SwitchDecisionBnaker(NiuNiu.Seat seat, NiuNiu.Room room, int playerNumber) { NN_ENUM_ROOM_STATUS roomStatus = room.roomStatus; bool currActiveSelfBankerBtn = _BankerBtnParent.gameObject.activeSelf; bool currActiveSelfNoBankerBtn = _NoBankerBtnParent.gameObject.activeSelf; Debug.Log(string.Format("处理开关换庄按钮 房间状态:{0},自己ID:{1},庄:{2}", roomStatus.ToString(), seat.PlayerId, seat.IsBanker)); if (roomStatus == NN_ENUM_ROOM_STATUS.IDLE || roomStatus == NN_ENUM_ROOM_STATUS.DISSOLVE) { //庄 if (seat.IsBanker && playerNumber >= 2) { if (currActiveSelfBankerBtn == false) { _BankerBtnParent.gameObject.SetActive(true); NiuNiuWindWordAni.PopUp(_BankerBtnParent); } } else { _BankerBtnParent.gameObject.SetActive(false); } //非庄 //if (!seat.IsBanker && currActiveSelfBankerBtn == true) //{ _NoBankerBtnParent.gameObject.SetActive(false); //} } else if (roomStatus == NN_ENUM_ROOM_STATUS.HOG) { _BankerBtnParent.gameObject.SetActive(false); if (room.roomModel == Room.RoomModel.robBanker) { _NoBankerBtnParent.gameObject.SetActive(seat.isAlreadyHOG == 0 && seat.PokerList[0].index > 0); if (seat.isAlreadyHOG == 0 && seat.PokerList[0].index > 0 && currActiveSelfNoBankerBtn == false) { NiuNiuWindWordAni.PopUp(_NoBankerBtnParent); } } else if (room.roomModel == Room.RoomModel.AbdicateBanker) { _NoBankerBtnParent.gameObject.SetActive(!seat.IsBanker && seat.isAlreadyHOG == 0); if (!seat.IsBanker && seat.isAlreadyHOG == 0 && currActiveSelfNoBankerBtn == false) { NiuNiuWindWordAni.PopUp(_NoBankerBtnParent); } } } else { if (currActiveSelfBankerBtn) { _BankerBtnParent.gameObject.SetActive(false); } if (currActiveSelfNoBankerBtn) { _NoBankerBtnParent.gameObject.SetActive(false); } return; } }
/// <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()); } }