public override void execute() { GameScene gameScene = mGameSceneManager.getCurScene(); if (gameScene.getType() != GAME_SCENE_TYPE.GST_MAHJONG) { return; } CommandCharacterGang cmdGang = mCommandSystem.newCmd <CommandCharacterGang>(); cmdGang.mDroppedPlayer = mCharacterManager.getCharacterByGUID(mDroppedPlayerGUID.mValue); cmdGang.mMahjong = (MAHJONG)mMahjong.mValue; mCommandSystem.pushCommand(cmdGang, mCharacterManager.getMyself()); }
public override void execute() { GameScene gameScene = mGameSceneManager.getCurScene(); if (gameScene.getSceneType() != GAME_SCENE_TYPE.GST_MAHJONG) { return; } // 清空提示信息 mScriptMahjongFrame.notifyInfo(""); CommandCharacterGang cmdGang = newCmd(out cmdGang); cmdGang.mDroppedPlayer = mCharacterManager.getCharacter(mDroppedPlayerGUID.mValue); cmdGang.mMahjong = (MAHJONG)mMahjong.mValue; pushCommand(cmdGang, mCharacterManager.getCharacter(mOtherPlayerGUID.mValue)); }
public override void execute() { GameScene gameScene = mGameSceneManager.getCurScene(); if (gameScene.getSceneType() != GAME_SCENE_TYPE.GST_MAHJONG) { return; } // 清空提示信息 ScriptMahjongFrame mahjongFrame = mLayoutManager.getScript(LAYOUT_TYPE.LT_MAHJONG_FRAME) as ScriptMahjongFrame; mahjongFrame.notifyInfo(""); CommandCharacterGang cmdGang = mCommandSystem.newCmd <CommandCharacterGang>(); cmdGang.mDroppedPlayer = mCharacterManager.getCharacter(mDroppedPlayerGUID.mValue); cmdGang.mMahjong = (MAHJONG)mMahjong.mValue; mCommandSystem.pushCommand(cmdGang, mCharacterManager.getCharacter(mOtherPlayerGUID.mValue)); }
// 玩家请求确认操作 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; } } } } } }