/// <summary> /// 加载窗口 (暂用于 刚进入游戏时 加载已有窗口) /// </summary> /// <param name="data"></param> private void SetEnterRoomView(object[] obj) { NiuNiu.Room room = RoomNiuNiuProxy.Instance.CurrentRoom; NiuNiu.Seat seat = RoomNiuNiuProxy.Instance.PlayerSeat; switch (room.roomStatus) { case NN_ENUM_ROOM_STATUS.IDLE: break; case NN_ENUM_ROOM_STATUS.READY: break; case NN_ENUM_ROOM_STATUS.BEGIN: break; case NN_ENUM_ROOM_STATUS.RSETTLE: break; case NN_ENUM_ROOM_STATUS.DEAL: break; case NN_ENUM_ROOM_STATUS.POUR: break; case NN_ENUM_ROOM_STATUS.LOOKPOCKER: break; case NN_ENUM_ROOM_STATUS.DISSOLVE: //弹出是否同意解散窗口 或者 已同意人数窗口 if (seat.Dissolve == NN_ENUM_SEAT_DISSOLVE.NOP) { //计算倒计时 long time = room.serverTime; long currTime = TimeUtil.GetTimestamp(); float countdownTime = (time - currTime) + GlobalInit.Instance.TimeDistance * 0.001f; countdownTime = Mathf.Clamp(countdownTime, 0, 5); //加载是否同意解散窗口 UIViewManager.Instance.ShowMessage("提示", "有人发起解散房间,是否同意", MessageViewType.OkAndCancel, ClientSendAgreeDisbandRoom, ClientSendRefuseDisbandRoom, countdownTime, AutoClickType.Cancel); } else if (seat.Dissolve == NN_ENUM_SEAT_DISSOLVE.AGREE && seat.Dissolve == NN_ENUM_SEAT_DISSOLVE.DISAGREE) { //加载人数窗口 LoadDisbandSumView(RoomNiuNiuProxy.Instance.agreeDissolveCount, RoomNiuNiuProxy.Instance.CurrentRoom.serverTime); } break; case NN_ENUM_ROOM_STATUS.HOG: break; case NN_ENUM_ROOM_STATUS.GAMEOVER: break; default: break; } }
//更改对应玩家信息显示 //参数座位类 位置索引(转化后的位置) void SetItemInfoUI(NiuNiu.Seat seat, int pos, NN_ENUM_ROOM_STATUS roomStatus) { //打开这一Item ShowPlayerItem(pos); //显示该位置完整信息 playersItem[pos].ShowWholeItem(seat, roomStatus); //Debug.Log("位置" + pos + "的牌型是" + seat.PockeType); }
/// <summary> /// 设置单个 玩家手牌UI (参数对应座位手牌信息 座位索引) /// </summary> /// <param name="seat"></param> /// <param name="pos"></param> public void SetShowPokersUI(TransferData data)//NiuNiu.Seat seat, int pos { if (isPlayDrawPokerAni) { return; } NiuNiu.Seat seat = data.GetValue <NiuNiu.Seat>("Seat"); playersItem[seat.Index].SetAllPokerUI(seat.PokerList); //翻牌 playersItem[seat.Index].SetPokerPos(seat.PokerList); //计算位置 }
//加载UIRoot后 展示房间全部信息 public void InitEnterRoomUI(NiuNiu.Room currentRoom, NiuNiu.Seat playerSeat, int playerNumber) { Debug.Log("房间初始化--置空"); for (int i = 0; i < playersItem.Length; i++) { playersItem[i].InfoItem(); } Debug.Log(" //----------------------设置房间初始玩家信息-------------------------------"); for (int i = 0; i < currentRoom.SeatList.Count; i++) { Debug.Log(currentRoom.SeatList[i].Pos); } Debug.Log(currentRoom.roomId); //跟换背景桌面 Debug.Log(" //-------------------" + currentRoom.superModel); m_BG[0].gameObject.SetActive(currentRoom.superModel == Room.SuperModel.CommonRoom); m_BG[1].gameObject.SetActive(currentRoom.superModel == Room.SuperModel.PassionRoom); for (int i = 0; i < playersItem.Length; i++) { playersItem[i].superModel = currentRoom.superModel; } //设置房间初始玩家信息 应该是全部信息 SetEnterRoomUI(currentRoom.SeatList, currentRoom.roomStatus); //初始化交互显影 UIInteraction_NiuNiu.Instance.InitAll(currentRoom.roomModel, currentRoom.superModel); //(currentRoom, playerSeat, playerNumber); //初始化房间固有信息 UIItemRoomInfo_NiuNiu.Instance.SetUI(RoomNiuNiuProxy.Instance.CurrentRoom.roomId, 0); UIItemRoomInfo_NiuNiu.Instance.SetRoomConfig(RoomNiuNiuProxy.Instance.CurrentRoom.Config); //根据此时状态 弹出对应窗口 SetEnterRoomView(currentRoom, playerSeat); //JuYou.JuYouSceneCtrl }
//具体设置 void RoomOpenPokerSettleAniPerform(NiuNiu.Seat seat, NN_ENUM_ROOM_STATUS roomStatus) { UISceneView_NiuNiu.Instance.SetShowTypeUI(seat, seat.Index, roomStatus); //显示牌型信息 UISceneView_NiuNiu.Instance.PlayEarningsAni(seat, seat.Index); //动画显示本局收益信息 SetGold Debug.Log("位置" + seat.Pos + "服务器传递收益为:" + seat.Earnings); StartCoroutine(delaySetGold(seat)); //更新玩家积分 SetGold playersItem[seat.Index].SetAllPokerUI(seat.PokerList); //刷新牌 if (!isPlayDrawPokerAni) { playersItem[seat.Index].SetPokerPos(seat.PokerList); //计算是否移动牌位置 } }
/// <summary> /// 接收聊天消息 /// </summary> public void OnReceiveMessage(ChatType type, int playerId, string message, string audioName) { NiuNiu.Seat seat = RoomNiuNiuProxy.Instance.GetSeatByPlayerId(playerId); if (type == ChatType.Expression) { UIItemChat.Instance.ShowExpression(seat.Index, message); } else { if (!string.IsNullOrEmpty(audioName)) { AudioEffectManager.Instance.Play(string.Format("{0}_{1}", seat.Gender, audioName), Vector3.zero, false); } UIItemChat.Instance.ShowMessage(seat.Index, message); } }
/// <summary> /// 向服务器申请 翻开一张 /// </summary> /// <param name="seat"></param> public void NeedOpenPoker(object[] obj) { Debug.Log("点击了牌"); if (RoomNiuNiuProxy.Instance.CurrentRoom.roomStatus != NN_ENUM_ROOM_STATUS.LOOKPOCKER && RoomNiuNiuProxy.Instance.PlayerSeat.Pour <= 0) { Debug.Log("不是看牌阶段,无法翻开这张牌"); return; } NN_ROOM_DRAW_GET proto = new NN_ROOM_DRAW_GET(); List <NN_POKER> prPokerList = proto.getNnPokerList(); NiuNiu.Seat PlayerSeat = RoomNiuNiuProxy.Instance.PlayerSeat; for (int i = 0; i < obj.Length; i++) { int itemIndex = (int)obj[i]; if (itemIndex > 0 && itemIndex <= ROOM_POKERLIST_COUNT) { Debug.Log("牌状态:" + PlayerSeat.PokerList[itemIndex].status); if (PlayerSeat.PokerList[itemIndex].status == 0) { NN_POKER nn_poker = new NN_POKER(); nn_poker.index = PlayerSeat.PokerList[itemIndex].index; nn_poker.color = PlayerSeat.PokerList[itemIndex].color; nn_poker.size = PlayerSeat.PokerList[itemIndex].size; nn_poker.pokerStatus = (NN_ENUM_POKER_STATUS)PlayerSeat.PokerList[itemIndex].status; proto.addNnPoker(nn_poker); Debug.Log("要开的牌index是" + nn_poker.index); } } } Debug.Log("发送的翻牌长度" + proto.getNnPokerList().Count); if (prPokerList.Count <= 0) { Debug.Log("没有要开的牌"); return; } NetWorkSocket.Instance.Send(proto.encode(), NN_ROOM_DRAW.CODE, GameCtrl.Instance.SocketHandle); }
//设置玩家已有积分 public void SetGold(NiuNiu.Seat seat, int pos) { playersItem[pos].SetGold(seat.Gold); }
/// <summary> /// 显示本局收益 动画 /// </summary> /// <param name="seat"></param> /// <param name="pos"></param> public void PlayEarningsAni(NiuNiu.Seat seat, int pos) { playersItem[pos].PlayEarningsAni(seat.Earnings); }
/// <summary> /// 显示牌型 /// </summary> /// <param name="seat"></param> /// <param name="pos"></param> public void SetShowTypeUI(NiuNiu.Seat seat, int pos, NN_ENUM_ROOM_STATUS roomStatus) { playersItem[pos].SetPockeTypeUI(seat.PockeType, roomStatus); }
//------------------------------------------------------------------------ //设置发牌动画 void SetDealAni(NiuNiu.Seat seat) { playersItem[seat.Index].PlayeDealAni(seat, () => { isPlayDrawPokerAni = false; }); }
IEnumerator delaySetGold(NiuNiu.Seat seat) { yield return(new WaitForSeconds(delaySetGoldTime)); SetGold(seat, seat.Index); }
//公开牌型动画 IEnumerator RoomOpenPokerSettleAni(NiuNiu.Room room)//NN_ENUM_ROOM_STATUS roomStatus { List <NiuNiu.Seat> seatList = room.SeatList; NN_ENUM_ROOM_STATUS roomStatus = room.roomStatus; NiuNiu.Seat playerSeat = null; for (int i = 0; i < seatList.Count; i++) { if (seatList[i].Index == 0) { playerSeat = seatList[i]; break; } } //yield return 0; for (int i = 0; i < seatList.Count; i++) { if (seatList[i] != null && seatList[i].PlayerId > 0 && seatList[i].PockeType != 0 && !seatList[i].IsBanker) { RoomOpenPokerSettleAniPerform(seatList[i], roomStatus); } else { continue; } yield return(new WaitForSeconds(PokerTypeAniIntervalTime)); } //显示庄的各种动画 for (int i = 0; i < seatList.Count; i++) { if (seatList[i].IsBanker) { // RoomOpenPokerSettleAniPerform(seatList[i], roomStatus); yield return(new WaitForSeconds(PokerTypeAniIntervalTime)); break; } } #if IS_WANGQUE //显示通杀 通赔 PlayTongCompensateKill(seatList); #endif //显示金币移动 GoldFlowCtrl_NiuNiu.Instance.GoldFlowAni(seatList); #if IS_CANGZHOU if (room.superModel == Room.SuperModel.CommonRoom) { //每局小结算 yield return(new WaitForSeconds(popupUnitAni)); NiuNiuGameCtrl.Instance.OpenView(UIWindowType.UnitSettlement_NiuNiu);//管理器调用 } #endif //#if IS_WANGQUE // if (room.superModel == Room.SuperModel.PassionRoom) // { // const string prefabName = "UIItemSeniorSettle_NiuNiu"; // string prefabPath = string.Format("download/{0}/prefab/uiprefab/uiitems/{1}.drb", ConstDefine.GAME_NAME, prefabName); // GameObject go = AssetBundleManager.Instance.LoadAssetBundle<GameObject>(prefabPath, prefabName); // go = UnityEngine.Object.Instantiate(go); // go.SetParent(m_EffectContainer.transform); // go.GetComponent<UIItemSeniorSettle_NiuNiu>().SetUI(playerSeat !=null ? playerSeat.Earnings:0); // } //#endif }