Beispiel #1
0
    /// <summary>
    /// 错误返回
    /// </summary>
    private void RecvError(byte[] args)
    {
        //上次发给服务器的消息Id
        int LastSendId = MsgParse.PopByte(ref args);
        int errorId    = MsgParse.PopByte(ref args);

        switch (errorId)
        {
        case 0:
            Log.Warning("未知错误");
            break;

        case 1:
            Log.Warning("登录失败,密码有误");
            break;

        case 2:
            Log.Warning("权限不足");
            break;

        case 3:
            Log.Warning("启动游戏失败");
            break;

        default:
            Log.Warning("未知错误");
            break;
        }
    }
Beispiel #2
0
    private void RecvGood(byte[] args)
    {
        var cmd = MsgParse.PopByte(ref args);

        Log.Debug("Good={0}", cmd);
        switch (cmd)
        {
        case Protocal.WATCH:
        {
            NetWorkManager.Instance.Send(Protocal.SEAT_QUERY, RoomManager.Instance.rData.gId.Value);
        }
        break;

        case Protocal.LEAVE:
        {
            RoomManager.Instance.Self.Value.state = EPlayerState.Watch;
        }
        break;

        case Protocal.READY_CANCEL:
        {
            RoomManager.Instance.Self.Value.state = EPlayerState.Seat;
        }
        break;

        case Protocal.READY:
        {
            RoomManager.Instance.Self.Value.state = EPlayerState.GamePrepare;
        }
        break;
        }
    }
Beispiel #3
0
    private void RecvNotifyDraw(byte[] args)
    {
        int gId = MsgParse.PopInt(ref args);

        if (gId != RoomManager.Instance.rData.gId.Value)
        {
            return;
        }

        byte rank      = MsgParse.PopByte(ref args);
        byte suit      = MsgParse.PopByte(ref args);
        int  pId       = MsgParse.PopInt(ref args);
        int  localRank = CardManager.CardConvert2C(suit, rank);
        var  player    = RoomManager.Instance.rData.GetPlayer(pId);

        if (player != null)
        {
            if (player.handCardsData.Count == 0)
            {
                player.state = EPlayerState.Deal;
            }

            player.handCardsData.Add(localRank);
        }

        Log.Debug("给id={2},{0}发牌数据,本地序号={1},牌个数={3}", player.name, localRank, pId, player.handCardsData.Count);
    }
Beispiel #4
0
    private void RecvNotifyStage(byte[] args)
    {
        int gId = MsgParse.PopInt(ref args);

        if (gId != RoomManager.Instance.rData.gId.Value)
        {
            return;
        }
        var stage = MsgParse.PopByte(ref args);

        int mm = MsgParse.PopInt(ref args);

        RoomManager.Instance.rData.timer.Value       = mm / (float)1000;
        RoomManager.Instance.rData.maxCoolTime.Value = mm / (float)1000;
        Log.Debug("通知Stage={0},time={1}", stage, RoomManager.Instance.rData.timer.Value);

        /*
         * Stage:
         *     1 -  抢庄
         *     2 -  下注
         *     3 -  开牌
         */
        foreach (var player in RoomManager.Instance.rData.allPlayers)
        {
            if (stage == 1)
            {
                player.state = EPlayerState.Banker;
            }
            else if (stage == 2)
            {
                Observable.Timer(TimeSpan.FromSeconds(2)).Subscribe(x => player.state = EPlayerState.Bet);
            }
            else if (stage == 3)
            {
                player.ClearCards();
                player.state = EPlayerState.End;
            }
        }
    }
Beispiel #5
0
    //设置座位状态
    private void RecvSeatState(byte[] args)
    {
        int gid = MsgParse.PopInt(ref args);

        if (gid != RoomManager.Instance.rData.gId.Value)
        {
            return;
        }

        byte pos   = MsgParse.PopByte(ref args);
        byte state = MsgParse.PopByte(ref args);
        int  pId   = MsgParse.PopInt(ref args);

        Log.Debug("设置座位状态pos={0},pid={1}", pos, pId);
        RoomManager.Instance.rData.roomSeats[pos].pid   = pId;
        RoomManager.Instance.rData.roomSeats[pos].state = state;
        RoomManager.Instance.rData.roomSeats[pos].pos   = pos;
        if (pId > 0)
        {
            //通过PID获取玩家的基本信息
            NetWorkManager.Instance.Send(Protocal.PLAYER_INFO, pId);
        }
    }
Beispiel #6
0
    private void RecvNotifyJoin(byte[] args)
    {
        int gId = MsgParse.PopInt(ref args);

        if (gId != RoomManager.Instance.rData.gId.Value)
        {
            return;
        }

        int pId = MsgParse.PopInt(ref args);

        byte pos   = MsgParse.PopByte(ref args);
        int  score = MsgParse.PopInt(ref args);

        //通过PID获取玩家的基本信息
        NetWorkManager.Instance.Send(Protocal.PLAYER_INFO, pId);
        if (pId == GameManager.Instance.GetRoleData().pId.Value)
        {
            RoomManager.Instance.Self.Value.SetPos(pos);
            RoomManager.Instance.Self.Value.state       = EPlayerState.Seat;
            RoomManager.Instance.Self.Value.score.Value = score;
        }
        else
        {
            var player = RoomManager.Instance.rData.GetPlayer(pId) as PlayerOther;
            if (player == null)
            {
                player          = new PlayerOther();
                player.id.Value = pId;
                player.InitData();
                player.SetPos(pos);
                player.state       = EPlayerState.Seat;
                player.score.Value = score;
                RoomManager.Instance.rData.roomPlayers.Add(player);
            }
        }
    }
Beispiel #7
0
    private void RecvNotifyState(byte[] args)
    {
        int gId = MsgParse.PopInt(ref args);

        if (gId != RoomManager.Instance.rData.gId.Value)
        {
            return;
        }
        int pId    = MsgParse.PopInt(ref args);
        int state  = MsgParse.PopByte(ref args);
        var player = RoomManager.Instance.rData.GetPlayer(pId);

        if (player != null && player != RoomManager.Instance.Self.Value)
        {
            if (state == 2)
            {
                player.state = EPlayerState.GamePrepare;
            }
            else if (state == 3)
            {
                player.state = EPlayerState.Seat;
            }
        }
    }
Beispiel #8
0
    public void Handle(object sender, GameFramework.Network.Packet packet)
    {
        var basePacket = (BasePacket)packet;
        var args       = basePacket.args;
        var msgId      = MsgParse.PopByte(ref args);

        if (msgId != 23 && msgId != 38)
        {
            Log.Debug("<<<<<<<<<<<<<<<<<<<<{0}", msgId);
        }
        switch (msgId)
        {
        case Protocal.Error:
            RecvError(args);
            break;

        case Protocal.GOOD:
            RecvGood(args);
            break;

        case Protocal.RecvLogin:
            RecvLogin(args);
            break;

        case Protocal.NOTIFY_DRAW:
            RecvNotifyDraw(args);
            break;

        case Protocal.NOTIFY_PRIVATE:
            RecvNotifyPrivate(args);
            break;

        case Protocal.NOTIFY_SHARED:
            RecvNotifyShared(args);
            break;

        case Protocal.NOTIFY_JOIN:
            RecvNotifyJoin(args);
            break;

        case Protocal.NOTIFY_LEAVE:
            RecvNotifyLeave(args);
            break;

        case Protocal.NOTIFY_CHAT:
            RecvNotifyChat(args);
            break;

        case Protocal.NOTIFY_START:
            RecvNotifyStart(args);
            break;

        case Protocal.NOTIFY_END:
            RecvNotifyEnd(args);
            break;

        case Protocal.NOTIFY_WIN:
            RecvNotifyWin(args);
            break;

        case Protocal.NOTIFY_BET:
            RecvNotifyBet(args);
            break;

        case Protocal.NOTIFY_RAISE:
            RecvNotifyRaise(args);
            break;

        case Protocal.NOTIFY_CALL:
            RecvNotifyCall(args);
            break;

        case Protocal.NOTIFY_STATE:
            RecvNotifyState(args);
            break;

        case Protocal.NOTIFY_STAGE:
            RecvNotifyStage(args);
            break;

        case Protocal.NOTIFY_BUTTON:
            RecvNotifyButton(args);
            break;

        case Protocal.BALANCE:
            RecvBalance(args);
            break;

        case Protocal.NOTIFY_SB:
            RecvNotifySB(args);
            break;

        case Protocal.NOTIFY_BB:
            RecvNotifyBB(args);
            break;

        case Protocal.SEAT_STATE:
            RecvSeatState(args);
            break;

        case Protocal.PLAYER_SUMMARY:
            RecvPlayerSummary(args);
            break;

        case Protocal.NOTIFY_READY:
            RecvNotifyReady(args);
            break;

        case Protocal.NOTIFY_READY_CANCEL:
            RecvNotifyReadyCancel(args);
            break;

        case Protocal.BID_REQ:
            RecvBIDREQ(args);
            break;

        case Protocal.NOTIFY_BID:
            RecvNotifyBid(args);
            break;

        case Protocal.NOTIFY_LAY:
            RecvNotifyLay(args);
            break;

        default:
            break;
        }
    }