Beispiel #1
0
    //加入开房结果
    public void JoinRoomRqs(SocketModel socketModel)
    {
        Debug.Log("收到加入房间返回结果" + socketModel.GetCommand());
        if (socketModel.GetCommand() == Helper_ErrCode.ErrCommand_Hall_JoinSucceed_加入房间成功)
        {
            GameInfo.Instance.roomId       = socketModel.GetData()[0];
            GameInfo.Instance.positon      = socketModel.GetData()[1];
            GameInfo.Instance.myGold       = socketModel.GetData()[2];
            GameInfo.Instance.maxRound     = socketModel.GetData()[3];
            GameInfo.Instance.maxPoint     = socketModel.GetData()[4];
            GameInfo.Instance.isZjDouble   = socketModel.GetData()[5];
            GameInfo.Instance.canQiangGang = socketModel.GetData()[6];
            GameInfo.Instance.isDaiGen     = socketModel.GetData()[7];
            GameInfo.Instance.isZiMoHu     = socketModel.GetData()[8];
            GameInfo.Instance.roomPassWord = socketModel.GetData()[9];


            List <String> list = socketModel.GetMessage();
            for (int i = 0; i < list.Count; i++)
            {
                if ((i + 1) % 4 == 0)
                {
                    GameInfo.Instance.addNewPlayer(int.Parse(list[i - 3]), list[i - 2], list[i - 1], int.Parse(list[i]));
                    Debug.Log("有玩家=" + i);
                }
            }
            Debug.Log("加入房间成功");
            GameEvent.DoSenceEvent("game");
        }
        else
        {
            switch (socketModel.GetCommand())
            {
            case Helper_ErrCode.ErrCommand_Hall_WrongPW_密码不正确:
                GameEvent.DoMsgEvent("密码不正确!");
                break;

            case Helper_ErrCode.ErrCommand_Hall_RooMInvalid_房间不存在:
                GameEvent.DoMsgEvent("房间不存在!");
                break;

            case Helper_ErrCode.ErrCommand_Hall_RoomFull_房间人满:
                GameEvent.DoMsgEvent("房间人满!");
                break;

            case Helper_ErrCode.ErrCommand_Hall_UserExit_玩家已在房间:
                GameEvent.DoMsgEvent("玩家已存在!");
                break;
            }
        }
    }
Beispiel #2
0
 //返回开房结果
 public void CreatRoomRqs(SocketModel socketModel)
 {
     if (socketModel.GetCommand() == 11)
     {
         List <int> list = socketModel.GetData();
         GameInfo.Instance.roomId       = list[0];
         GameInfo.Instance.positon      = list[1];
         GameInfo.Instance.myGold       = list[2];
         GameInfo.Instance.maxRound     = list[3];
         GameInfo.Instance.maxPoint     = list[4];
         GameInfo.Instance.isZjDouble   = list[5];
         GameInfo.Instance.canQiangGang = list[6];
         GameInfo.Instance.isDaiGen     = list[7];
         GameInfo.Instance.isZiMoHu     = list[8];
         GameInfo.Instance.roomPassWord = list[9];
         int fk = list[10];
         //更新钻石
         int fk2 = GameInfo.Instance.UserFK - fk;
         GameInfo.Instance.setUserFk(fk2);
         GameEvent.DoSenceEvent("game");
         Debug.Log("开房成功,房间ID=" + GameInfo.Instance.roomId);
         Debug.Log("开房成功,我的位置=" + GameInfo.Instance.positon);
         Debug.Log("开房成功,我的金币=" + GameInfo.Instance.myGold);
         Debug.Log("开房成功,最大圈数=" + GameInfo.Instance.maxRound);
         Debug.Log("开房成功,最大番数=" + GameInfo.Instance.maxPoint);
     }
     else
     {
         Debug.Log("开房失败 socketModel.GetComman=" + socketModel.GetCommand());
         GameEvent.DoMsgEvent("开房失败!");
     }
 }
Beispiel #3
0
    //分享钻石
    public void FenXiangRqs(SocketModel socketModel)
    {
        if (socketModel.GetCommand() == 18)
        {
            List <int> list = socketModel.GetData();
            int        fk   = list[0];
            GameInfo.Instance.setUserFk(fk);
            GameEvent.DoMsgTipEvent("分享钻石成功!");

            List <string> mList = socketModel.GetMessage();
            MailData      md    = new MailData();
            md.setDataTime(mList[0]);
            md.setFk(int.Parse(mList[1]));
            md.setGid(int.Parse(mList[2]));
            md.setStype(int.Parse(mList[3]));
            GameInfo.Instance.mailList.Insert(0, md);
        }
        else if (socketModel.GetCommand() == 17)
        {
            GameEvent.DoMsgTipEvent("用户不存在!");
        }
        else
        {
            GameEvent.DoMsgTipEvent("未知错误!");
        }
    }
Beispiel #4
0
    //摸牌
    public void MoPai(SocketModel socketModel)
    {
        //GameEvent.DoMsgTipEvent(" 收到摸牌数据");
        List <string> msgList = socketModel.GetMessage();

        //如果是自己摸牌
        Debug.Log("摸牌的位置=" + int.Parse(msgList[0]));
        if (int.Parse(msgList[0]) == GameInfo.Instance.positon)
        {
            Debug.Log("是自己摸牌 摸的牌= " + int.Parse(msgList[1]));
            //GameEvent.DoMsgTipEvent("是自己摸牌 摸的牌= " + int.Parse(msgList[1]));
            //摸起的牌放到手牌队列里
            int mj = int.Parse(msgList[1]);
            GameInfo.Instance.putMjtoHandList(mj);
            //广播给UI显示
            GameEvent.DoMoPai(mj);
            Debug.Log("摸牌==" + mj);
            //是否能,杠,糊
            List <int> list = socketModel.GetData();
            RoomEvent.DoActionList(list);
            //如果Action有数据,可以杠
            if (socketModel.GetAdata() != null && socketModel.GetAdata().Count > 0)
            {
                Debug.Log("可以杠牌=" + socketModel.GetAdata().Count);
                GameInfo.Instance.gangList = socketModel.GetAdata();//杠的数据保存在INFO, 选择牌型后清空
            }
        }
        //不管是谁摸,更新牌的数量
        Debug.Log("剩余牌的数量=" + socketModel.GetCommand());
        int mjNum = socketModel.GetCommand();

        RoomEvent.DoActionLeftMj(mjNum);
    }
Beispiel #5
0
    //抢杠
    public void QiangGang(SocketModel socketModel)
    {
        //收到这个数据说明,能抢杠胡
        List <int> list = socketModel.GetData();

        RoomEvent.DoActionList(list);
    }
Beispiel #6
0
    //开局
    public void RoomGameStart(SocketModel socketModel)
    {
        //
        GameInfo.Instance.isGameStart = 1;
        int value = socketModel.GetCommand();

        if (value > 0)
        {
            //手牌
            List <int> list = socketModel.GetData();
            list.Reverse();
            GameInfo.Instance.myHandMj = list;

            //房间信息
            List <string> msg = socketModel.GetMessage();
            GameInfo.Instance.zhuangjia = int.Parse(msg[0]);
            GameInfo.Instance.round     = int.Parse(msg[1]);
            GameInfo.Instance.mjLeft    = int.Parse(msg[2]);
            //开始后,设置所有人状态为未准备
            GameInfo.Instance.isMyReady    = 0;
            GameInfo.Instance.isRightReady = 0;
            GameInfo.Instance.isTopReady   = 0;
            GameInfo.Instance.isLeftReady  = 0;
            //通知UI游戏开始了
            GameEvent.DoGameStartEvent(1);
            Debug.Log("人满开局发牌 " + list);
        }
        int mjNum = socketModel.GetCommand();

        RoomEvent.DoActionLeftMj(mjNum);
    }
Beispiel #7
0
    //聊天
    public void Chat(SocketModel socketModel)
    {
        List <int> list = socketModel.GetData();
        int        pos  = list[0];
        int        txt  = list[1];

        GameEvent.DoChat(pos, txt);
    }
Beispiel #8
0
    //明杠
    public void MingGang(SocketModel socketModel)
    {
        Debug.Log("收到明杠数据");
        List <int> list = socketModel.GetData();
        int        pos  = list[0];
        int        mj   = list[1];

        GameInfo.Instance.addMingGang(pos, mj);
    }
Beispiel #9
0
    //碰牌
    public void PengPai(SocketModel socketModel)
    {
        List <int> list  = socketModel.GetData();
        int        pos   = list[0];
        int        mj    = list[1];
        List <int> alist = new List <int>();

        alist.Add(mj); alist.Add(mj);
        Action act = new Action();

        act.setActionType(CardView.CHI_PENG_碰牌);
        act.setActionData(alist);
        GameInfo.Instance.addPengPai(pos, act);
        RoomEvent.DoPlayerDiction(pos, 2);
    }
Beispiel #10
0
    //暗杠
    public void AnGang(SocketModel socketModel)
    {
        Debug.Log("收到暗杠数据");
        List <int> plist = socketModel.GetData();
        int        pos   = plist[0];
        int        mj    = plist[1];
        List <int> alist = new List <int>();

        alist.Add(mj); alist.Add(mj); alist.Add(mj); alist.Add(mj);
        Action act = new Action();

        act.setActionType(CardView.CHI_ANGANG_暗杠);
        act.setActionData(alist);
        Debug.Log("暗杠 pos=" + pos + "mj=" + mj);
        GameInfo.Instance.addAnGang(pos, act);
    }
Beispiel #11
0
    //直杠
    public void ZhiGang(SocketModel socketModel)
    {
        Debug.Log("收到直杠数据");
        List <int> plist      = socketModel.GetData();
        int        pos        = plist[0];
        int        mj         = plist[1];
        int        beiGangPos = plist[2];
        //
        List <int> alist = new List <int>();

        alist.Add(mj); alist.Add(mj); alist.Add(mj); alist.Add(mj);
        Action act = new Action();

        act.setActionType(CardView.CHI_GANG_杠牌);
        act.setActionData(alist);
        //
        GameInfo.Instance.addZhiGang(pos, act, beiGangPos);
        //设置操作方向
        RoomEvent.DoPlayerDiction(pos, 2);
    }
Beispiel #12
0
    //自摸
    public void ZiMo(SocketModel socketModel)
    {
        List <int> dlist   = socketModel.GetData();
        int        pos     = dlist[0];
        int        mj      = dlist[1];
        string     sendPos = "";

        if (pos == GameInfo.Instance.positon)
        {
            sendPos = "bot";
        }
        else
        {
            sendPos = GameInfo.Instance.TryGetLocPos(GameInfo.Instance.positon, pos);
        }
        List <PlayerData> plist = socketModel.GetPdata();

        RoomEvent.DoZiMo(sendPos, mj, plist);
        //
        GameInfo.Instance.PlayFlag = false;
    }
Beispiel #13
0
    //吃胡
    public void HuPai(SocketModel socketModel)
    {
        List <int> list       = socketModel.GetData();
        int        pos        = list[0];
        int        mj         = list[1];
        int        fangpaoPos = list[2];
        string     sendPos    = String.Empty;

        if (pos == GameInfo.Instance.positon)
        {
            sendPos = "bot";
        }
        else
        {
            sendPos = GameInfo.Instance.TryGetLocPos(GameInfo.Instance.positon, pos);
        }
        List <PlayerData> plist = socketModel.GetPdata();

        RoomEvent.DoChiHu(sendPos, mj, fangpaoPos, plist);
        //
        GameInfo.Instance.PlayFlag = false;
    }
Beispiel #14
0
    //出牌
    public void ChuPai(SocketModel socketModel)
    {
        //1.先把出的牌显示出来
        List <string> list = socketModel.GetMessage();
        //2.其他玩家有没有操作
        int stats = socketModel.GetCommand();

        if (stats == 0)
        {
            GameEvent.DoChuPai(int.Parse(list[0]), int.Parse(list[1]), false);
        }
        else
        {
            GameEvent.DoChuPai(int.Parse(list[0]), int.Parse(list[1]), true);
        }

        Debug.Log("位置=" + list[0] + "出牌 = " + list[1]);
        //3如果没人操作,设置指示方向
        if (stats == 0)
        {
            Debug.Log("设置指示方向");
            RoomEvent.DoPlayerDiction(int.Parse(list[2]));
        }
        //如果是玩家自己出的牌就不继续判断读取数据了
        if (int.Parse(list[0]) == GameInfo.Instance.positon)
        {
            Debug.Log("如果是玩家自己出的牌就不继续判断读取数据了");
            return;
        }
        //4.看看自己是否可以可以吃,碰 等操作;
        List <int> mylist = socketModel.GetData();

        Debug.Log("mylist=" + mylist);
        if (mylist != null)
        {
            //如果有操作,通知UI显示相关按键
            Debug.Log("自己有操作=" + mylist[0]);
            //如果Action有数据,可以杠
            List <Action> actionlist = socketModel.GetAdata();
            if (actionlist != null)
            {
                Debug.Log("可以杠牌=" + actionlist.Count);
                GameInfo.Instance.gangList = actionlist;//杠的数据保存在INFO, 选择牌型后清空
            }
            RoomEvent.DoActionList(mylist);
        }
        else
        {
            //3.如果自己没有操作,再看其他玩家可以,吃,碰等操作.如果有,就等待.
            if (stats == 0)
            {
                Debug.Log("没有人可以吃,碰操作");
                //4.如果其他玩家也没操作,那看看本轮出牌权是否是自己,如果是自己那就向服务器摸牌
                if (int.Parse(list[2]) == GameInfo.Instance.positon)
                {
                    RoomEvent.DoActionMoPai();
                }
            }
            else
            {
                Debug.Log("有人操作,吃,碰等操作,要等待");
            }
        }
    }