/// <summary> /// 服务器广播开始下一局 /// </summary> /// <param name="obj"></param> public void NextGame(NN_ROOM_NEXT_GAME proto) { //清空手牌 牌型 下注 CurrentRoom.roomStatus = NN_ENUM_ROOM_STATUS.IDLE; Poker poker = new NiuNiu.Poker(); for (int i = 0; i < CurrentRoom.SeatList.Count; i++) { CurrentRoom.SeatList[i].PockeType = 0; CurrentRoom.SeatList[i].Pour = 0; for (int j = 0; j < CurrentRoom.SeatList[i].PokerList.Count; j++) { CurrentRoom.SeatList[i].PokerList[j].SetPoker(poker); } } SendRoomInfoChangeNotify(); if (proto.hasBeginTime()) { CurrentRoom.serverTime = proto.beginTime; SetCountDown(); } //处理Scene TransferData data = new TransferData(); data.SetValue <NiuNiu.Room>("CurrentRoom", CurrentRoom); SendNotification(ConstDefine_NiuNiu.ObKey_SetNextGameUISceneView, data); }
private int pokerSort(NiuNiu.Poker info1, NiuNiu.Poker info2) { int value1 = info1.size * 10 + info1.color; int value2 = info2.size * 10 + info2.color; return(value1 >= value2 ? 1 : -1); }
/// <summary> /// 设置单张扑克UI (参数 大小 花色 扑克位置索引) /// </summary> public void SetSinglePokerUI(NiuNiu.Poker poker, int pokerIndex) { if (poker.status == NN_ENUM_POKER_STATUS.POKER_STATUS_UPWARD) { _pokersList[pokerIndex].SetPokerSprite(poker); //_pokersList[pokerIndex].transform.parent.GetComponent<PokerCtrl>().FlipCardsForward(); //m_ShowPokerAni[pokerIndex].Restart(); } }
//void Update() //{ // if (Input.GetKeyDown(KeyCode.A)) // { // FlipCardsForward(); // } // if (Input.GetKeyDown(KeyCode.S)) // { // FlipCardsReverse(); // } //} #region 设置单张扑克UI (参数 大小 花色 扑克位置索引) /// <summary> /// 设置单张扑克UI (参数 大小 花色 扑克位置索引) /// </summary> public void SetPokerSprite(NiuNiu.Poker poker) { //AssetBundle更换图片 string pokerName = poker.ToString(); if (poker.status != NN_ENUM_POKER_STATUS.POKER_STATUS_UPWARD) { pokerName = "16_1"; } if (string.Compare(pokerName, positiveImage.sprite.name) != 0) { if (poker.size == 0) { pokerName = "16_1"; } Sprite currSprite = null; string pathK = string.Format("download/{0}/source/uisource/gameuisource/poker.drb", ConstDefine.GAME_NAME); currSprite = AssetBundleManager.Instance.LoadSprite(pathK, pokerName); if (currSprite != null) { positiveImage.sprite = currSprite; } } if (poker.status == NN_ENUM_POKER_STATUS.POKER_STATUS_UPWARD) { FlipCardsForward(); //m_ShowPokerAni[pokerIndex].Restart(); } //else //{ // _pokersList[pokerIndex].transform.localPosition = UIPokerHide; //} }
/// <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()); } }