コード例 #1
0
    /// <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));
    }