コード例 #1
0
ファイル: SCNotifyGetMahjong.cs プロジェクト: microxw/MaQ
    public override void execute()
    {
        CommandCharacterGet cmd = mCommandSystem.newCmd <CommandCharacterGet>();

        cmd.mMahjong = (MAHJONG)mMahjong.mValue;
        mCommandSystem.pushCommand(cmd, mCharacterManager.getCharacterByGUID(mPlayerGUID.mValue));
    }
コード例 #2
0
    public override void execute()
    {
        CommandCharacterGet cmd = newCmd(out cmd);

        cmd.mMahjong = (MAHJONG)mMahjong.mValue;
        pushCommand(cmd, mCharacterManager.getCharacter(mPlayerGUID.mValue));
    }
コード例 #3
0
ファイル: MahjongSystem.cs プロジェクト: quyixia/Mahjong
 public void notifyPlayerDrop(Character player, MAHJONG mah)
 {
     // 正常游戏过程中,玩家打了一张牌后,判断其他玩家是否有碰或者杠,该下家摸牌
     if (mPlayState == MAHJONG_PLAY_STATE.MPS_NORMAL_GAMING)
     {
         // 判断其他玩家是否可以碰或者杠
         bool hasAction = false;
         foreach (var item in mPlayerIDList)
         {
             if (item.Value != player)
             {
                 List <MahjongAction> checkActionList = new List <MahjongAction>();
                 CharacterData        data            = item.Value.getCharacterData();
                 // 是否可胡
                 if (GameUtility.canHu(data.mHandIn, mah))
                 {
                     List <HU_TYPE> huList = GameUtility.generateHuType(data.mHandIn, mah, data.mPengGangList, false, false);
                     checkActionList.Add(new MahjongAction(ACTION_TYPE.AT_HU, item.Value, player, mah, huList));
                 }
                 // 是否可杠
                 if (GameUtility.canGang(data.mHandIn, mah))
                 {
                     checkActionList.Add(new MahjongAction(ACTION_TYPE.AT_GANG, item.Value, player, mah));
                 }
                 // 是否可碰
                 if (GameUtility.canPeng(data.mHandIn, mah))
                 {
                     checkActionList.Add(new MahjongAction(ACTION_TYPE.AT_PENG, item.Value, player, mah));
                 }
                 if (checkActionList.Count > 0)
                 {
                     hasAction = true;
                     // 添加pass操作
                     checkActionList.Add(new MahjongAction(ACTION_TYPE.AT_PASS, item.Value, player, mah));
                     askPlayerAction(item.Value, player, mah, checkActionList);
                 }
             }
         }
         // 没有人需要这张牌,则该下家摸牌
         if (!hasAction)
         {
             if (mMahjongPool.Count > 0)
             {
                 PLAYER_POSITION     nextPosition = (PLAYER_POSITION)(((int)(player.getCharacterData().mPosition) + 1) % (int)PLAYER_POSITION.PP_MAX);
                 Character           nextPlayer   = getCharacterByPosition(nextPosition);
                 CommandCharacterGet cmdGet       = mCommandSystem.newCmd <CommandCharacterGet>();
                 cmdGet.mMahjong = requestGet();
                 mCommandSystem.pushCommand(cmdGet, nextPlayer);
             }
             // 牌已经摸完了,则本局为平局
             else
             {
                 //End;
             }
         }
     }
 }
コード例 #4
0
ファイル: MahjongSystem.cs プロジェクト: quyixia/Mahjong
    // 玩家请求确认操作
    public void playerConfirmAction(Character player, ACTION_TYPE type)
    {
        if (!mWaitList.ContainsKey(player))
        {
            UnityUtility.logError("player has no action : name : " + player.getName() + ", action : " + type);
        }
        MahjongAction        action     = null;
        List <MahjongAction> actionList = mWaitList[player].mActionList;
        int actionCount = actionList.Count;

        for (int i = 0; i < actionCount; ++i)
        {
            if (actionList[i].mType == type)
            {
                action = actionList[i];
                break;
            }
        }
        if (action == null)
        {
            return;
        }
        mWaitList[player].mConfirmedAction = action;
        // 胡牌的优先级最高,如果有玩家选择胡牌,则忽略其他玩家的操作
        if (action.mType == ACTION_TYPE.AT_HU)
        {
            // 游戏状态设置为正常游戏
            notifyPlayState(MAHJONG_PLAY_STATE.MPS_NORMAL_GAMING);
            CommandCharacterHu cmd = mCommandSystem.newCmd <CommandCharacterHu>();
            mCommandSystem.pushCommand(cmd, player);

            // 有玩家胡牌后则结束游戏
            //End;
        }
        else
        {
            bool          allConfirm          = true;
            Character     highestActionPlayer = null;
            MahjongAction highestAction       = null;
            foreach (var wait in mWaitList)
            {
                if (wait.Value.mConfirmedAction == null)
                {
                    allConfirm = false;
                    break;
                }
                if (highestAction == null || highestAction.mType > wait.Value.mConfirmedAction.mType)
                {
                    highestAction       = wait.Value.mConfirmedAction;
                    highestActionPlayer = wait.Value.mPlayer;
                }
            }
            // 如果全部玩家都已经确认操作了,允许优先级最高的操作进行
            if (allConfirm)
            {
                // 先获得信息,因为在设置状态时会将列表清空
                WaitActionInfo info = mWaitList[highestActionPlayer];
                // 游戏状态设置为正常游戏
                notifyPlayState(MAHJONG_PLAY_STATE.MPS_NORMAL_GAMING);
                if (highestAction.mType == ACTION_TYPE.AT_GANG)
                {
                    // 自己摸的牌开杠
                    if (info.mDroppedPlayer == info.mPlayer)
                    {
                        ;
                    }
                    // 别人打出牌开杠
                    else
                    {
                        ;
                    }
                    CommandCharacterGang cmd = mCommandSystem.newCmd <CommandCharacterGang>();
                    cmd.mDroppedPlayer = info.mDroppedPlayer;
                    cmd.mMahjong       = info.mMahjong;
                    mCommandSystem.pushCommand(cmd, info.mPlayer);

                    // 还有牌,玩家杠了一张牌以后需要再摸一张
                    if (mMahjongPool.Count > 0)
                    {
                        CommandCharacterGet cmdGet = mCommandSystem.newCmd <CommandCharacterGet>();
                        cmdGet.mMahjong = requestGet();
                        mCommandSystem.pushCommand(cmdGet, info.mPlayer);
                    }
                    // 没有牌了则平局
                    else
                    {
                        //End;
                    }
                }
                else if (highestAction.mType == ACTION_TYPE.AT_PENG)
                {
                    CommandCharacterPeng cmd = mCommandSystem.newCmd <CommandCharacterPeng>();
                    cmd.mDroppedPlayer = info.mDroppedPlayer;
                    cmd.mMahjong       = info.mMahjong;
                    mCommandSystem.pushCommand(cmd, info.mPlayer);

                    CommandCharacterAskDrop cmdAskDrop = mCommandSystem.newCmd <CommandCharacterAskDrop>();
                    mCommandSystem.pushCommand(cmdAskDrop, info.mPlayer);
                }
                else if (highestAction.mType == ACTION_TYPE.AT_PASS)
                {
                    // 如果是自己摸了一张牌,选择了pass,则需要自己打一张牌出来
                    if (info.mDroppedPlayer == info.mPlayer)
                    {
                        CommandCharacterAskDrop cmd = mCommandSystem.newCmd <CommandCharacterAskDrop>();
                        mCommandSystem.pushCommand(cmd, info.mPlayer);
                    }
                    else
                    {
                        // 还有牌则通知下一家摸牌
                        if (mMahjongPool.Count > 0)
                        {
                            PLAYER_POSITION     nextPosition = (PLAYER_POSITION)(((int)(info.mDroppedPlayer.getCharacterData().mPosition) + 1) % (int)PLAYER_POSITION.PP_MAX);
                            CommandCharacterGet cmdGet       = mCommandSystem.newCmd <CommandCharacterGet>();
                            cmdGet.mMahjong = requestGet();
                            mCommandSystem.pushCommand(cmdGet, getCharacterByPosition(nextPosition));
                        }
                        // 没有牌了则平局
                        else
                        {
                            //End;
                        }
                    }
                }
            }
        }
    }