Ejemplo n.º 1
0
    /// <summary>
    /// 服务器广播开局发牌
    /// </summary>
    /// <param name="obj"></param>
    private void OnServerBroadcastBegin(byte[] obj)
    {
        PAIGOW_ROOM_BEGIN proto = PAIGOW_ROOM_BEGIN.decode(obj);


        if (proto.hasPaigowSeat())
        {
            //真发牌
            RoomPaiJiuProxy.Instance.Begin(proto);

            if (PaiJiuSceneCtrl.Instance != null)
            {
                PaiJiuSceneCtrl.Instance.Begin(RoomPaiJiuProxy.Instance.CurrentRoom, true);
            }
        }
        else
        {
            RoomPaiJiuProxy.Instance.Begin();
            //只开局
            if (PaiJiuSceneCtrl.Instance != null)
            {
                PaiJiuSceneCtrl.Instance.Begin(true);
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 开局发牌
    /// </summary>
    /// <param name="proto"></param>
    public void Begin(PAIGOW_ROOM_BEGIN proto)
    {
        AppDebug.Log("发牌");
        CurrentRoom.roomStatus    = ROOM_STATUS.LOOP;
        CurrentRoom.remainMahjong = proto.remainMahjong;//剩余牌数量

        //设置骰子数据
        CurrentRoom.SetDiceEntity(proto.firstGivePos, proto.diceFirst, proto.diceSecond);
        Debug.Log("-----剩余牌墙具体信息-----------" + proto.hasMahjongs_remain());
        //剩余牌墙具体信息
        if (proto.hasMahjongs_remain())
        {
            Debug.Log("-----剩余牌墙具体信息-----------" + proto.getMahjongs_remainList().Count);
            List <PAIGOW_MAHJONG> Mahjongs_remain = proto.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());
            }
        }

        //设置数据

        //其他人牌为空
        //int HandPokerCount = proto.paigow_seat.getPaigowMahjongList().Count;

        for (int i = 0; i < CurrentRoom.SeatList.Count; i++)
        {
            if (CurrentRoom.SeatList[i].PlayerId > 0)
            {
                //CurrentRoom.SeatList[i].PokerList.Clear();
                for (int j = 0; j < 2; j++)
                {
                    //添加空牌
                    if (CurrentRoom.SeatList[i].PokerList.Count < 2)
                    {
                        CurrentRoom.SeatList[i].PokerList.Add(new Poker((j + 1), 0, 0, PAIGOW_STATUS.HIDE));
                    }
                }
            }
        }


        //接收牌
        for (int i = 0; i < proto.getPaigowSeatList().Count; i++)
        {
            Seat seat = GetSeatBySeatId(proto.getPaigowSeatList()[i].pos);
            if (seat == null)
            {
                continue;
            }

            seat.SetSeat(proto.getPaigowSeatList()[i]);
        }



        //设置倒计时
        SetCountDown(proto.unixtime);
        //发送消息
        SendRoomInfoChangeNotify();

        //sceneCtrl 开局
        TransferData data = new TransferData();

        data.SetValue("SeatPos", PlayerSeat.Pos);
        data.SetValue("SeatCount", CurrentRoom.SeatList.Count);
        //data.SetValue("SeatDirection", PlayerSeat.Direction);
        SendNotification(ON_BEGIN, data);
    }