public void SetSeat(SEAT_INFO op_seat) { }
///// <summary> ///// 当前游戏状态 ///// </summary> //public MahjongGameState CurrentState; ///// <summary> ///// 游戏规则 ///// </summary> //public MahjongRule Rule; #endregion #region 初始化房间信息 构建房间 /// <summary> /// 初始化房间信息 构建房间 /// </summary> /// <param name="proto"></param> public void InitRoom(ROOM_INFO proto) { CurrentRoom = new RoomEntity() { currentLoop = proto.loop, roomId = proto.roomId, Status = proto.room_status, maxLoop = proto.maxLoop, //matchId = protoRoom.matchId,//比赛场 }; CurrentRoom.Config.Clear(); //for (int i = 0; i < proto.settingIdCount(); ++i) //{ // cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(proto.getSettingId(i)); // if (settingEntity != null) // { // CurrentRoom.Config.Add(settingEntity); // } //} CurrentRoom.SeatList = new List <SeatEntity>(); for (int i = 0; i < proto.seatinfoCount(); ++i) { SEAT_INFO op_seat = proto.getSeatinfo(i); SeatEntity seat = new SeatEntity(); seat.Pos = op_seat.pos; seat.PlayerId = op_seat.playerId; seat.Gender = op_seat.gender; seat.Gold = op_seat.gold; seat.Nickname = op_seat.nickname; seat.Avatar = op_seat.avatar; //seat.IP = op_seat.ipaddr; seat.Status = op_seat.seat_status; Debug.Log(seat.Status); for (int j = 0; j < op_seat.pockerInfoCount(); ++j) { POCKER_INFO protoPoker = op_seat.getPockerInfo(j); seat.PokerList.Add(new Poker(protoPoker.index, protoPoker.color, protoPoker.size)); } seat.SetSeat(op_seat); CurrentRoom.SeatList.Add(seat); // for (int j = 0; j < op_seat.desktopCount(); ++j) // { // OP_POKER protoPoker = op_seat.getDesktop(j); // seat.DeskTopPoker.Add(new Poker(protoPoker.index, protoPoker.color, protoPoker.size, protoPoker.pos)); // } // for (int j = 0; j < op_seat.usePokerGroupCount(); ++j) // { // OP_POKER_GROUP protoPoker = op_seat.getUsePokerGroup(j); // List<Poker> lst = new List<Poker>(); // for (int k = 0; k < protoPoker.pokerCount(); ++k) // { // OP_POKER op_poker = protoPoker.getPoker(k); // Poker poker = new Poker(op_poker.index, op_poker.color, op_poker.size, op_poker.pos); // lst.Add(poker); // } // if (protoPoker.typeId != ENUM_POKER_TYPE.POKER_TYPE_GANG) // { // MahJongHelper.SimpleSort(lst); // } //#if IS_DAZHONG || IS_WUANJUN // if ((OperatorType)protoPoker.typeId == OperatorType.Chi)//吃的牌放中间 // { // for (int k = 0; k < lst.Count; ++k) // { // if (lst[k].pos != seat.Pos) // { // Poker poker = lst[k]; // lst.Remove(poker); // lst.Insert(1, poker); // } // } // } // if ((OperatorType)protoPoker.typeId == OperatorType.Peng || (OperatorType)protoPoker.typeId == OperatorType.Gang) // { // for (int k = 0; k < lst.Count; ++k) // { // if (lst[k].pos != op_seat.pos) // { // Poker poker = lst[k]; // lst.Remove(poker); // if (Mathf.Abs(poker.pos - op_seat.pos) == 2) // { // lst.Insert(1, poker); // break; // } // if (poker.pos - op_seat.pos == 1 || poker.pos - op_seat.pos == -3) // { // lst.Insert(2, poker); // break; // } // if (poker.pos - op_seat.pos == -1 || poker.pos - op_seat.pos == 3) // { // lst.Insert(0, poker); // break; // } // } // } // } //#endif // PokerCombinationEntity combination = new PokerCombinationEntity((OperatorType)protoPoker.typeId, (int)protoPoker.subTypeId, lst); // seat.UsedPokerList.Add(combination); } // for (int j = 0; j < op_seat.universalCount(); ++j) // { // OP_POKER op_poker = op_seat.getUniversal(j); // seat.UniversalList.Add(new Poker(op_poker.index, op_poker.color, op_poker.size, op_poker.pos)); // } // seat.PokerAmount = op_seat.pokerAmount; // seat.IsBanker = op_seat.isBanker; // seat.IsTrustee = op_seat.isTrustee; // seat.IsWaiver = op_seat.isWaiver; // for (int j = 0; j < op_seat.keepPokerGroupCount(); ++j) // { // OP_POKER_GROUP op_poker_group = op_seat.getKeepPokerGroup(j); // List<Poker> lstPoker = new List<Poker>(); // for (int k = 0; k < op_poker_group.pokerCount(); ++k) // { // OP_POKER op_poker = op_poker_group.getPoker(k); // lstPoker.Add(new Poker(op_poker.index, op_poker.color, op_poker.size, op_poker.pos)); // } // seat.HoldPoker.Add(lstPoker); // } // for (int j = 0; j < op_seat.dingPokerGroupCount(); ++j) // { // OP_POKER_GROUP op_poker_group = op_seat.getDingPokerGroup(j); // List<Poker> lstPoker = new List<Poker>(); // for (int k = 0; k < op_poker_group.pokerCount(); ++k) // { // OP_POKER op_poker = op_poker_group.getPoker(k); // lstPoker.Add(new Poker(op_poker.index, op_poker.color, op_poker.size, op_poker.pos)); // } // seat.DingJiangPoker.AddRange(lstPoker); // } // seat.Direction = op_seat.wind; // if (proto.seatCount() == 2 && seat.Direction == 2) // { // seat.Direction = 3; // } // CurrentRoom.SeatList.Add(seat); // } // if (CurrentRoom.SeatList.Count == 2) // { // for (int i = 0; i < CurrentRoom.SeatList.Count; ++i) // { // for (int j = 0; j < CurrentRoom.SeatList[i].UsedPokerList.Count; ++j) // { // for (int k = 0; k < CurrentRoom.SeatList[i].UsedPokerList[j].PokerCount; ++k) // { // if (CurrentRoom.SeatList[i].UsedPokerList[j].PokerList[k].pos == 2) // { // CurrentRoom.SeatList[i].UsedPokerList[j].PokerList[k].pos = 3; // } // } // } // } // } // CurrentRoom.FirstDice = new DiceEntity() // { // diceA = proto.diceFirstA, // diceB = proto.diceFirstB, // seatPos = proto.diceFirst, // }; // CurrentRoom.SecondDice = new DiceEntity() // { // diceA = proto.diceSecondA, // diceB = proto.diceSecondB, // seatPos = proto.diceSecond, // }; // int askLeng = proto.askPokerGroupCount(); // if (askLeng > 0) // { // AskPokerGroup = new List<OP_POKER_GROUP>(); // for (int i = 0; i < askLeng; ++i) // { // AskPokerGroup.Add(proto.getAskPokerGroup(i)); // } // } // else // { // AskPokerGroup = null; // } // cfg_settingDBModel.Instance.SetSetting(new List<int>(proto.getSettingIdList())); // CalculateSeatIndex(); // InitConfig(); // if (currentOperatorPos == 0) // { // currentOperatorPos = CurrentRoom.BankerPos; // } // for (int i = 0; i < CurrentRoom.SeatList.Count; ++i) // { // SeatEntity seat = CurrentRoom.SeatList[i]; // for (int j = 0; j < CurrentRoom.SeatList.Count; ++j) // { // for (int k = 0; k < CurrentRoom.SeatList[j].UsedPokerList.Count; ++k) // { // for (int l = 0; l < CurrentRoom.SeatList[j].UsedPokerList[k].PokerList.Count; ++l) // { // if (CurrentRoom.SeatList[j].UsedPokerList[k].PokerList[l].pos == seat.Pos && MahJongHelper.HasPoker(CurrentRoom.SeatList[j].UsedPokerList[k].PokerList[l], seat.UniversalList)) // { // seat.isPlayedUniversal = true; // break; // } // } // if (seat.isPlayedUniversal) break; // } // if (seat.isPlayedUniversal) break; // for (int k = 0; k < CurrentRoom.SeatList[j].DeskTopPoker.Count; ++k) // { // if (CurrentRoom.SeatList[j].DeskTopPoker[k].pos == seat.Pos && MahJongHelper.HasPoker(CurrentRoom.SeatList[j].DeskTopPoker[k], seat.UniversalList)) // { // seat.isPlayedUniversal = true; // break; // } // } // if (seat.isPlayedUniversal) break; // for (int k = 0; k < CurrentRoom.SeatList[j].PokerList.Count; ++k) // { // if (CurrentRoom.SeatList[j].PokerList[k].pos == seat.Pos && MahJongHelper.HasPoker(CurrentRoom.SeatList[j].PokerList[k], seat.UniversalList)) // { // seat.isPlayedUniversal = true; // break; // } // } // if (seat.isPlayedUniversal) break; // } // } // for (int i = 0; i < CurrentRoom.Config.Count; ++i) // { // if (CurrentRoom.Config[i].tags.Equals("handTotal")) // { // CurrentRoom.PokerTotalPerPlayer = CurrentRoom.Config[i].value; // break; // } // } // SetCurrentOperator(currentOperatorPos, true); }
///// <summary> ///// 当前游戏状态 ///// </summary> //public MahjongGameState CurrentState; ///// <summary> ///// 游戏规则 ///// </summary> //public MahjongRule Rule; #endregion #region InitRoom 初始化房间数据 public void InitRoom(ROOM_INFO protoRoom) { //ROOM_INFO protoRoom = proto.roomInfo; CurrentRoom = new RoomEntity() { //BaseScore = proto.baseScore, roomId = protoRoom.roomId, ownerId = protoRoom.ownerId, currentLoop = protoRoom.loop, //matchId = protoRoom.matchId,//比赛场ID Status = (RoomEntity.RoomStatus)protoRoom.roomStatus, maxLoop = protoRoom.maxLoop, DisbandStartTime = protoRoom.dismissTime, DisbandTime = protoRoom.dismissMaxTime, DisbandTimeMax = (int)(protoRoom.dismissMaxTime - protoRoom.dismissTime), }; CurrentRoom.HistoryPoker = new List <Poker>(); CurrentRoom.SeatList = new List <SeatEntity>(); //收到数据存到模型基类 CurrentRoom.Config.Clear(); for (int i = 0; i < protoRoom.settingIdCount(); ++i) { cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(protoRoom.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; } } 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为:" + protoRoom.roomId); Debug.Log("服务器发送的房间座位长度为:" + protoRoom.getSeatInfoList().Count); CurrentRoom.SeatCount = protoRoom.getSeatInfoList().Count; CurrentRoom.SeatList = new List <SeatEntity>(); for (int i = 0; i < CurrentRoom.SeatCount; ++i) { SEAT_INFO protoSeat = protoRoom.getSeatInfo(i); SeatEntity seat = new SeatEntity(); //是否同意解散 if (protoSeat.hasSeatStatus()) { seat.DisbandState = (DisbandState)protoSeat.dismiss_status; } //庄 //seat.IsBanker = protoSeat.isBanker; //玩家ID seat.PlayerId = protoSeat.playerId; //房主 seat.isLandlord = seat.PlayerId == protoRoom.ownerId; //pos seat.Pos = protoSeat.pos; //昵称 seat.Nickname = protoSeat.nickname; //头像 seat.Avatar = protoSeat.avatar; //性别 seat.Gender = protoSeat.gender; //是否准备 seat.IsReady = protoSeat.isReady; //已有金币 seat.Gold = protoSeat.gold; //座位状态 seat.Status = (SeatEntity.SeatStatus)protoSeat.seatStatus; ////本局收益 //seat.Earnings = protoSeat.nn_earnings; ////是否是胜利者 //seat.Winner = protoSeat.isWiner; ////纬度 //if (protoSeat.hasLatitude()) seat.Latitude = protoSeat.latitude; ////经度 //if (protoSeat.hasLongitude()) seat.Longitude = protoSeat.longitude; //手牌类型 seat.pokerList = new List <Poker>(); //具体手牌 if (protoSeat.hasPokerInfo()) { List <POKER_INFO> prPokerList = protoSeat.getPokerInfoList(); Debug.Log("prPokerList:" + prPokerList.Count); for (int j = 0; j < prPokerList.Count; ++j) { seat.pokerList.Add(new Poker(prPokerList[j].index, prPokerList[j].size, prPokerList[j].color)); } seat.HandPockerNum = prPokerList.Count; } CurrentRoom.SeatList.Add(seat); if (seat.Status == SeatEntity.SeatStatus.Operate) { CurrentRoom.OperateSeat = seat; } } CalculateSeatIndex(); //上家出牌 List <Poker> recentlyPlayPoker = new List <Poker>(); List <POKER_INFO> leftPoker = new List <POKER_INFO>(); if (protoRoom.hasLeftPoker()) { leftPoker = protoRoom.leftPoker.getPokerInfoList(); } for (int i = 0; i < leftPoker.Count; ++i) { recentlyPlayPoker.Add(new Poker(leftPoker[i].index, leftPoker[i].size, leftPoker[i].color)); } int leftPokerPos = protoRoom.hasLeftPoker() ? protoRoom.leftPoker.pos : 0; CurrentRoom.CurrAlreadyPlayPos = leftPokerPos; CurrentRoom.RecentlyPlayPoker = new CombinationPokersEntity(leftPokerPos, recentlyPlayPoker, PokersType.None, 0); PaoDeKuaiHelper.CheckPokerType(CurrentRoom.RecentlyPlayPoker); Currhint = new HintPokersEntity(CurrentRoom.RecentlyPlayPoker); SeatEntity leftseat = GetSeatBySeatPos(leftPokerPos); if (leftseat != null) { if (recentlyPlayPoker.Count > 0) { leftseat.pokerList.AddRange(recentlyPlayPoker); } } SetSeatPass(CurrentRoom.RecentlyPlayPoker.Pos, CurrentRoom.OperateSeat); //if (proto.nn_room.hasUnixtime()) //{ // CurrentRoom.serverTime = proto.nn_room.unixtime;//(时间戳) //} }
public const int ROOM_SEAT_COUNT = 4; //房间座位数量 public void InitRoom(SSS_CREATE_ROOM proto) { //CurrentRoom = room; //CalculateSeatIndexOne(); //普通场计算座位 Index //SendRoomInfoChangeNotify(); CurrentRoom = new RoomEntity() { roomId = proto.roomInfo.roomId, currentLoop = proto.roomInfo.loop, maxLoop = proto.roomInfo.maxLoop, SszRoomStatus = proto.roomInfo.roomStatus, BaseScore = proto.roomInfo.baseScore,//底分 SeatCount = proto.roomInfo.seatInfoCount(), gameId = GameCtrl.Instance.CurrentGameId, groupId = 0, matchId = 0, SeatList = new List <SeatEntity>(), }; Debug.Log(proto.roomInfo.seatInfoCount() + " 座位长度"); for (int i = 0; i < proto.roomInfo.seatInfoCount(); ++i) { SEAT_INFO ssz_seat = proto.roomInfo.getSeatInfo(i); SeatEntity seat = new SeatEntity(); seat.PlayerId = ssz_seat.playerId;//玩家ID if (seat.PlayerId == AccountProxy.Instance.CurrentAccountEntity.passportId) { seat.IsPlayer = true; } Debug.Log(ssz_seat.nickname + " 玩家名字"); seat.Nickname = ssz_seat.nickname; //玩家名字 seat.Avatar = ssz_seat.avatar; //玩家头像 seat.Gender = ssz_seat.gender; //玩家性别 seat.Gold = ssz_seat.gold; //底分 seat.Pos = ssz_seat.pos; //座位位置 seat.seatStatus = ssz_seat.seatStatus; //座位状态 seat.handPokerList = new List <Poker>(); seat.firstPokerList = new List <Poker>(); seat.middlePokerList = new List <Poker>(); seat.endPokerList = new List <Poker>(); for (int j = 0; j < ssz_seat.firstPokerInfoCount(); ++j) { FIRST_POKER_INFO firstPoker = ssz_seat.getFirstPokerInfo(j); seat.firstPokerList.Add(new Poker(firstPoker.index, firstPoker.color, firstPoker.size)); } for (int j = 0; j < ssz_seat.secondPokerInfoCount(); ++j) { SECOND_POKER_INFO middlePoker = ssz_seat.getSecondPokerInfo(j); seat.middlePokerList.Add(new Poker(middlePoker.index, middlePoker.color, middlePoker.size)); } for (int j = 0; j < ssz_seat.thirdPokerInfoCount(); ++j) { THIRD_POKER_INFO endPoker = ssz_seat.getThirdPokerInfo(j); seat.endPokerList.Add(new Poker(endPoker.index, endPoker.color, endPoker.size)); } CurrentRoom.SeatList.Add(seat); } if (proto.roomInfo.seatInfoCount() == 3) { CurrentRoom.SeatList.Add(new SeatEntity()); } CalculateSeatIndexOne(); }