/// <summary> /// 加载房间后 加载已有窗口 /// </summary> /// <param name="obj"></param> private void SetEnterRoomView(object[] obj) { //加载等待解散 或 是否同意解散 PaiJiu.Room room = RoomPaiJiuProxy.Instance.CurrentRoom; PaiJiu.Seat playerSeat = RoomPaiJiuProxy.Instance.PlayerSeat; switch (room.roomStatus) { case ROOM_STATUS.DISMISS: bool isOperate = false; for (int i = 0; i < room.OperatePosList.Count; i++) { if (room.OperatePosList[i] == playerSeat.Pos) { isOperate = true; } } if (isOperate) { UIViewManager.Instance.ShowMessage("提示", "等待解散结果", MessageViewType.None); } else { UIViewManager.Instance.ShowMessage("提示", "有人发起解散房间,是否同意", MessageViewType.OkAndCancel, ClientSendAgreeDisbandRoom, ClientSendRefuseDisbandRoom, 10f, AutoClickType.Cancel); } break; } }
/// <summary> /// 准备开始下一次 /// </summary> public void NextGame() { //清空场景 PaiJiu.Room Currentroom = RoomPaiJiuProxy.Instance.CurrentRoom; //1 将用过的牌放入桌子 if (Currentroom.loopEnd) { MahJongManager_PaiJiu.Instance.ClearWall(); } for (int i = 0; i < Currentroom.SeatList.Count; i++) { if (Currentroom.SeatList[i].PlayerId > 0) { //弃牌 if (Currentroom.SeatList[i] == RoomPaiJiuProxy.Instance.PlayerSeat) { m_UIScenePaiJiu3DView.ClearHandPoker(); } SeatCtrl_PaiJiu seatCtrl = GetSeatCtrlBySeatPos(Currentroom.SeatList[i].Pos); seatCtrl.ClearHandPoker(); //如果是一局结束 清空打过的牌 if (Currentroom.loopEnd) { seatCtrl.ClearDeskTopContainer(); } //如果是一局结束 清空牌墙 } } }
/// <summary> /// 开局 /// </summary> /// <param name="room"></param> /// <param name="isPlayAnimation"></param> public void Begin(PaiJiu.Room room, bool isPlayAnimation /*, bool isReplay*/) { //CompassCtrl.Instance.SetNormal(); //指南针控制 //UIItemTingTip.Instance.Close(); //m_UISceneMaJiang3DView.Begin(); //m_UIScenePaiJiu3DView. //设置开局的 //====================初始化墙==================== if (wallList.Count == 0) //如果牌墙为空 初始化墙 { InitWall(isPlayAnimation); } DrawPoker(room, isPlayAnimation); }
/// <summary> /// 计算座位的客户端序号 /// </summary> /// <param name="room">房间信息</param> private void CalculateSeatIndex(PaiJiu.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 < CurrentRoom.SeatList.Count; ++j) { PaiJiu.Seat seat = room.SeatList[j]; int seatIndex = seat.Pos - PlayerSeat.Pos; seatIndex = seatIndex < 0 ? seatIndex + ROOM_SEAT_COUNT : seatIndex; seat.Index = seatIndex; if (CurrentRoom.SeatList.Count == 2) { if (seat.Index != 0) { seat.Index = 2; } } } break; } } if (PlayerSeat == null) { PlayerSeat = room.SeatList[0]; for (int j = 0; j < CurrentRoom.SeatList.Count; ++j) { PaiJiu.Seat seat = room.SeatList[j]; int seatIndex = seat.Pos - PlayerSeat.Pos; seatIndex = seatIndex < 0 ? seatIndex + ROOM_SEAT_COUNT : seatIndex; seat.Index = seatIndex; if (CurrentRoom.SeatList.Count == 2) { if (seat.Index != 0) { seat.Index = 2; } } } } }
/// <summary> /// 选庄时场景处理 /// </summary> public void ChooseBanker() { //清空场景 PaiJiu.Room Currentroom = RoomPaiJiuProxy.Instance.CurrentRoom; MahJongManager_PaiJiu.Instance.ClearWall(); for (int i = 0; i < Currentroom.SeatList.Count; i++) { if (Currentroom.SeatList[i].PlayerId > 0) { SeatCtrl_PaiJiu seatCtrl = GetSeatCtrlBySeatPos(Currentroom.SeatList[i].Pos); seatCtrl.ClearHandPoker(); seatCtrl.ClearDeskTopContainer(); } } }
/// <summary> /// 重建房间 /// </summary> /// <param name="room"></param> private void ReBuildRoom(PaiJiu.Room room) { //1.DEAL 发牌中 2.SETTLE 结算中 3.IDLE 空闲中 4.POUR 下注中 5.LOOP 看牌中 6.READY 准备中 7.DISMISS 解散中 8.CHOOSEBANKER 选庄中 9.GRABBANKER 抢庄中 10.CUTPOKER 切牌中 11.BEGIN 游戏开始(开局) //轮庄 1未使用 必定有牌:SETTLE LOOP 必定无牌 IDLE READY CHOOSEBANKER 可能有 POUR remainMahjong > 0 DISMISS remainMahjong > 0 //抢庄 1未使用 必定有牌:SETTLE LOOP POUR 必定无牌 IDLE READY GRABBANKER 可能有 DISMISS remainMahjong > 0 if (RoomPaiJiuProxy.Instance.CurrentRoom.roomStatus == ROOM_STATUS.BEGIN || RoomPaiJiuProxy.Instance.CurrentRoom.roomStatus == ROOM_STATUS.CUTPOKER || RoomPaiJiuProxy.Instance.CurrentRoom.roomStatus == ROOM_STATUS.SETTLE || RoomPaiJiuProxy.Instance.CurrentRoom.roomStatus == ROOM_STATUS.LOOP || (RoomPaiJiuProxy.Instance.CurrentRoom.roomStatus == ROOM_STATUS.POUR && RoomPaiJiuProxy.Instance.CurrentRoom.remainMahjong > 0) || (RoomPaiJiuProxy.Instance.CurrentRoom.roomStatus == ROOM_STATUS.DISMISS && RoomPaiJiuProxy.Instance.CurrentRoom.remainMahjong > 0) ) { Begin(room, false); } //====================确认当前游戏状态===================== RoomPaiJiuProxy.Instance.SendRoomInfoChangeNotify(); }
/// <summary> /// 座位信息变更回调 /// </summary> /// <param name="obj"></param> private void OnSeatInfoChanged(TransferData data) { PaiJiu.Seat seat = data.GetValue <PaiJiu.Seat>("Seat"); //座位 bool isPlayer = data.GetValue <bool>("IsPlayer"); //是否自己 ROOM_STATUS roomStatus = data.GetValue <ROOM_STATUS>("RoomStatus"); //房间状态 PaiJiu.Room currentRoom = data.GetValue <PaiJiu.Room>("CurrentRoom"); //当前房间 PaiJiu.Seat BankerSeat = data.GetValue <PaiJiu.Seat>("BankerSeat"); //庄家座位 PaiJiu.Seat ChooseBankerSeat = data.GetValue <PaiJiu.Seat>("ChooseBankerSeat"); //当前选庄座位 if (isPlayer) { m_ButtonReady.gameObject.SetActive(seat.seatStatus == SEAT_STATUS.SEAT_STATUS_IDLE && (roomStatus == ROOM_STATUS.IDLE || roomStatus == ROOM_STATUS.READY)); m_ButtonShare.gameObject.SetActive(seat.seatStatus == SEAT_STATUS.SEAT_STATUS_IDLE && roomStatus == ROOM_STATUS.IDLE || roomStatus == ROOM_STATUS.READY); if (!SystemProxy.Instance.IsInstallWeChat) { m_ButtonShare.gameObject.SetActive(false); } //m_CancelAuto.gameObject.SetActive(seat.IsTrustee); m_Operater.SetUI(currentRoom, seat, BankerSeat); } }
/// <summary> /// 发牌 /// </summary> /// <param name="room"></param> /// <param name="isPlayAnimation"></param> private void DrawPoker(PaiJiu.Room room, bool isPlayAnimation) { //===================摸牌======================= if (!isPlayAnimation) { for (int i = 0; i < room.SeatList.Count; i++) { PaiJiu.Seat seat = room.SeatList[i]; //桌面上的牌 for (int j = 0; j < seat.TablePokerList.Count; j++) { AppDebug.Log(string.Format("重连房间座位{0}已出的牌{1}", seat.Pos, (seat.TablePokerList[j].type + "_" + seat.TablePokerList[j].size))); MaJiangCtrl_PaiJiu majiang = MahJongManager_PaiJiu.Instance.DrawMaJiang(seat.Pos, seat.TablePokerList[j]); } //清空摸到手里的已出过的牌 if (seat.TablePokerList.Count > 0) { GetSeatCtrlBySeatPos(seat.Pos).ClearHandPoker(); } //AppDebug.Log(string.Format("------------------------------------------------重连房间座位手牌长度{0}", seat.PokerList.Count)); //手里的牌 for (int j = 0; j < seat.PokerList.Count; ++j) { //if (seat == RoomPaiJiuProxy.Instance.PlayerSeat) AppDebug.Log(string.Format("---PlayerSeat---------重连房间座位手牌{0}", seat.PokerList[j].type + "_" + seat.PokerList[j].size)); MaJiangCtrl_PaiJiu majiang = null; majiang = MahJongManager_PaiJiu.Instance.DrawMaJiang(seat.Pos, seat.PokerList[j]); //显示手牌 if (seat == RoomPaiJiuProxy.Instance.PlayerSeat) { m_UIScenePaiJiu3DView.DrawPoker(majiang); } else { GetSeatCtrlBySeatPos(seat.Pos).DrawPoker(majiang); } //DRB.MahJong.MaJiangSceneCtrl } } #if IS_ZHANGJIAKOU // 如果有牌墙具体信息 则翻开牌墙 if (room.pokerWall.Count > 0) { DrawMaJiangWall(room.pokerWall, false); } #endif } else { //清空手牌 for (int i = 0; i < room.SeatList.Count; i++) { SeatCtrl_PaiJiu seatCtrl = GetSeatCtrlBySeatPos(room.SeatList[i].Pos); if (seatCtrl != null) { seatCtrl.ClearHandPoker(); } } StartCoroutine(BeginAnimation(/*isReplay*/)); } }
/// <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> /// <param name="data"></param> //private void OnOverplusWallCountChange(TransferData data) //{ // int count = data.GetValue<int>("OverplusWallCount"); // m_TextOverplusWallCount.SafeSetText(string.Format("剩余:{0}", count.ToString())); //} /// <summary> /// 房间信息变更 (base中已注册 若要改变 需覆盖该方法) /// </summary> /// <param name="obj"></param> private void OnRoomInfoChanged(TransferData data) { Debug.Log("子类UIItemPaiJiuRoomInfo"); PaiJiu.Room entity = data.GetValue <PaiJiu.Room>("Room"); ShowLoop(entity.currentLoop, entity.maxLoop); }
IEnumerator RoomOpenPokerSettleAni(PaiJiu.Room room) { #if IS_ZHANGJIAKOU #endif List <PaiJiu.Seat> seatList = room.SeatList; if (!room.isCutPan) { //ROOM_STATUS roomStatus = room.roomStatus; yield return(0); for (int i = 0; i < seatList.Count; i++) { if (seatList[i] != null && seatList[i].PlayerId > 0 && !seatList[i].IsBanker) { RoomOpenPokerSettleAniPerform(seatList[i], room); yield return(new WaitForSeconds(PokerTypeAniIntervalTime)); } else { continue; } } //显示庄的各种动画 for (int i = 0; i < seatList.Count; i++) { if (seatList[i].IsBanker) { // RoomOpenPokerSettleAniPerform(seatList[i], room); yield return(new WaitForSeconds(PokerTypeAniIntervalTime)); break; } } //播放通赔 通杀 PlayTongCompensateKill(seatList); yield return(new WaitForSeconds(PokerTypeAniIntervalTime)); //显示金币移动 《-------金币动画 GoldFlowCtrl_PaiJiu.Instance.GoldFlowAni(seatList); } else { //如果是切锅 只刷新金币 for (int i = 0; i < seatList.Count; i++) { if (seatList[i].PlayerId > 0) { //改为发消息刷新金币 TransferData data = new TransferData(); data.SetValue("seat", seatList[i]); ModelDispatcher.Instance.Dispatch(ConstDefine_PaiJiu.ObKey_SetGoldAni, data); } } } //每局小结算 if (room.loopEnd) { #if IS_ZHANGJIAKOU //是否炸锅 PlayUIAnimation(true ? ConstDefine_PaiJiu.UIAniZhaGuo_JuYou:ConstDefine_PaiJiu.UIAniBaoGuo_JuYou); //加载爆锅炸锅 yield return(new WaitForSeconds(2f)); #endif if (!room.isCutPan) { yield return(new WaitForSeconds(popupUnitAni)); } UIDispatcher.Instance.Dispatch(ConstDefine_PaiJiu.ObKey_OpenViewPaiJiu, new object[] { UIWindowType.UnitSettlement_PaiJiu }); } yield return(new WaitForSeconds(2f)); //完成结算 UIDispatcher.Instance.Dispatch(ConstDefine_PaiJiu.ObKey_SettleOnComplete, null); }
/// <summary> /// 每次结算 /// </summary> public void EverytimeSettle(PaiJiu.Room room) { // 分数 金币动画 StartCoroutine("RoomOpenPokerSettleAni", room); }