Esempio n. 1
0
    /// <summary>
    /// 互动表情点击回调
    /// </summary>
    /// <param name="id"></param>
    private void OnHudongClickCallback(int id)
    {
        MJGameController    mCtr = Global.Inst.GetController <MJGameController>();
        SendReceiveGameChat req  = new SendReceiveGameChat();

        req.chatType   = (int)eGameChatContentType.HDFace;
        req.faceIndex  = id;
        req.fromSeatId = MJGameModel.Inst.mMySeatId;
        req.toSeatId   = mRoomPlayerInfo.seatId;
        mCtr.SendGameChat(req);
    }
Esempio n. 2
0
    /// <summary>
    /// 打牌
    /// </summary>
    public void SendOutCard(List <CanHuStruct> canHuList = null)
    {
        if (!MJGameModel.Inst.mIsTing && MJGameModel.Inst.mStartGameData.roomInfo.roomState == eRoomState.START) //不是在报叫
        {
            OptRequest data = new OptRequest();
            data.ins   = eMJInstructionsType.HIT;
            data.cards = new List <int>();
            data.cards.Add(mNum);
            MJGameController mGameCtr = Global.Inst.GetController <MJGameController>();
            #region 判断点击的牌是否符合要求   符合要求发送消息   出牌   不符合设置为没选中


            if (MJGameModel.Inst.isHu)
            {
                int curCard = MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].currCard;
                if (curCard > 0 && mNum == curCard)
                {
                }
                else
                {
                    SetCardUnSelect();
                    return;
                }
            }

            if (MJGameModel.Inst.isHasFixeCard)
            {
                if (MJGameModel.Inst.eFixe[0] == 0 || mNum > MJGameModel.Inst.eFixe[0] && mNum < MJGameModel.Inst.eFixe[1])
                {
                }
                else
                {
                    SetCardUnSelect();
                    return;
                }
            }
            if (!MJGameModel.Inst.isMyHit)
            {
                SetCardUnSelect();
                return;
            }
            #endregion
            MJGameModel.Inst.isMyHit = false;
            Debug.Log("出牌");
            mGameCtr.SendOptRequest(data, () =>
            {
            }, false);
            MJGameModel.Inst.hasCanHuListCards = null;
        }
    }
Esempio n. 3
0
    /// <summary>
    /// 继续
    /// </summary>
    public void OnContinueClick()
    {
        MJGameController mMJctr = Global.Inst.GetController <MJGameController>();

        MJGameModel.Inst.ResetData();
        if (mInfo == null)//解散过后
        {
            mMJctr.ConnectedToHallServer(null);
        }
        else
        {
            MJGameSettlementFinalInfo info = MJGameModel.Inst.mFinalSettlementInfo;
            if (info != null)
            {
                if (info != null)
                {
                    mMJctr.mGameUI.ServerSettlementFinal(info);
                    CloseWidget <MJGameSettlementView>();
                    //gameObject.SetActive(false);
                    return;
                }
                else
                {
                    Global.Inst.GetController <MJGameController>().ConnectedToHallServer(null);
                }
            }
            else
            {
                //准备
                mMJctr.mGameUI.SetSelfPreShow(false);
                OptRequest req = new OptRequest();
                req.ins = eMJInstructionsType.READY;
                Global.Inst.GetController <MJGameController>().SendOptRequest(req);
                Close();
            }
        }
    }
Esempio n. 4
0
    private void HandleStartGameData(StartGameRespone data)
    {
        mjController = Global.Inst.GetController <MJGameController>();
        #region 准备房间 玩家数据移植
        //StartGameRespone data = msg.Read<StartGameRespone>();

        MJGameModel.Inst.mStartGameData = data;
        SQDebug.Log("准备房间 玩家数据移植:" + Time.deltaTime);
        MJGameModel.Inst.mPlayCount    = data.roomInfo.maxGameCount;  //最大局数
        MJGameModel.Inst.mCurPlayCount = data.roomInfo.currGameCount; //当前局数
        MJGameModel.Inst.mRoomId       = data.roomInfo.roomId;        //房间号
        MJGameModel.Inst.mZhuangSeatId = data.startInfo.zhuangSeatId;
        foreach (var itemRoomPlayer in data.roomInfo.playerList)      //玩家信息数据
        {
            if (itemRoomPlayer.uId == PlayerModel.Inst.UserInfo.userId)
            {
                MJGameModel.Inst.mMySeatId = itemRoomPlayer.seatId;
                break;
            }
        }
        //MJGameModel.Inst.mMySeatId = data.roomInfo.mySeatId;//我自己的座位号
        MJGameModel.Inst.mRoomMgSeatId = 1;             //房主座位号
        int totalPlayerCount = data.roomInfo.maxPlayer; //房间总共人数
        MJGameModel.Inst.totalPlayerCount = totalPlayerCount;
        totalPlayerCount = totalPlayerCount == 2 ? 4 : totalPlayerCount;
        MJGameModel.Inst.AllPlayerEfixe = new List <int[]>();//所有玩家定缺区间
        for (int i = 0; i < 5; i++)
        {
            MJGameModel.Inst.AllPlayerEfixe.Add(new int[2]);
        }
        MJGameModel.Inst.mnewSeatToIndex       = new int[totalPlayerCount + 1];              //玩家座位号 数组
        MJGameModel.Inst.mSeatToDirectionIndex = new int[5];                                 //所有玩家座位号对应桌面东南西北高亮显示的index
        MJGameModel.Inst.mRoomPlayers          = new PlayerInfoStruct[totalPlayerCount + 1]; //玩家 数据缓存数组
        foreach (var itemRoomPlayer in data.roomInfo.playerList)                             //玩家信息数据
        {
            MJGameModel.Inst.mRoomPlayers[itemRoomPlayer.seatId]          = itemRoomPlayer;
            MJGameModel.Inst.mnewSeatToIndex[itemRoomPlayer.seatId]       = mjController.SeatIdToIndex(MJGameModel.Inst.mMySeatId, itemRoomPlayer.seatId, totalPlayerCount);
            MJGameModel.Inst.mSeatToDirectionIndex[itemRoomPlayer.seatId] = mjController.SeatIdToDirectionIndex(MJGameModel.Inst.mMySeatId, itemRoomPlayer.seatId, data.roomInfo.maxPlayer);
        }
        #endregion
        MJGameModel.Inst.isGetStartGameData        = true;
        MJGameModel.Inst.totalCardNum              = data.startInfo.totalCardNum;                                 //总共有多少张牌
        MJGameModel.Inst.leaveCardNum              = data.startInfo.leaveCardNum;                                 //剩余多少张牌
        MJGameModel.Inst.mCurInsSeatId             = data.startInfo.currTurnSeatId;                               //当前指针 指的玩家座位号
        MJGameModel.Inst.isMyHit                   = data.startInfo.currTurnSeatId == MJGameModel.Inst.mMySeatId; //是否轮到我操作
        MJGameModel.Inst.allPlayersCardsInfoStruct = new CardsInfoStruct[totalPlayerCount + 1];
        //可操作列表
        if (data.roomInfo.optList != null)
        {
            for (int i = 0; i < data.roomInfo.optList.Count; i++)
            {
                if (data.roomInfo.optList[i].ins == eMJInstructionsType.HIT)
                {
                    mjController.GetCanHuList(data.roomInfo.optList[i]);
                }
            }
        }
        //手牌信息
        if (data.startInfo.cardsInfoList != null)
        {
            foreach (var item in data.startInfo.cardsInfoList)
            {
                MJGameModel.Inst.allPlayersCardsInfoStruct[item.seatId] = item;
                //找出我定缺的类型
                if (item.seatId == MJGameModel.Inst.mMySeatId) //我自己
                {
                    if (item.isFixedColor)                     //已经定缺
                    {
                        MJGameModel.Inst.SetMyFixedType(item.fixedType);
                        if (item.handList != null)//手牌排序
                        {
                            item.handList = MJGameModel.Inst.ChangList(item.handList, item.fixedType);
                        }
                    }
                    else
                    {
                        MJGameModel.Inst.SetMyFixedType(0);
                    }
                }

                if (item.handList != null)
                {
                    foreach (var VARIABLE in item.handList)
                    {
                        MJGameModel.Inst.mySelfCards.Add(VARIABLE);
                    }
                    if (item.isHasCurrCard)
                    {
                        MJGameModel.Inst.mySelfCards.Add(item.currCard);
                    }

                    foreach (var oneItem in MJGameModel.Inst.mySelfCards)
                    {
                        if (oneItem < 10)
                        {
                            MJGameModel.Inst.handCardsTiao.Add(oneItem);
                        }
                        else if (oneItem < 20)
                        {
                            MJGameModel.Inst.handCardsTong.Add(oneItem);
                        }
                        else if (oneItem < 30)
                        {
                            MJGameModel.Inst.handCardsWan.Add(oneItem);
                        }
                    }
                }
            }
        }
    }