/// <summary> /// 下注 /// </summary> /// <param name="proto"></param> public void NoticeJetton(PAIGOW_ROOM_INFORM_JETTON proto) { CurrentRoom.roomStatus = ROOM_STATUS.POUR; CurrentRoom.loopEnd = false; List <int> pourPosList = proto.getPosList(); for (int i = 0; i < pourPosList.Count; i++) { PaiJiu.Seat seat = GetSeatBySeatId(pourPosList[i]); if (seat == null) { continue; } seat.Pour = 0; AppDebug.Log(seat.Nickname + "开始下注"); //提示该谁下注 //设置倒计时 SetCountDown(proto.unixtime); //SendSeatInfoChangeNotify(seat); //SendRoomInfoChangeNotify(); } // 1 判断自己是否下注 // 2 控制提示 SendRoomInfoChangeNotify(); }
/// <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> /// <param name="pbSeat"></param> public void EnterRoom(PAIGOW_ROOM_ENTER proto) { Debug.Log(proto.pos + "进入房间"); PaiJiu.Seat seat = GetSeatBySeatId(proto.pos); if (seat == null) { return; } seat.PlayerId = proto.playerId; seat.Nickname = proto.nickname; seat.Avatar = proto.avatar; seat.Gender = proto.gender; seat.Pos = proto.pos; //seat.Gold = proto.gold; //<-----------------------------------《玩家基本金币》 PeopleCounting(); SendSeatInfoChangeNotify(seat); #if IS_ZHANGJIAKOU if (BankerSeat != null) { SendSeatInfoChangeNotify(BankerSeat); } #endif AppDebug.Log(seat.Nickname + "进入房间,SeatIndex:" + seat.Index); }
void RoomOpenPokerSettleAniPerform(PaiJiu.Seat seat, Room CurrentRoom) { m_Seats[seat.Index].SetSettle(seat); //设置结算效果 //m_Seats[seat.Index].SetScoresGoUp(seat.Earnings); //m_Seats[seat.Index].SetHandPokersType(seat,true); //牌型 StartCoroutine(DelaySetGold(seat)); // 更新玩家积分 SetGold }
/// <summary> /// 开局动画 /// </summary> /// <param name="isReplay"></param> /// <returns></returns> private IEnumerator BeginAnimation(/*bool isReplay*/) { yield return(new WaitForSeconds(0.7f)); //===================摇骰子===================== StartCoroutine(RollDice(0, 0, RoomPaiJiuProxy.Instance.CurrentRoom.currentDice.diceA, RoomPaiJiuProxy.Instance.CurrentRoom.currentDice.diceB)); yield return(new WaitForSeconds(ROLL_DICE_ANIMATION_DURATION)); int loopCount = RoomPaiJiuProxy.Instance.PlayerSeat.PokerList.Count / countPerTimes; //===================根据手牌长度设定摸牌循环次数============count/countPerTimes========= int firstGivePos = RoomPaiJiuProxy.Instance.CurrentRoom.currentDice.seatPos; //按顺序发牌 for (int i = 0; i < loopCount; ++i) { for (int j = 0; j < RoomPaiJiuProxy.Instance.CurrentRoom.SeatList.Count; ++j) { int seatPos = (firstGivePos + j - 1) % RoomPaiJiuProxy.Instance.CurrentRoom.SeatList.Count; PaiJiu.Seat seat = RoomPaiJiuProxy.Instance.CurrentRoom.SeatList[seatPos]; if (seat.PlayerId <= 0) { continue; } for (int k = 0; k < countPerTimes; ++k) { //发牌入手 MaJiangCtrl_PaiJiu majiang = MahJongManager_PaiJiu.Instance.DrawMaJiang(seat.Pos, seat.PokerList[(i * countPerTimes) + k]); //显示手牌 if (seat == RoomPaiJiuProxy.Instance.PlayerSeat) { m_UIScenePaiJiu3DView.DrawPoker(majiang); } else { GetSeatCtrlBySeatPos(seat.Pos).DrawPoker(majiang); } } #if IS_ZHANGJIAKOU AudioEffectManager.Instance.Play(ConstDefine_PaiJiu.FaPai_paijiu, Vector3.zero); //播放声音 #endif yield return(new WaitForSeconds(DEAL_ANIMATION_DURATION)); } } #if IS_ZHANGJIAKOU // 如果有牌墙具体信息 则翻开牌墙 if (RoomPaiJiuProxy.Instance.CurrentRoom.pokerWall.Count > 0) { DrawMaJiangWall(RoomPaiJiuProxy.Instance.CurrentRoom.pokerWall, true); } #endif yield return(new WaitForSeconds(PLAYER_OPEN_POKER_DURATION)); PaiJiuGameCtrl.Instance.ClientSendGetSettle(); }
IEnumerator DelaySetGold(PaiJiu.Seat seat) { yield return(new WaitForSeconds(delaySetGoldTime)); //改为发消息刷新金币 TransferData data = new TransferData(); data.SetValue("seat", seat); ModelDispatcher.Instance.Dispatch(ConstDefine_PaiJiu.ObKey_SetGoldAni, data); }
/// <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> /// <param name="seat"></param> private void SendSeatInfoChangeNotify(PaiJiu.Seat seat) { if (seat == null) { return; } TransferData data = new TransferData(); data.SetValue("Seat", seat); data.SetValue("IsPlayer", seat == PlayerSeat); data.SetValue("RoomStatus", CurrentRoom.roomStatus); data.SetValue("CurrentRoom", CurrentRoom); data.SetValue("BankerSeat", BankerSeat); data.SetValue("ChooseBankerSeat", CurrentRoom.ChooseBankerSeat); SendNotification(ConstDefine_PaiJiu.ObKey_SeatInfoChanged, data); }
/// <summary> /// 下注某分 /// </summary> /// <param name="proto"></param> public void Jetton(PAIGOW_ROOM_JETTON proto) { PaiJiu.Seat seat = GetSeatBySeatId(proto.pos); if (seat == null) { return; } if (proto.hasPour()) { seat.Pour = proto.pour; } //显示其下注内容 SendRoomInfoChangeNotify(); AppDebug.Log(seat.Nickname + "下注了,下注分:" + seat.Pour); }
/// <summary> /// 离开房间 /// </summary> /// <param name="proto"></param> public void ExitRoom(PAIGOW_ROOM_LEAVE proto) { PaiJiu.Seat seat = GetSeatByPlayerId(proto.playerId); if (seat == null) { return; } seat.PlayerId = 0; PeopleCounting(); SendSeatInfoChangeNotify(seat); AppDebug.Log(seat.Nickname + "离开房间"); if (seat == PlayerSeat) { NetWorkSocket.Instance.SafeClose(GameCtrl.Instance.SocketHandle); SceneMgr.Instance.LoadScene(SceneType.Main); } }
/// <summary> /// 某人翻开某牌 /// </summary> /// <param name="proto"></param> public void OnServerOpenPoker(PAIGOW_ROOM_DRAW proto) { AppDebug.Log(string.Format("开牌内容长度:{0} 座位号:{1}", proto.paigowMahjongCount(), proto.pos)); PaiJiu.Seat seat = GetSeatBySeatId(proto.pos); List <PAIGOW_MAHJONG> protoMajiangList = proto.getPaigowMahjongList(); for (int i = 0; i < protoMajiangList.Count; i++) { AppDebug.Log(string.Format("开牌信息:index:{0} size{1} type{2}", protoMajiangList[i].index, protoMajiangList[i].size, protoMajiangList[i].type)); for (int j = 0; j < seat.PokerList.Count; j++) { if (protoMajiangList[i] != null && protoMajiangList[i].index == seat.PokerList[j].index) { seat.PokerList[j].SetPoker(protoMajiangList[i]); AppDebug.Log(string.Format("设置手牌数据:index:{0} size{1} type{2}", protoMajiangList[i].index, protoMajiangList[i].size, protoMajiangList[i].type)); continue; } } } }
/// <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="proto"></param> public void Ready(PAIGOW_ROOM_READY proto) { if (CurrentRoom.roomStatus == ROOM_STATUS.IDLE) { CurrentRoom.roomStatus = ROOM_STATUS.READY; } PaiJiu.Seat seat = GetSeatBySeatId(proto.pos); if (seat == null) { return; } seat.seatStatus = SEAT_STATUS.SEAT_STATUS_READY; //seat.IsTrustee = false; //需要庄家点开始 //#if IS_ZHANGJIAKOU SendRoomInfoChangeNotify(); //#else // SendSeatInfoChangeNotify(seat); //#endif AppDebug.Log(seat.Nickname + "准备"); }
/// <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> public void SetHandPokersType(Seat seat, bool isShow) { bool isShowactiveSelf = m_HandPokersType.gameObject.activeSelf; if (isShowactiveSelf != isShow) { m_HandPokersType.gameObject.SetActive(isShow); #if IS_ZHANGJIAKOU if (m_DoubleImage != null) { m_DoubleImage.gameObject.SetActive(false); } #endif if (isShow) { int typeData = 0; //m_HandPokersType.gameObject.SetActive(true); if (seat.PokerList.Count >= 2) { if (seat.PokerList[0].type == seat.PokerList[1].type && seat.PokerList[0].size == seat.PokerList[1].size) { typeData = 10; #if IS_ZHANGJIAKOU if (m_DoubleImage != null && !seat.IsBanker && seat.PokerList[0].size >= 4 && seat.Earnings > 0) { m_DoubleImage.gameObject.SetActive(true); } #endif } else { for (int i = 0; i < seat.PokerList.Count; i++) { typeData += seat.PokerList[i].size; } typeData = typeData % 10; } } else { return; } string spritePath = string.Format(ConstDefine_PaiJiu.UISpritePath, ConstDefine.GAME_NAME); Sprite sprite = AssetBundleManager.Instance.LoadSprite(spritePath, ("handpokerstype" + typeData)); m_HandPokersType.sprite = sprite; //播放声音 string pokerTypeAudio = string.Format(ConstDefine_PaiJiu.PokerType_paijiu, typeData); //#if IS_PAIJIU //#else // string pokerTypeAudio = seat.Gender + "_" + string.Format(ConstDefine_PaiJiu.PokerType_paijiu, typeData); //#endif AudioEffectManager.Instance.Play(pokerTypeAudio, Vector3.zero); //NiuNiu.NiuNiuWindWordAni TweenAni_PaiJiu.PokerTypeAni(m_HandPokersType.transform); } } }
/// <summary> /// 设置结算效果 /// </summary> public void SetSettle(Seat seat) { SetScoresGoUp(seat.Earnings); SetHandPokersType(seat, true); //SetDoubleImage(seat, true, bankerSeat); }
/// <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)); }