|
- require("luaScript.Views.Room.RoomFunctions")
- local MJRoomToolView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomToolView")
- local MJRoomMessageView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomMessageView")
- local MJRoomPlayerView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomPlayerView")
- local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJHandCardView=MJFramework.MJImport("mj.luaScript.Views.Game.MJHandCardView")
- local MJRoomXiaoJuView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomXiaoJuView")
- local MJRoomDaJuView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDaJuView")
- local MJRoomDismissView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDismissView")
- local MJRoomDirection=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDirection")
- local MJMessage=MJFramework.MJImport("mj.luaScript.Protocol.MJMessage")
- local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
- local MJWanFa=MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa")
- local MJAnimationCompnent=MJFramework.MJImport("mj.luaScript.Views.Compnent.MJAnimationCompnent")
- local MJFunction=MJFramework.MJImport("mj.luaScript.MJFunction")
- local MJSound = MJFramework.MJImport("mj.luaScript.MJSound")
-
- local MJRoomView = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomView")
- local huamajiangRoomView = class("huamajiangRoomView", MJRoomView)
-
- local zhongNiaoTime=1.33
- local HU_EFFECT_TAG = 100
-
- function huamajiangRoomView:ctor()
- huamajiangRoomView.super.ctor(self)
- self.operates = {}
-
- MJDefine.MJConfig = MJDefine.loadMJConfig(self.desktopType)
- end
-
- function huamajiangRoomView:loadUi()
- local ui = loadUI("mj_huamajiang/res/ui_fangjian/mj_huamajiang_roomView.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function huamajiangRoomView:onEnter()
- huamajiangRoomView.super.onEnter(self)
-
- self.ZOrder = {};
-
- --获取是否贴鬼杠和是否自动对齐
- self:setCheckDefault()
- self:doSound()
-
- self:initLogo()
- end
-
- ---
- -- 更新logo
- -- @return
- --
- --[[function huamajiangRoomView:initLogo ()
- local config = getSubGameConfig(GAME_IDS.huamajiang or app.gameId)
-
- if config and config.logo then
- self.ui.Items.ImageView_Logo:loadTexture(config.logo,0);
- end
-
- if config.isShowLogo == false then
- self.ui.Items.ImageView_Logo:setVisible(false)
- end
- end--]]
-
- --- huamajiangRoomView:addToLayer 添加节点至指定层
- -- @param layerName 指定层级的名称,background(背景层)、game(游戏层)、anim(动画特效层)、popup(弹框层)、system(系统弹框层)
- -- @param node 要添加的节点
- -- @param zorder 指定的zorder
- function huamajiangRoomView:addToLayer(layerName, node, zorder)
- if layerName == "background" then
- layerName = "Layout_Background";
- elseif layerName == "game" then
- layerName = "Layout_Game";
- elseif layerName == "anim" then
- layerName = "Layout_Anim";
- elseif layerName == "popup" then
- layerName = "Layout_PopUp";
- elseif layerName == "system" then
- layerName = "Layout_System";
- end
-
- local layer = self.ui.Items[layerName];
- if not layer then
- self:addChild(node)
- return ;
- end
- self.ZOrder = self.ZOrder or {};
- self.ZOrder[layerName] = self.ZOrder[layerName] or 0;
- self.ZOrder[layerName] = zorder or (self.ZOrder[layerName] + 1);
- node:setLocalZOrder(self.ZOrder[layerName])
- layer:addChild(node);
- end
-
- function huamajiangRoomView:onExit()
- huamajiangRoomView.super.onExit(self)
-
- if self.SwapTime then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.SwapTime)
- end
-
- self:cleanCache()
- end
-
- function huamajiangRoomView:cleanCache()
- local preload = package.loaded
- for k, v in pairs(package.loaded or {}) do
- local res1 = string.find( k, "mj.luaScript") or 0
- local res2 = string.find( k, "mj_huamajiang.luaScript") or 0
- if res1 > 0 or res2 > 0 then
- package.loaded[k] = nil
- end
- end
- end
-
- function huamajiangRoomView:initView()
- --暂时隐藏牌数
- self.ui.Items.ImageView_CardNum:setVisible(false)
-
- -- 初始化玩家层
- self:initPlayerView();
- --加载工具层
- self:initToolView()
- --聊天层
- -- self:initChatView()
- -- 初始化方向
- self:initDirectionView();
- -- 初始化听牌组件
- self:initTingCardView();
- -- 初始化听牌按钮,动态创建的
- self:initTingBtnView();
-
- --定时器
- self.ui.Items.Text_Time:setText(MJFunction.getTimeString())
- if not self.Time then
- self.Time = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function ()
- self.ui.Items.Text_Time:setText(MJFunction.getTimeString())
- end,1.0,false)
- end
-
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(false);
- end
-
- --- huamajiangRoomView:initPlayerView 初始化playerView
- function huamajiangRoomView:initPlayerView()
- if not self.playerView then
- self.playerView = MJRoomPlayerView:new()
- self:addToLayer("game", self.playerView, 6);
- end
- end
-
- --- huamajiangRoomView:initHandCardNodes 初始化手牌
- function huamajiangRoomView:initHandCardNodes ()
- local maxPlayCount = app.room.roomInfo:getMaxPlayerCount();
- if MJDefine.MJRoomPlayerSitConfig[maxPlayCount] then
- for k,v in pairs(MJDefine.MJRoomPlayerSitConfig[maxPlayCount]) do
- if self.playerHandCards[v] then
- self.playerHandCards[v]:removeFromParent();
- end
- self.playerHandCards[v] = MJHandCardView:new(v, self.desktopType);
- self:addToLayer("game", self.playerHandCards[v], v + 1);
- end
- end
- end
- --- huamajiangRoomView:initToolView 初始化工具栏
- function huamajiangRoomView:initToolView()
- if not self.toolView then
- self.toolView = MJRoomToolView:new(self.desktopType)
- self:addToLayer("game", self.toolView, 7);
- end
-
- self.toolView:setFlowVisible(false);
- end
- --- huamajiangRoomView:initDirectionView 初始化中间方向指示器
- function huamajiangRoomView:initDirectionView()
- if not self.direcionView then
- self.direcionView = MJRoomDirection:new(self.desktopType)
- self:addToLayer("background", self.direcionView);
- self.direcionView:setVisible(false)
- end
- end
- --- huamajiangRoomView:initTingCardView 初始化听牌组件
- function huamajiangRoomView:initTingCardView ()
- if not self._tingCardView then
- self._tingCardView = require("mj_huamajiang.luaScript.Views.Components.huamajiangTingCardView"):new();
- self:addToLayer("game", self._tingCardView, 6);
- self._tingCardView:setData(nil);
- self:setTingCardVisible(false);
- end
- end
- --- huamajiangRoomView:initChatView 初始化聊天语音
- function huamajiangRoomView:initChatView()
- -- 添加语音相关的界面
- local headInfos = {}
- for k,v in pairs(self.playerView.allNodes) do
- local pos = cc.pAdd(v.player:getPosition(),cc.p(38,66))
- table.insert(headInfos,{headPos=pos})
- end
-
- local ChatView = require("luaScript.Views.Room.ChatView");
- self.messageView = ChatView:new({
- chatList=MJDefine.MJChatTxt,
- faceList=MJDefine.MJFaceConfig
- }, headInfos, true)
- if self.toolView.ui.Items.Layout_Chat then
- self.toolView.ui.Items.Layout_Chat:addChild(self.messageView)
- else
- self.playerView.ui.Items.Layout_Player:addChild(self.messageView)
- end
-
- self.messageView:setBtnFace(cc.p(1236, 272), "room_menu3_room_btn_kjy.png")
- self.messageView:setBtnVoice(cc.p(1236, 187), "room_menu3_room_btn_yuyin.png")
-
- -- local voiceEnable = loadUserInfo("voiceEnable") or 1
- -- local propEnable = loadUserInfo("propEnable") or 1
- -- self.messageView:setVoiceEnabled(tonumber(voiceEnable)==1)
- -- self.messageView:setPropEnabled(tonumber(propEnable)==1)
- self:onChangeChatEnable()
-
- end
-
- --- huamajiangRoomView:initTingBtnView 初始化听牌按钮
- function huamajiangRoomView:initTingBtnView ()
- local huamajiangTingBtnView = import("mj_huamajiang.luaScript.Views.Components.huamajiangTingBtnView");
- local btnTing = huamajiangTingBtnView:new();
- btnTing:setCallback(handler(self, self.onBtnTingInfoClicked));
- btnTing:setPosition(cc.p(230, 158));
- self.btnTing = btnTing;
- self:addToLayer("game", self.btnTing, 8)
- end
-
- function huamajiangRoomView:doSound()--1 普通话 2 方言
- local bgmType = tonumber(loadUserInfo("huamajiang_bgm")) or 1
- MJSound.PlayGameBGM(bgmType)
-
- local cacheLan = "mj_language"..(MJDefine.GameID or app.gameId)
- local defaultValue = tonumber(loadUserInfo(cacheLan)) or 2
- -- saveUserInfo("mj_language", defaultValue)
- MJSound.setSoundType(defaultValue)
- end
-
- --- huamajiangRoomView:changeGameBg 更换背景
- function huamajiangRoomView:changeGameBg()
- if app.systemSetting.info.viewType == MJDefine.DesktopType.TwoD then --更新2D麻将类型 金色还是绿色
- local value = loadUserInfo("mj_desktop_2d_mjType") --or MJDefine.DesktopType.TwoD
- if value=="" or not value then
- value = MJDefine.DesktopType.TwoD
- saveUserInfo("mj_desktop_2d_mjType", value)
- end
- self.desktopType = value
- else
- self.desktopType = app.systemSetting.info.viewType
- end
- self:loadTextureCache()
-
- local defaultValue = tonumber(loadUserInfo("huamajiang_desktop_background")) or 2
- local bgData = MJDefine.CHANGE_GAME_BG[defaultValue]
- --更换2D桌面
- if self.desktopType==MJDefine.DesktopType.TwoD or self.desktopType==MJDefine.DesktopType.TwoDGold then
- self.ui.Items.ImageView_bg:loadTexture(bgData['2d'])
- else
- self.ui.Items.ImageView_bg:loadTexture(bgData['3d'])
- end
-
- --记录当前的桌布类型(2d/3d)
- self.curDeskType = self.desktopType
- end
-
- function huamajiangRoomView:setCheckDefault()
- MJDefine.isAutomatic = true
- end
-
-
- --- huamajiangRoomView:onClickButtonShot 一键截屏
- function huamajiangRoomView:onClickButtonShot( sender )
- playBtnEffect()
- showScreenShot()
- end
-
- --- huamajiangRoomView:hideClub 隐藏俱乐部
- function huamajiangRoomView:hideClub()
- -- self.ui.Items.Button_Club:setVisible(false)
- if self.clubView and not tolua.isnull(self.clubView) then
- self.clubView:removeFromParent()
- self.clubView=nil
- end
- end
-
- function huamajiangRoomView:loadTextureCache()
- huamajiangRoomView.super.loadTextureCache(self)
- loadSpriteFrameFile("mj_huamajiang/res/zy_fangjian/anim/huamajiang_effect_guangxiao.plist")
- loadSpriteFrameFile("mj_huamajiang/res/zy_fangjian/anim/huamajiang_effect_guafeng.plist")
- loadSpriteFrameFile("mj_huamajiang/res/zy_fangjian/anim/huamajiang_effect_xiayu.plist")
- end
-
- --- huamajiangRoomView:initGameButton 初始化游戏按钮
- function huamajiangRoomView:initGameButton()
- --点击空白
- self.ui.Items.Layout_Touch:registerClick(nil, function ()
- -- 隐藏个人信息
- self.playerView:removePlayerInfoView()
- self.toolView:setMenuVisible(false)
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:hideOperateItem()
- end
-
- self.toolView:hideRule()
- self:setTingCardVisible(false);
-
-
- -- local preload = package.loaded
- -- for k, v in pairs(package.loaded or {}) do
- -- local res1 = string.find( k, "mj.luaScript.Common") or 0
- -- local res3 = string.find( k, "mj_huamajiang.luaScript.Views.3d") or 0
- -- local res4 = string.find( k, "mj_huamajiang.luaScript.Views.2d") or 0
- -- if res1 > 0 or res3 > 0 or res4 > 0 then
- -- package.loaded[k] = nil
- -- end
- -- end
-
- -- -- MJDefine.MJConfig = require("mj_huamajiang.luaScript.Views.2d.MJConfig_2d")
- -- -- MJDefine.MJConfig = require("mj_huamajiang.luaScript.Views.3d.MJConfig_3d")
- -- MJDefine.loadMJConfig("3d")
-
- -- local playerCount = 4
- -- app.room.roomInfo:setMaxPlayerCount(playerCount)
-
- -- self:initHandCardNodes()
-
- -- local cards = {}
- -- for i = 1, 11 do
- -- table.insert(cards, {card = math.random(17, 25)})
- -- end
- -- local groupCards = {
- -- {values = {41, 41, 41}, opType = 0x0004, fromViewId = 10001, showType = 2},
- -- -- {values = {41, 41, 41, 41}, opType = 0x0008, fromViewId = 10001, showType = 3},
- -- -- {values = {41, 41, 41, 41}, opType = 0x0020, fromViewId = 10001, showType = 4},
- -- -- {values = {41, 41, 41, 41}, opType = 0x0010, fromViewId = 10001, showType = 5},
- -- }
-
- -- local outCards = {}
- -- for i = 1, 33 do
- -- table.insert(outCards, {card = 41})
- -- -- table.insert(outCards, {card = math.random(17, 41)})
- -- end
-
- -- local huCards = {}
- -- for i = 1, 60 do
- -- table.insert(huCards, {huCard = 41, huType = 0})
- -- end
-
- -- if playerCount == 2 then
- -- self.playerHandCards[2]:onGetHuCard(huCards, true)
- -- self.playerHandCards[4]:onGetHuCard(huCards, true)
- -- else
- -- for i = 1, playerCount do
- -- -- self.playerHandCards[i]:createGroupCards(groupCards)
- -- -- self.playerHandCards[i]:createHandCards(cards)
- -- -- self.playerHandCards[i]:createOutCards(outCards)
- -- self.playerHandCards[i]:onGetHuCard(huCards, true)
- -- -- self.playerHandCards[i]:createOpenHandCards(cards)
- -- end
- -- end
-
-
- -- -- local node = cc.Node:create()
-
- -- -- local group = require(MJDefine.MJConfig_2d.GROUP_GANG):new({41, 41, 41, 41}, 4, 1)
- -- -- group:setScale(0.7)
- -- -- group:setPosition(cc.p(0, 15))
- -- -- node:addChild(group)
-
- -- -- for i = 1, 11 do
- -- -- local card = require(MJDefine.MJConfig_2d.MAHJONG_CARD):new(41, 4, MJDefine.MJConfig_2d.MJType.Out, i)
- -- -- card:setPositionX((i - 1) * 44 + 140)
- -- -- node:addChild(card)
- -- -- end
- -- -- node:setPosition(cc.p(100, 200))
- -- -- self:addChild(node)
-
- -- self.toolView:setVisible(false)
- end)
-
-
- --隐藏听牌模板
- self.ui.Items.Item_Ting:setVisible(false)
-
- self:setButtonTingInfoVisible(false);
- end
-
- --- huamajiangRoomView:onBankerBaoPai 通知庄家可以爆牌
- -- @param data
- function huamajiangRoomView:onBankerBaoPai(data)
- local function runBankerBaoPai(onEnd)
- local myUserId = app.room:getMyUserId()
- local viewId = app.room:getViewIdByUserId(myUserId)
-
- if data.response.nUserId == myUserId then
- self:showBaoJiao()
- self.playerHandCards[viewId]:setOutCardEnable(false)
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting);
- self.isTing = true;
- self:setButtonTingInfoVisible(true);
- end
-
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runBankerBaoPai)
- end
-
- --- huamajiangRoomView:onBaoPai 广播玩家爆牌
- -- @param data
- function huamajiangRoomView:onBaoPai(data)
- if data.response.isBaoPai == 1 then
- local effect=MJAnimationCompnent.CreateBaoEffect()
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local myUserId = app.room:getMyUserId()
- local userInfo=app.room:getUserInfoByViewId(viewId)
- --爆牌音效
- MJSound.PlayBaoSound(userInfo.sex)
-
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- if myUserId == data.response.nUserId then
- self.playerHandCards[viewId]:lockHandCard()
- -- self.playerHandCards[viewId]:setOutCardEnable(false)
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- self.isTing = true;
- self:setButtonTingInfoVisible(true);
- else
- --self.playerHandCards[viewId]:setOutCardEnable(true)
- end
- self.playerView:playBaoAnim(viewId)
- end
- if app.room:getMyUserId() == data.response.nUserId then
- self:hideBaoJiao()
- if (data.response.isBaoPai == 1 or data.response.isBaoPai == 2) then
- local tingpai = app.room.roomInfo:getGameRuleByKey("tingpai");
- if tingpai > 0 then
- -- self:setButtonTingInfoVisible(true);
- app.room.roomInfo.memberList[data.response.nUserId].nTingStatus = MJDefine.MJTingStatus.Ting;
- end
- end
- end
- end
-
- --- huamajiangRoomView:onGameSendCardResponse 开始发牌
- function huamajiangRoomView:onGameSendCardResponse()
- logD("huamajiangRoomView:onGameSendCardResponse", "开始发牌")
- --发牌的时候清除桌面上的飘
- self.ui.Items.Layout_Effect_luobo:removeAllChildren()
- local function runGameSendCardResponse(onEnd)
- log("2000000000-huamajiangRoomView - runGameSendCardResponse()" )
- self.isShowFanLuoBo = true;
- local myUserId = app.room:getMyUserId()
- for k,v in pairs(app.room.roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:createHandCards(v.handCards)
- self.playerHandCards[viewId]:resetHandCards()
- end
-
- if v.isBaoPai == 1 and myUserId == v.nUserId then
- --self.playerHandCards[viewId]:showBaoPai()
- self:showBaoJiao()
- end
- end
-
- -- local effect=MJAnimationCompnent.CreateGameStart()
- -- self.ui.Items.Layout_Player:addChild(effect,5)
- -- MJSound.PlayStartGame()
-
- MJAnimationCompnent.CreateStartSendCards(self.playerHandCards, function ()
- self.playerHandCards[MJDefine.MyViewId]:refreshLuoBoCards()
- if onEnd then
- onEnd();
- end
- end)
-
- local gameurle = app.room.roomInfo:getGameRuleByKey()
- local count = table.nums(app.room.roomInfo.memberList);
- local totalCards = gameurle == 1 and 144 or 216;
- local specRule = app.room.roomInfo:getGameRuleByKey("specRule");
- local isQuPai = getNumBand(specRule, 0x80);
- if isQuPai > 0 then
- totalCards = totalCards - math.floor(totalCards / 3);
- end
-
- self.direcionView:updateCardNums(totalCards - count * 13 - 4);
-
- self.toolView:showTuoGuan(app.room.roomInfo.hosting==1)
- end
- log("2000000000-huamajiangRoomView - addCallBack(runGameSendCardResponse)" )
- self:addCallBack(runGameSendCardResponse);
- end
-
- function huamajiangRoomView:onUserReadyResponse(response)
- logD("huamajiangRoomView:onUserReadyResponse", "有玩家准备了")
- huamajiangRoomView.super.onUserReadyResponse(self,response)
- local roomInfo = app.room.roomInfo;
- local myUserId = app.room:getMyUserId()
- if response and response.nUserId==myUserId then
- self.playerView:clearBao()
- self.playerView:clearAllPiao()
- roomInfo:setLuoBoCards({});
- -- local roomInfo = app.room.roomInfo
- -- for k,v in pairs(roomInfo.memberList) do
- -- self.ui.Items.Layout_Player:removeChildByTag(HU_EFFECT_TAG)
- -- end
- local totalCards = 144;
- local specRule = app.room.roomInfo:getGameRuleByKey("specRule");
- local isQuPai = getNumBand(specRule, 0x80);
- if isQuPai > 0 then
- totalCards = totalCards - math.floor(totalCards / 3);
- end
- self.direcionView:updateCardNums(totalCards);
- end
-
- self:setButtonTingInfoVisible(false);
- end
-
-
- -- 广播桌子上所有玩家庄家起手操作 这里其实是发牌
- function huamajiangRoomView:onBankerOutCard(data)
-
- --[[ -- 庄家uid
- , defVar("nUserId", VT_Int, 0)
- -- 庄家操作类型
- , defVar("mainOpCode", VT_Short, 0)
- --庄家是否需要出牌0不需要 1:需要
- , defVar("IsShouldOutCard", VT_UChar, 0)--]]
- local function runOnBankerOutCard(onEnd)
- logD("huamajiangRoomView:onBankerOutCard", "玩家抓牌", table.tostring(data.response))
- -- if not data.response.nUserId then
- -- showTooltip("庄家起手操作nUserId is not exist")
- -- end
-
- local nUserId = data.response.nUserId
- local viewId = app.room:getViewIdByUserId(nUserId)
- local card= data.response.card
- local operates=data.response.operates
- local nSeatId=data.response.nSeatId
- local roomInfo = app.room.roomInfo;
-
- -- roomInfo.outCardUserId = data.response.nUserId
-
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:onGetCard(operates,card)
- end
-
- --先清除所有操作按钮
- --self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- self.playerHandCards[MJDefine.MyViewId]:hideOperateItem()
-
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card,true)
-
- if viewId == MJDefine.MyViewId then
- local huCards = roomInfo.memberList[nUserId].huCards or {};
- -- 默认抓牌隐藏听牌按钮
- self:setButtonTingInfoVisible(false);
- if table.nums(huCards) > 0 then
- -- 如果玩家已经胡了,则不隐藏听牌按钮
- self:setButtonTingInfoVisible(true);
-
- --ljx 勾选自动胡则锁手牌
- local specRule = roomInfo:getGameRuleByKey("specRule") or 0;
- if getNumBand(specRule, 0x08) > 0 then
- self.playerHandCards[viewId]:lockHandCard(true);
- end
- end
- if operates and table.nums(operates)>0 then
- self.operates = operates
- else
- self.operates = {}
- end
-
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- local player = roomInfo.memberList[data.response.nUserId]
- if player and player.isBaoPai==1 then
- self.playerHandCards[MJDefine.MyViewId]:lockHandCard()
- end
- end
-
- app.room:dispatchEvent({name = MJDefine.MJEvent.SelectCard})
- app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing})
- -- app.room:dispatchEvent({name = MJDefine.MJEvent.ShowTing})
-
- self:setTingCardVisible(false);
- end
-
-
-
- -- local myUserId = app.room:getMyUserId()
- -- if data.response.nUserId == myUserId then
- -- if self.playerHandCards[MJDefine.MyViewId] then
- -- self.playerHandCards[MJDefine.MyViewId]:pushTing()
- -- end
- -- end
- if type(data.response.nLeaveCardNum) == "number" then
- roomInfo:setLeaveCardNum(data.response.nLeaveCardNum);
- end
- self:updateGameNums()
-
- self.direcionView:updateDirection(nSeatId)
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-huamajiangRoomView - addCallBack(runOnBankerOutCard)")
- self:addCallBack(runOnBankerOutCard);
-
- end
-
- function huamajiangRoomView:onTurnOutCard(data)
- local function runOnTurnOutCard(onEnd)
- logE("MJRoomView:runOnOutCard(), response = ", table.tostring(data.response))
- log("2000000000-MJRoomView - runOnOutCard")
-
- if app.room.roomInfo:getLastOutViewId() ~= MJDefine.MyViewId then
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- end
- -- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- -- local card= data.response.card
- -- if self.playerHandCards[viewId] then
- -- self.playerHandCards[viewId]:createOutCards(card)
- -- end
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-MJRoomView - addCallBack(runOnTurnOutCard)")
- self:addCallBack(runOnTurnOutCard)
- end
-
- --出牌成功
- function huamajiangRoomView:onOutCardSuccess(data)
- logE("huamajiangRoomView:onOutCardSuccess(), response = ", table.tostring(data.response))
- local function runOnOutCardSuccess(onEnd)
- log("2000000000-huamajiangRoomView - runOnOutCardSuccess---------")
-
- -- app.room.roomInfo.outCardUserId = data.response.nUserId
- local roomInfo = app.room.roomInfo;
- local nUserId = data.response.nUserId
- local viewId = app.room:getViewIdByUserId(nUserId)
- local card= data.response.card
- local operates=data.response.operates
- local opType = operates.opType
-
- if operates and table.nums(operates)>0 then
- self.operates = operates
- self:setTingCardVisible(false);
- else
- self.operates = {}
- end
-
- local function callback()
- -- roomInfo:LastOutViewId(nil)
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
- if onEnd then
- onEnd()
- end
- end
- -- self.lastOutCard = card
-
-
- if self.playerHandCards[viewId] then
- --(viewId~=MJDefine.MyViewId or player.isBaoPai == 1) and roomInfo:getLastOutViewId()~=MJDefine.MyViewId
- if viewId==MJDefine.MyViewId then
- local gameInfo = roomInfo:getGameRule();
- local zidonghu = getNumBand(gameInfo.specRule, 0x08) or 0;
- local player = roomInfo.memberList[nUserId]
-
- local function doOutCard(viewId, card, callback)
- self.playerHandCards[viewId]:onOutCard(card,callback)
- --音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- if userInfo then
- MJSound.PlayMJSound(userInfo.sex,card)
- end
- end
-
- if ((player.isBaoPai==1 or player.isBaoPai==2) and roomInfo:getLastOutViewId()~=MJDefine.MyViewId) then
- -- 点击爆牌的时候 前端已经打出牌 要判断上次出牌的人是不是自己 避免重复出牌
- doOutCard(viewId, card, callback)
- elseif (self.playerHandCards[viewId]:isLock() and zidonghu > 0) and roomInfo:getLastOutViewId()~=MJDefine.MyViewId then
- -- 或者牌锁定状态下,后端自动出牌时,前端需要移除手牌
- doOutCard(viewId, card, callback)
- elseif self.needDeleteOutCard and true == self.needDeleteOutCard then
- self.needDeleteOutCard = nil
- uploadLogs("huamajiangduopai")
- doOutCard(viewId, card, callback)
- elseif app.room.roomInfo.hosting == 1 then
- -- 托管状态下
- doOutCard(viewId, card, callback)
- else
- callback();
- end
-
- self.playerHandCards[viewId]:setTing(false)
- if gameInfo.tingpai > 0 then
- self._isOutCardTingCheck = true;
- self.ui:sendMsg(app.room, MJDefine.MJEvent.Ting)
- end
-
- if table.nums(player.huCards) > 0 then
- -- 胡牌后,显示听牌按钮
- self:setButtonTingInfoVisible(true);
- end
-
- -- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- self:setTingCardVisible(false);
- -- self.isTing = true;
- -- self:setButtonTingInfoVisible(true);
- else
- self.playerHandCards[viewId]:onOutCard(card,callback)
- end
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value=card ,viewId=viewId})
- else
- callback()
- end
- roomInfo:setLastOutViewId(viewId);
- end
- log("2000000000-huamajiangRoomView - addCallBack(runOnOutCardSuccess)")
- self:addCallBack(runOnOutCardSuccess)
- end
-
- --已经发送了过操作,此时就算再勾选贴鬼碰,也不会显示操作
- function huamajiangRoomView:onSendGuo()
- --发牌重置,主要用于贴鬼碰/杠
- MJDefine.isSendGuo = false
- self.operates = {}
- end
-
- -- 操作成功
- function huamajiangRoomView:onOperationCodeSuccess(data)
- local function runOnOperationSuccess(onEnd)
- local response = data.response
- local nUserId = response.nUserId
- local opType = response.opType
- local opCard = response.opCard
-
- local bIsOutCard = response.isNeedOutCard > 0
- local fromSeatId = response.fromSeatId
- local cardNum = response.cardNum or 0;
- local viewId = app.room:getViewIdByUserId(nUserId)
- local fromViewId = app.room:getViewIdBySeatId(fromSeatId)
- local opSeatId = app.room:getSeatIdByViewId(viewId)
- local fromUserId = app.room:getUserIdBySeatId(fromSeatId)
- if self.playerHandCards[viewId] then
- --组合一下牌
- local groups={
- self:getChangeGruopDatas({opType=opType, opCard=opCard, cardNum = cardNum, targetSeatId=opSeatId, opUserId=fromUserId})
- }
- --删除手中对应的牌
- local deleteCards
- for k,v in pairs(groups) do
- if v.showType==MJDefine.MJGroupType.Peng then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,2,v.cardNum)
- elseif v.showType==MJDefine.MJGroupType.Chi then
- --TODO:吃的牌删除两张
-
- elseif v.showType==MJDefine.MJGroupType.AnGang
- or v.showType==MJDefine.MJGroupType.MAnGang then
- if v.cardNum <= 4 then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,4,v.cardNum)
- else
- -- 多头杠移除1张手牌
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,1,v.cardNum)
- end
- else
- if opType==MJDefine.MJOperateType.OPREATE_BAGANG then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,1,v.cardNum)
- else
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,3,v.cardNum)
- end
- end
- end
- --删除出去的牌 遍历哪些操作需要删除牌
- for k,v in pairs(MJDefine.MJOperateNeedRemoveCard) do
- if v==opType then
- self.playerHandCards[fromViewId]:removeOutCard(opCard)
- break
- end
- end
-
- if opType==MJDefine.MJOperateType.OPREATE_BAGANG then
- self.playerHandCards[viewId]:buGang(opCard,cardNum)
- else
- self.playerHandCards[viewId]:createGroupCards(groups)--创建显示的牌
- end
-
- self.playerHandCards[viewId]:resetHandCards()
- self.playerHandCards[viewId]:hideOperate()
- self.playerHandCards[viewId]:setOutCardEnable(bIsOutCard)
-
- if self.playerHandCards[viewId]:isLock() then
- self.playerHandCards[viewId]:lockHandCard();
- end
-
- self.direcionView:updateDirection(app.room:getSeatIdByViewId(viewId))
- end
-
- local function guafengxiayuEffect()
- local effect
- if (opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (opType==MJDefine.MJOperateType.OPREATE_BAGANG) or
- (opType==MJDefine.MJOperateType.OPREATE_MINGGANG) then
- effect=MJAnimationCompnent.createGuaFengEffect()
- MJSound.PlayWindSound()
- elseif (opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- effect=MJAnimationCompnent.createXiaYuEffect()
- MJSound.PlayRainSound()
- end
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
-
- if (opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (opType==MJDefine.MJOperateType.OPREATE_BAGANG) or
- (opType==MJDefine.MJOperateType.OPREATE_MINGGANG) or (opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- -- 花麻将直接播放刮风下雨效果,不播放“杠”字效果
- guafengxiayuEffect();
- else
- local effectCallback = function ()
- guafengxiayuEffect();
- end
-
- --播放动画
- local effect=MJAnimationCompnent.CreateOperareEffect(opType, effectCallback)--,onEnd)
- if effect then
- self.ui.Items.Layout_Player:addChild(effect);
- effect:setLocalZOrder(1000);
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion());
- end
- end
- self:showOperateScore(response.optScore);
-
- --音效
- local userInfo=app.room:getUserInfo(nUserId)
- if userInfo then
- MJSound.PlayOperateSound(userInfo.sex,opType)
- end
-
- if viewId == MJDefine.MyViewId then
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- self:setButtonTingInfoVisible(false)
- self.operates={}
- end
-
- --删除等待操作的显示
- if self.waitOperates and #self.waitOperates>0 then
- for k,v in pairs(self.waitOperates) do
- v:removeFromParent()
- end
- self.waitOperates={}
- end
- --[[if viewId == MJDefine.MyViewId and opType==MJDefine.MJOperateType.OPREATE_PENG then
- local cards = {opCard}
- self.playerHandCards[viewId]:cardEnabled(cards, true)
- end--]]
-
- -- 取消操作按钮
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
-
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runOnOperationSuccess)
- end
-
-
- function huamajiangRoomView:test()
- self.playerHandCards={}
-
- self.playerHandCards[MJDefine.MyViewId] = MJHandCardView:new(MJDefine.MyViewId)
-
- -- self:addChild(self.playerHandCards[MJDefine.MyViewId])
- self:addToLayer("game", self.playerHandCards[MJDefine.MyViewId]);
-
- self.playerView = MJRoomPlayerView:new()
- -- self:addChild(self.playerView)
- self:addToLayer("game", self.playerView);
- end
-
- --飘状态停止
- function huamajiangRoomView:stopDirection()
- if not tolua.isnull(self.direcionView) then
- self.direcionView:stopAllActions()
- self.direcionView.ui.Items.ImageView_Dir_Down:setVisible(false)
- self.direcionView.ui.Items.ImageView_Dir_Up:setVisible(false)
- self.direcionView.ui.Items.ImageView_Dir_Left:setVisible(false)
- self.direcionView.ui.Items.ImageView_Dir_Right:setVisible(false)
- self.direcionView.ui.Items.Text_Time:setString(string.format("%02d",0))
- end
- end
-
- function huamajiangRoomView:onGameReconnection()
-
- local function onGameReconnectionCallback(onEnd)
- --更新房间基础数据
- local roomInfo = app.room.roomInfo;
- self:updateRoomBaseData()
-
- if (not isReviewVersion()) and cc.Application:getInstance():getTargetPlatform() ~= 0 then
- self:updateAllGpsInfo()
- end
- -- self:checkGpsDistance(nil,roomInfo:getGameStartCount() == 0)
- -- self:checkMyGpsNeedUpdate();
- self.toolView:updateButton()
-
- --显示离线状态
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(k)
- self.playerView:setPlayerOffLineVisible(v.nOnlineStatus ~= MJDefine.PlayerOnlineStatus.Online, viewId)
- end
-
- if roomInfo:getGameStartCount() > 0 then
- -- 当前局数大于0,处于重连状态
- self:handleGameReconnection();
- else
- -- 游戏未开始,非重连
- self:handleGameNormal();
- end
-
- if onEnd then
- onEnd();
- end
- end
-
- self:addCallBack(onGameReconnectionCallback);
- end
- --[[
- 重连游戏的逻辑处理
- ]]
- function huamajiangRoomView:handleGameReconnection()
- local roomInfo = app.room.roomInfo;
- local myUserId = app.room:getMyUserId();
- local memberStatus = {};
- local dismissUserId = 0;
- local gameStatus = roomInfo:getGameStatus();
- -- 当前局数大于0,子游戏重连
- if self._fastRequestView then
- -- 隐藏快速开局
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
- --隐藏俱乐部
- self:hideClub()
- self.toolView:setFlowVisible(true);
- self.toolView:showTuoGuan(app.room.roomInfo.hosting == 1)
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(k)
- -- local nOffLineState = v.nOnlineStatus
- -- --显示离线
- -- self.playerView:setPlayerOffLineVisible(nOffLineState ~= MJDefine.PlayerOnlineStatus.Online,viewId)
- --发起解散状态的ID
- dismissUserId = (v.nDisbandStatus == 1) and v.nUserId or dismissUserId;
- if v.nDisbandStatus ~= 0 then
- table.insert(memberStatus,{userId = v.nUserId , status = v.nDisbandStatus})
- end
-
- local extInfo = roomInfo.extJson or ""
- if type(extInfo)=='table' and extInfo[tostring(v.nUserId)] then
- local info = extInfo[tostring(v.nUserId)]
- local host = info.hosted or 0--托管状态
- local isTuoGuan = host == 1;
- self.playerView:showTuoGuanByViewId(viewId,isTuoGuan)
- end
- end
- --显示解散界面
- if roomInfo:getIsUserDisbandGame() == 1 and dismissUserId ~= 0 and roomInfo:getIsGameOver() ~= 1 then
- local view = require("luaScript.Views.Room.RoomDismissView"):new(dismissUserId, roomInfo.memberList, roomInfo:getDismissStateTime());
- -- self:addChild(view,1);
- self:addToLayer("popup", view);
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_UPDATE_STATUS, memberStatus = memberStatus});
- end
- --如果一局结束,玩家点了准备,不再显示牌信息
- if MJDefine.GameStatus.GAME_STATUS_ROUND_OVER == gameStatus or MJDefine.GameStatus.GAME_STATUS_GAME_OVER == gameStatus then
- if roomInfo.memberList[myUserId].nPlayerFlag == 1 then --游戏为停止或开始状态
- self:onUserReadyResponse({nUserId = myUserId});
- return
- end
- end
-
- -- 刷新庄家显示
- self:updateBanker()
- -- 初始化玩家手牌节点
- self:initHandCardNodes()
- --初始化方位
- self.direcionView:initDirection(self.desktopType)
- self.direcionView:updateDirection(app.room:getSeatIdByUserId(roomInfo:getNeedOutCardId()));
- self.direcionView:updateCardNums(roomInfo:getLeaveCardNum())
- --显示用户的牌
- for userId,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(userId)
- if self.playerHandCards[viewId] then
- --组合一下牌
- local groups={}
- for k, v in ipairs(v.operates) do
- table.insert(groups, self:getChangeGruopDatas(v));
- end
- self.playerHandCards[viewId]:createGroupCards(groups);
- self.playerHandCards[viewId]:createOutCards(v.outCards);
-
- if table.nums(v.huCards) > 0 and viewId ~= MJDefine.MyViewId then
- self.playerHandCards[viewId]:createOpenHandCards(v.handCards);
- else
- self.playerHandCards[viewId]:createHandCards(v.handCards);
- -- self.playerHandCards[viewId]:moveLastCard()
-
- if v.canBaoPai == 1 and viewId ~= MJDefine.MyViewId and v.nSeatId == roomInfo:getBankSeatId() then
- -- 庄家报牌的情况下,其他玩家看不到出牌,需补一张手牌
- self.playerHandCards[viewId]:createHandCards(0);
- self.playerHandCards[viewId]:moveLastCard();
- end
- end
-
- if v.nPlayerFlag > 1 then
- if viewId == MJDefine.MyViewId then
- -- self.playerHandCards[viewId]:resetHandCards();
- --显示听
- if v.nTingStatus==MJDefine.MJTingStatus.Ting then
- -- self:setChaTingCardViewVisible(true);
- if v.canBaoPai ~= 1 then
- self:setButtonTingInfoVisible(true);
- end
- end
- local operates = roomInfo:getOperates();
- self.operates = (operates and table.nums(operates)>0) and operates or {};
- --local outCardUserId = app.room:getUserIdBySeatId(roomInfo:getNeedOutCardId())
- local bIsOutCard = roomInfo:getIsNeedOutCard() > 0 or false
- if (not bIsOutCard) and v.nTingStatus == MJDefine.MJTingStatus.Ting then
- -- local gameInfo =app.room.roomInfo:getGameRule();
- -- self:setButtonTingInfoVisible(gameInfo.tingpai > 0);
- end
- if v.canBaoPai == 1 then
- local lastOpCard = roomInfo:getLastOpCard();
- if v.nUserId == roomInfo:getOutCardUserId() and lastOpCard > 0 then
- roomInfo:setLastOutViewId(viewId);
- self.playerHandCards[viewId]:runOutCardAction(lastOpCard);
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg,value = lastOpCard,viewId = viewId})
- end
- self:showBaoJiao();
- end
-
- if roomInfo:getGameRuleByKey("piaomode") == 1 then
- -- 只有三人、四人才会有飘,做人数限制是因为快速开局不确定人数,可以选择飘
- __ = v.canPiao <= 0 and self:showPiao(); -- 可以飘玩家显示飘
- end
-
- if table.nums(v.huCards) > 0 then
- -- 已经胡牌的玩家,不能操作手牌
- self.playerHandCards[viewId]:lockHandCard();
- local specRule = roomInfo:getGameRuleByKey("specRule") or 0;
- if getNumBand(specRule, 0x08) > 0 then
- self.playerHandCards[viewId]:lockHandCard(true);
- --ljx 添加重连回来 如果胡牌且勾选了自动胡 不显示过按钮
- app.room.roomInfo.passGuo = true;
- end
- end
-
- if v.nTingStatus==MJDefine.MJTingStatus.Ting or table.nums(v.huCards) > 0 or v.isBaoPai ~= 0 then
- -- 听牌、报叫、胡牌情况下,显示听牌按钮
- -- 此时需重新请求一下听牌数据,否则显示为空
- self.ui:sendMsg(app.room, MJDefine.MJEvent.Ting)
- self.isTing = true;
- self:setButtonTingInfoVisible(true);
- end
- end
-
- --已爆牌玩家不能出牌
- if v.isBaoPai ~= 0 then
- if v.isBaoPai == 1 then-- 报叫
- self.playerView:playBaoAnim(viewId)
- end
- if v.nUserId == myUserId then --自己爆牌
- self.playerHandCards[viewId]:lockHandCard()
- end
- end
- local isHu = table.nums(v.huCards) > 0;
- self.playerView:showHu(viewId, isHu);
- --显示飘状态
- self.playerView:showPiao(viewId,tonumber(v.isPiao) == 1)
- end
-
- if roomInfo:getNeedOutCardId() == userId then
- local lastOpCard = roomInfo:getLastOpCard();
- if userId == myUserId and lastOpCard ~= 0 then
- self.playerHandCards[viewId]:removeHandCard(lastOpCard);
- self.playerHandCards[viewId]:resetHandCards();
- self.playerHandCards[viewId]:createHandCards(lastOpCard);
- end
- self.playerHandCards[viewId]:setOutCardEnable(true);
- end
-
- -- 刷新胡牌
- self.playerHandCards[viewId]:onGetHuCard(v.huCards, true);
- end
-
- local reserve = v.reserve;
- local opList = json.decode(reserve);
-
- local resopnse = {};
- resopnse.nUserId = v.nUserId;
- if opList and table.nums(opList) > 0 then
- resopnse.opType = opList.subOpt;
- self:onWaitOperate({response = resopnse})
- end
- end
- --显示出牌角标
- local lastOutCardViewId = app.room:getViewIdByUserId(roomInfo:getOutCardUserId());
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value = roomInfo:getLastOpCard(), viewId = lastOutCardViewId});
-
- --等待换牌 设置换牌显示
- if gameStatus == MJDefine.GameStatus.GAME_STATUS_WAIT_SWAP_CARDS then
- self.playerHandCards[MJDefine.MyViewId]:initSwapCardTouchEvent()
- self:showSwapCard(true,10)
- self.swapCard.Items.Button_sure:setEnabled(false)
-
- for i, player in pairs(roomInfo.swapCardList) do
- local viewId = app.room:getViewIdByUserId(player.nUserId)
- if player.nUserId == myUserId then
- if player.isSwapCard == 1 and self.swapCard and self.swapCard.Items.ImageView_bg then--操作过换牌
- self.swapCard.Items.ImageView_bg:setVisible(false)
- end
- else
- self:setSwapCardSucc(player.isSwapCard == 1,viewId)
- end
- if player.isSwapCard == 1 then
- self.playerHandCards[viewId]:createSwapCards({0,0,0})
- end
- end
- end
-
- --设置可以出牌的人
- -- local outCardViewId = app.room:getViewIdBySeatId(roomInfo.outCardSeatId)
- -- if outCardViewId then
- -- if (outCardViewId~=MJDefine.MyViewId and roomInfo.lastOpCard==0) or (outCardViewId == MJDefine.MyViewId or roomInfo.isNeedOutCard) then
- -- self.playerHandCards[outCardViewId]:setOutCardEnable(true)
- -- end
- -- end
- --显示听标示
- app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing});
- --如果有操作显示操作按钮
- self.playerHandCards[MJDefine.MyViewId]:showOperate(roomInfo:getOperates(), roomInfo:getLastOpCard());
- --显示结算界面
- if gameStatus == MJDefine.GameStatus.GAME_STATUS_ROUND_OVER or gameStatus == MJDefine.GameStatus.GAME_STATUS_GAME_OVER then
- -- 摊开手牌
- self:showOpenCard()
- -- 显示小局结算
- self:showXiaoJuView();
- end
- self:setBtnSitDownVisible(false)
- end
- --[[
- 游戏未开始时的逻辑处理
- ]]
- function huamajiangRoomView:handleGameNormal()
- local roomInfo = app.room.roomInfo;
- local gameStatus = roomInfo:getGameStatus();
- local gameInfo = roomInfo:getGameRule();
- local myUserId = app.room:getMyUserId();
- if gameStatus and gameStatus < MJDefine.GameStatus.GAME_STATUS_WAIT_BANKER_START then
- --self.toolView:enableHosting(false)
- local quickStartInfo = roomInfo:getQuickStartInfo();
- if quickStartInfo then
- if quickStartInfo.tablefaststate == 1 or quickStartInfo.tablefaststate == true then
- local tmpInfo = {}
- for uid,status in pairs(quickStartInfo.list) do
- table.insert(tmpInfo, {nUserId=tonumber(uid), nStatus = status})
- end
- local response = {}
- response.pList = tmpInfo
- response.timeOut = roomInfo:getQuickStartInfo().time
- self:onBroadcastFaststart({response=response})
- else
- --self.toolView:showFastStart(true)
- end
- else
- if self._fastRequestView then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
- --self.toolView:showFastStart(true)
- end
- elseif gameStatus == MJDefine.GameStatus.GAME_STATUS_ROUND_OVER or gameStatus == MJDefine.GameStatus.GAME_STATUS_GAME_OVER then
- local mySelf = roomInfo.memberList[myUserId];
- if mySelf.nPlayerFlag ~= 1 then
- --显示哪些玩家胡牌
- for i,player in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(player.nUserId)
- --已爆牌玩家
- if player.isBaoPai ~= 0 then
- self.playerView:playBaoAnim(viewId)
- end
- end
- end
- elseif gameStatus == MJDefine.GameStatus.GAME_STATUS_WAIT_PIAO then
- self:stopDirection()
- for i, player in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(player.nUserId)
- if myUserId == player.nUserId then
- if tonumber(player.canPiao) == 1 then -- 操作过飘了
- self.playerView:showPiao(viewId,tonumber(player.isPiao) == 1)
- else
- if gameInfo.piaomode == 1 then--可以飘 还没有飘 显示飘按钮
- self:showPiao()
- end
- end
- else
- self.playerView:showPiao(viewId,tonumber(player.isPiao) == 1)
- end
- if tonumber(player.isPiao) == 1 then
- local effect = MJAnimationCompnent.CreatePiaoEffect()
- if effect then
- self.ui.Items.Layout_Effect_luobo:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- end
- end
- end
-
- function huamajiangRoomView:getChangeGruopDatas(g)
- local opType = g.opType
- local showType = MJDefine.MJOperateToGroupType[g.opType]
- local opCard = g.opCard
- local cardNum = g.cardNum
-
- local fromViewId = nil
- local targetSeatId = g.targetSeatId--操作位置座位号
- local fromUserId = g.opUserId or g.fromUserId --触发操作玩家
- local fromViewId1 = app.room:getViewIdByUserId(fromUserId)
-
- if fromUserId > 0 and targetSeatId then
- fromViewId = app.room:transPos(targetSeatId, app.room:getSeatIdByUserId(fromUserId))
- --判断是否是对面玩家,对面玩家的话要做一次翻转
- local opViewId = app.room:getViewIdBySeatId(targetSeatId)
- if opViewId == 2 then --对面
- if fromViewId == 1 then
- fromViewId = 3
- elseif fromViewId == 3 then
- fromViewId = 1
- end
- end
- --三人玩只有上下家
- if app.room:getMaxPlayerCount() == 3 and fromViewId == 2 then fromViewId = 3 end
- if app.room:getMaxPlayerCount() == 2 and fromViewId ~= 0 then
- fromViewId = showType == MJDefine.MJGroupType.Peng and 2 or 4;
- end
- end
- --组合一下牌
- local group={
- opType = opType,
- showType = showType,
- values = {},
- opCard = opCard,
- cardNum = cardNum,
- fromViewId = fromViewId,
- fromViewId1 = fromViewId1,--真正的来源viewID
- }
- if MJDefine.MJGroupType.Chi==showType then
- elseif MJDefine.MJGroupType.Peng==showType then
- group.values={opCard,opCard,opCard}
- else
- group.values={opCard,opCard,opCard,opCard}
- end
- return group
- end
-
- -- 小局结算
- function huamajiangRoomView:onGameXiaoJuResponse(data)
- local function runGameXiaoJuResponse(onEnd)
- if not tolua.isnull(self.firstTingTipsView) then
- self.firstTingTipsView:killSelf()
- self.firstTingTipsView = nil
- end
- -- 取消操作按钮
- if self.playerHandCards and self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- end
-
- local roomInfo = app.room.roomInfo
- if not tolua.isnull(self.direcionView) then
- self.direcionView:stopAllActions()
- end
- self.operates = {}
- self:setTingCardVisible(false);
- app.room:resetTings()
- app.room:cleanTingStatus()
- --如果是解散直接return
- --[[if roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- if onEnd then
- onEnd()
- end
- return
- end --]]
-
- --所有胡牌的人 考虑抢杠胡的问题
- --[[local viewIds={}
- local failViewId=0
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if v.result>0 then
- table.insert(viewIds,viewId)
- --处理掉huCard, 不加入手牌
- --播放音效
- if viewId==MJDefine.MyViewId then
- --MJSound.PlayWinGame()
- end
- if v.result==MJDefine.MJGameHuType.HU_DIANPAO then
- failViewId = app.room:getViewIdBySeatId(v.dpSeatId)
- end
-
- end
- end]]
- self:showOpenCard()
-
- --被抢杠的人回退补杠
- -- if resultInfo.hutype==MJDefine.MJHuType.QiangGangHu and roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_NORMAL then
- -- self.playerHandCards[failViewId]:retoreBuGang(resultInfo.hucard)
- -- end
-
- local function callback()
- local roomInfo = app.room.roomInfo
-
- local memberList = roomInfo.memberList;
- local hasHandcards = true;
- for k, v in pairs(memberList) do
- if v.handCards and #v.handCards == 0 then
- hasHandcards = false;
- break;
- end
- end
- if not hasHandcards then
- -- 还没发牌就结束游戏,直接返回大厅
- app.room.roomInfo.needJieSuanInfo = 1;
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE});
- return ;
- end
- self:showXiaoJuView()
- if onEnd then
- onEnd()
- end
- self.ui.Items.Layout_Effect_luobo:removeAllChildren()
- end
-
- if roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- local effect=MJAnimationCompnent.CreateLiuJuEffect(callback)
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- MJSound.PlayHuangZhuang()
- else
- local delayTime = 1.5;
- if roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- delayTime = 0;
- end
- runDelay(delayTime, function ()
- callback()
- end)
- end
- end
- self:addCallBack(runGameXiaoJuResponse);
- end
-
- -- 显示小局结算
- function huamajiangRoomView:showXiaoJuView()
- if not tolua.isnull(self.direcionView) then
- self.direcionView:stopAllActions()
- end
-
- self:setTingCardVisible(false);
- if self.xiaojuView then
- self.xiaojuView:removeFromParent()
- end
- local roomInfo = app.room.roomInfo
-
- local memberList = roomInfo.memberList;
- for k, v in pairs(memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId);
- local huCards = v.huCards;
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:onGetHuCard(huCards, true);
- end
-
- --刷新玩家分数
- local nodes = self.playerView.allNodes[viewId]
- nodes.score:setText(tostring(v.nTotalMoney))
- end
-
- self.xiaojuView = MJRoomXiaoJuView:new(self.desktopType)
- self:addToLayer("popup", self.xiaojuView);
- if roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- self.xiaojuView:onClickChaPai()
- end
- app.room:dispatchEvent({name = MJDefine.MJEvent.EVENT_XIAOJU_VIEW_SHOWED});
- end
-
- function huamajiangRoomView:onEventBtnShowFlowViewClicked (event)
- logD("huamajiangRoomView:onButtonFlowClicked");
-
- local data = event.response;
- if not data then
- local roomInfo = app.room.roomInfo;
- data = {};
- local scoreInfo = roomInfo:getScoreInfo();
- local luoboCards = roomInfo:getLuoBoCards();
-
- luoboCards = roomInfo:getLuoBoCardsSummary(luoboCards)
-
- local scoreData = {};
- for k, v in ipairs(scoreInfo) do
- table.insert(scoreData, json.decode(v));
- end
-
- data.detail = scoreData
- data.luoboCards = luoboCards;
- end
-
- local flowView = MJFramework.MJImport("mj_huamajiang.luaScript.Views.Components.huamajiangFlowView"):new(data, self.desktopType);
- if data.isReplay then
- self:addChild(flowView);
- else
- self:addToLayer("popup", flowView);
- end
- end
-
- --- huamajiangRoomView:setChaTingCardViewVisible 显示查听的牌,花麻将弃用
- function huamajiangRoomView:setChaTingCardViewVisible(bVisible,tingCards)
- end
-
- --- huamajiangRoomView:setTingCardViewVisible 显示听牌框,花麻将弃用
- function huamajiangRoomView:setTingCardViewVisible(bVisible,tingCards)
- end
-
- function huamajiangRoomView:onTingCardStatus()
- local myUserId=app.user.loginInfo.uid;
- local memberList=app.room.roomInfo.memberList;
- local player = memberList[myUserId];
- if not player then
- return ;
- end
- local nTingStatus = player.nTingStatus
- if nTingStatus == MJDefine.MJTingStatus.Ting then
- print("---------onTingCardStatus-----------1 "..myUserId)
- if player.isBaoPai == 1 then
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- end
- self.isTing = true;
- self:setButtonTingInfoVisible(true);
- else
- print("---------onTingCardStatus-----------0 "..myUserId)
- self:setButtonTingInfoVisible(false);
- end
- end
-
- function huamajiangRoomView:onTingCardResult(data)
- print("---------听牌结果-------------")
- local tingCards = data.response.tingCards or {};
- self.isTing = table.nums(tingCards) > 0;
- self:setButtonTingInfoVisible(self.isTing);
- self._tingCardView:setData(tingCards);
- end
-
- function huamajiangRoomView:showTing(evet)
- local roomInfo=app.room.roomInfo;
- local selectCard = evet.card;
- if not selectCard or evet.card <= 0 then
- return;
- end
-
- local curTingCards = roomInfo:getTingCardsByCard(selectCard);
- if not self._tingCardView then
- return ;
- end
-
- self._tingCardView:setData(curTingCards);
- self.isTing = table.nums(curTingCards) > 0;
- if self.isTing and (not self:isMySelfHu()) then
- self:setTingCardVisible(true);
- else
- self:setTingCardVisible(false);
- end
- end
-
- function huamajiangRoomView:isMySelfHu()
- local myUserId = app.room:getMyUserId();
- local player = app.room.roomInfo.memberList[myUserId];
- if not player then
- return false;
- end
-
- local huCards = player.huCards or {};
- return table.nums(huCards) > 0;
- end
-
- function huamajiangRoomView:setButtonTingInfoVisible (isVisible)
- if self.btnTing then
- self.btnTing:setVisible(isVisible);
- end
- end
-
- function huamajiangRoomView:setTingCardVisible (isVisible)
- if not self._tingCardView then
- return ;
- end
- self._tingCardView:setVisible(isVisible);
- end
-
- function huamajiangRoomView:pushTing()
- local function runPushTing(onEnd)
- local myUserId = app.room:getMyUserId();
- local player = app.room.roomInfo.memberList[myUserId]
- local huCards = player.huCards;
- if self.playerHandCards[MJDefine.MyViewId] then
- if not (table.nums(huCards) > 0 or player.isBaoPai > 0) then
- -- 已经胡牌、报叫的玩家,不显示听牌箭头
- self.playerHandCards[MJDefine.MyViewId]:pushTing()
- end
- end
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runPushTing);
- end
-
- function huamajiangRoomView:onHuResponse(data)
- local function runHuResponse(onEnd)
- local response = data.response
- --是否一炮多响
- local daPaoHaoShuang = response.huRenShu > 1
- local huPaiIndex = response.huIndex
-
- local function callback()
- self:playHuAni(response)
- if onEnd then
- onEnd()
- end
- end
-
- --删除等待操作的显示
- if self.waitOperates and #self.waitOperates>0 then
- for k,v in pairs(self.waitOperates) do
- v:removeFromParent()
- end
- self.waitOperates={}
- end
-
- local viewId = app.room:getViewIdByUserId(response.nUserId)
- local userInfo=app.room:getUserInfoByViewId(viewId)
- local roomInfo = app.room.roomInfo;
- local isNeedRemoveCard = false
-
- local isPlayHuEffect = false;
- local huInfos = {};
- if response.huType == MJDefine.MJGameHuType.HU_ZIMO then
- isPlayHuEffect = true;
- local huData = {};
- huData.huType = response.huType;
- huData.viewId = viewId;
- huData.userInfo = app.room:getUserInfoByViewId(viewId);
- table.insert(huInfos, huData);
- else
- local ext = roomInfo.memberList[response.nUserId].ext or {};
- local huIndex = roomInfo.memberList[response.nUserId].huIndex;
- if response.isReplay then
- local seat = app.room:getSeatIdByUserId(response.nUserId);
- ext.seat = string.format("%s;", seat);
- huIndex = 1;
- end
-
- local huSeats = string.split(ext.seat, ";");
- if huSeats and huIndex then
- if (#huSeats - 1) == huIndex then -- 因为最后一个是空格,所以要减一
- isNeedRemoveCard = true
- isPlayHuEffect = true;
- for k, v in ipairs(huSeats) do
- if string.len(v) > 0 then
- local seat = tonumber(v);
- local huData = {};
- huData.huType = MJDefine.MJGameHuType.HU_DIANPAO;
- huData.viewId = app.room:getViewIdBySeatId(seat);
- huData.userInfo = app.room:getUserInfoByViewId(huData.viewId);
- table.insert(huInfos, huData);
- end
- end
- end
- end
- end
-
- if isPlayHuEffect then
- for k, v in ipairs(huInfos) do
- --先播放胡牌动画和音效,再显示胡牌顺序
- local effect = MJAnimationCompnent.CreateHuEffect(v.huType)
- if v.huType == MJDefine.MJGameHuType.HU_ZIMO then
- MJSound.PlayOperateSound(v.userInfo.sex,MJDefine.MJOperateType.OPREATE_ZIMOHU)
- else
- MJSound.PlayOperateSound(v.userInfo.sex,MJDefine.MJOperateType.OPREATE_DIANPAOHU)
- end
-
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(HU_EFFECT_TAG)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[v.viewId]:getAnimationPostion())
- end
- self:showOperateScore(response.optScore);
-
- --放炮动画
- if response.huType ~= MJDefine.MJGameHuType.HU_ZIMO then
- local failViewId = app.room:getViewIdByUserId(response.dpId)
- local effect=MJAnimationCompnent.CreateDianPaoEffect()
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[failViewId]:getAnimationPostion())
- end
- end
-
- local huCards = roomInfo.memberList[response.nUserId].huCards;
- local huCard = response.huCard;
- if response.huType==MJDefine.MJGameHuType.HU_DIANPAO then
- local failViewId = app.room:getViewIdByUserId(response.dpId)
- --点炮胡或抢杠胡,胡牌类型都是发 点炮胡
- if response.isQiangGng > 0 then
- -- logD("isQiangGng huCard:"..huCard)
- --抢杠胡
- -- self.playerHandCards[viewId]:onGetCard(nil,huCard)
- self.playerHandCards[viewId]:onGetHuCard({huCard},nil,{yipaoduoxiang = daPaoHaoShuang,huPaiIndex = huPaiIndex});
- --被抢杠的人回退补杠
- if daPaoHaoShuang then
- if huPaiIndex == 1 then
- self.playerHandCards[failViewId]:retoreBuGang(huCard.huCard,1)
- end
- else
- self.playerHandCards[failViewId]:retoreBuGang(huCard.huCard,1)
- end
- -- self.playerHandCards[failViewId]:removeHandCardByNum(huCard, 1);
- self.playerHandCards[failViewId]:resetHandCards();
- -- 自动胡情况下,抢杠会自动出牌,此处需设置被抢杠玩家为上次出牌玩家
- -- 否则会出现多牌情况
- local gameInfo = roomInfo:getGameRule();
- local zidonghu = getNumBand(gameInfo.specRule, 0x08) or 0;
- if zidonghu > 0 then
- roomInfo:setLastOutViewId(failViewId);
- end
- elseif response.isGspHu and response.isGspHu > 0 then--点杠炮事手上已经有杠的牌 不需要再加一张胡的牌
- --将胡的牌收走
- if not self.playerHandCards[viewId]:removeLastHandCard() then
- if isNeedRemoveCard then
- self.playerHandCards[failViewId]:removeOutCard(huCard.huCard);
- end
- end
- self.playerHandCards[viewId]:onGetHuCard({huCard});
- else
- -- self.playerHandCards[viewId]:onGetCard(nil,response.huCard)
- self.playerHandCards[viewId]:onGetHuCard({huCard});
- --将胡的牌收走
- if isNeedRemoveCard then
- self.playerHandCards[failViewId]:removeOutCard(huCard.huCard);
- end
- end
-
- if failViewId==MJDefine.MyViewId and roomInfo:getLastOutViewId() == MJDefine.MyViewId then --修改点炮的人连续二次出牌 不删除牌
- roomInfo:setLastOutViewId(nil);
- end
-
- --此处仅做保留,没有实际意义
- elseif response.huType==MJDefine.MJGameHuType.HU_QIANGGANG then
- local failViewId = app.room:getViewIdByUserId(response.dpId)
- if response.redRealCard > 0 then
- --抢杠胡时,胡牌的人将胡的牌加入手中
- -- self.playerHandCards[viewId]:onGetCard(nil,response.redRealCard)
- self.playerHandCards[viewId]:onGetHuCard({huCard});
- --被抢杠的人回退补杠
- self.playerHandCards[failViewId]:retoreBuGang(response.redRealCard,1)
- end
- end
-
- if response.nUserId == app.room:getMyUserId() then
- if response.huType == MJDefine.MJGameHuType.HU_ZIMO then
- -- 自摸时, 去掉服务端下发的胡的那张牌 add->ljx
- local arg = {
- {card = huCard.huCard}
- }
- self.playerHandCards[viewId]:removeHandCard(arg)
- self.playerHandCards[viewId]:resetHandCards()
-
- self.playerHandCards[viewId]:onGetHuCard({huCard});
- end
- self.playerHandCards[viewId]:setOutCardEnable(false)
- self:setTingCardVisible(false);
- self.playerHandCards[viewId]:setTing(false)
- self.playerHandCards[viewId]:lockHandCard();
-
- local specRule = roomInfo:getGameRuleByKey("specRule") or 0;
- if getNumBand(specRule, 0x08) > 0 then
- app.room.roomInfo.passGuo = true;
- self.playerHandCards[viewId]:lockHandCard(true);
- end
-
- -- 胡牌之后,显示听牌按钮,并拉取新的数据
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- self:setButtonTingInfoVisible(true);
- else
- if response.huType == MJDefine.MJGameHuType.HU_ZIMO then
- -- 自摸且回放时, 去掉服务端下发的胡的那张牌 或者去掉最后一张牌 add->ljx
- if response.isReplay then
- local arg = {
- {card = huCard.huCard}
- }
- self.playerHandCards[viewId]:removeHandCard(arg)
- self.playerHandCards[viewId]:resetHandCards()
- else
- self.playerHandCards[viewId]:removeLastHandCard();
- end
-
- local huCard = huCards[#huCards];
- local tmpCard = {
- huCard = huCard.huCard;
- huType = huCard.huType;
- dpSeatId = huCard.dpSeatId;
- };
- if not response.isReplay then
- tmpCard.huCard = 0;
- end
- self.playerHandCards[viewId]:onGetHuCard({tmpCard});
- end
-
- -- 其他人胡了倒牌
- local handCards = {}
- for k,v in pairs(self.playerHandCards[viewId]:getHandCardNodes() or {}) do
- table.insert(handCards,{card = v.value or v:getValue()})
- end
- -- if response.huType==MJDefine.MJGameHuType.HU_ZIMO then --如果是自摸胡 把最后一张替换为胡的牌
- -- handCards[#handCards] = {card = response.huCard}
- -- end
- self.playerHandCards[viewId]:removeAllHandCards()
- self.playerHandCards[viewId]:createOpenHandCards(handCards)
- -- self.playerHandCards[viewId]:moveLastOpenCard()
- -- self.playerHandCards[viewId]:removeLastHandCard();
- end
-
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
-
- self.playerView:showHu(viewId, true);
-
- callback();
- end
- self:addCallBack(runHuResponse);
- end
-
- function huamajiangRoomView:showOperateScore( optScore )
- if not optScore then
- return ;
- end
- for k, v in ipairs(optScore or {}) do
- v.viewId = app.room:getViewIdByUserId(v.uid);
- end
- self._scoreAnim = MJFramework.MJImport("mj_huamajiang.luaScript.Views.Animation.huamajiangScoreAnimation"):new();
- self._scoreAnim:play(optScore, function ()
- self.playerView:refreshPlayerScore(optScore)
- end);
- self:addToLayer("anim", self._scoreAnim);
- end
-
- function huamajiangRoomView:playHuAni(response)
- -- 花麻将不需要播放胡牌顺序
- -- 需要可以从自贡麻将同步
- end
-
- function huamajiangRoomView:onQiangDuanOperates(data)
- local function runOnQiangDuanOperates(onEnd)
- logD("huamajiangRoomView:runOnQiangDuanOperates")
- local response = data.response
- if response.operates and self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:showOperate(response.operates)
- end
- if onEnd then
- onEnd()
- end
- end
- logD("huamajiangRoomView:onQiangDuanOperates")
- self:addCallBack(runOnQiangDuanOperates)
- end
-
- --游戏消息
- function huamajiangRoomView:bindExtendMessage()
- self:bindEvent(app.room , MJDefine.MJEvent.OutCardTings, handler(self , self.pushTing));
- self:bindEvent(app.room , MJDefine.MJEvent.HuResponse, handler(self , self.onHuResponse))
- self:bindEvent(app.room , MJDefine.MJEvent.BaoPaiResponse, handler(self , self.onBaoPai))
- self:bindEvent(app.room , MJDefine.MJEvent.BankerBaoPai, handler(self , self.onBankerBaoPai))
- self:bindEvent(app.room , MJDefine.MJEvent.SendGuo, handler(self , self.onSendGuo))
-
- self:bindEvent(app.room , MJDefine.MJEvent.QiangDuanOperates, handler(self , self.onQiangDuanOperates))
-
- self:bindEvent(app , MJDefine.MJEvent.ChangeLanguage , handler(self , self.doSound))
-
- self:bindEvent(app.room , MJDefine.MJEvent.StartPiao, handler(self , self.onStartPiao))
- self:bindEvent(app.room , MJDefine.MJEvent.PiaoResponse, handler(self , self.onPiaoResponse))
- self:bindEvent(app.room , MJDefine.MJEvent.FanLuoBoResponse, handler(self , self.onFanLuoBoResponse))
-
- --更换桌布
- self:bindEvent(app, MJDefine.MJEvent.ChangeTableBg , handler(self , self.changeGameBg));
- self:bindEvent(app.room, MJDefine.MJEvent.EVENT_BTN_SHOW_FLOW_VIEW_CLICKED, handler(self, self.onEventBtnShowFlowViewClicked));
-
- self:bindEvent(app , MJDefine.MJEvent.ChangeChatEnable , handler(self , self.onChangeChatEnable))
-
- self:bindEvent(app, "applicationWillEnterForeground", handler(self, self.onApplicationWillEnterForeground ))
- self:bindEvent(app, "applicationDidEnterBackground", handler(self, self.onApplicationDidEnterBackground ))
-
- self:bindEvent(app, MJDefine.MJEvent.ChangeViewType, handler(self, self.onEventChangeViewType ))
- -- 托管
- self:bindEvent(app.room , MJDefine.MJEvent.HostingRequest, handler(self, self.onHostingRequest))
-
- --换三张,服务器会通过0x8206通知换牌
- self:bindEvent(app.room , MJDefine.MJEvent.NoticeSwapCard,handler(self,self.onNoticeSwapCardResponse))
- --换三张失败
- self:bindEvent(app.room , MJDefine.MJEvent.SwapCardErr,handler(self,self.onChangeCardFail))
- --换三张成功
- self:bindEvent(app.room , MJDefine.MJEvent.SwapCardSucc,handler(self,self.onChangeCardSucc))
- --换三张成功后的信息
- self:bindEvent(app.room , MJDefine.MJEvent.SwapCardSuccInfo,handler(self,self.onChangeCardInfo))
-
- --检测是否符合换三张规则
- self:bindEvent(app.room , MJDefine.MJEvent.CheckIsInSwapRule,handler(self , self.onCheckIsInSwapRule))
-
- --内容和0x8106保持统一 广播桌子上所有玩家庄家起手操作
- self:bindEvent(app.room , MJDefine.MJEvent.AfterDingQue,handler(self , self.onAfterDingQue))
- end
-
- function huamajiangRoomView:clean()
- self.playerView:init()
- -- --默认状态
- self:defaultState()
- app.room:resetRoomInfo()
- self:setBtnSitDownVisible(false)
-
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallReadyRequest)
- --
- self._gameoverview = nil
- end
-
- function huamajiangRoomView:updateReady()
- local roomInfo = app.room.roomInfo;
- local nUserId = app.room:getMyUserId()--app.user.loginInfo.uid
- local gameStartCount = roomInfo:getGameStartCount();
- if gameStartCount > 0 then
- self.toolView.ui.Items.Button_Leave:setEnabled(false)
- self:setBtnSitDownVisible(false)
- else
- self.toolView.ui.Items.Button_Leave:setEnabled(true)
- end
- if gameStartCount == 0 and roomInfo:getRoomOwnedUid() ~= nUserId then
- self.toolView.ui.Items.Button_Dismiss:setEnabled(false)
- else
- self.toolView.ui.Items.Button_Dismiss:setEnabled(true)
- end
-
- self:checkCanDismiss()
- end
-
- --- huamajiangRoomView:onGameStartResponse 游戏开始
- function huamajiangRoomView:onGameStartResponse()
- huamajiangRoomView.super.onGameStartResponse(self)
- self._gameoverview = nil
-
- self:changeGameBg();
-
- self.toolView:setFlowVisible(true);
-
- self:playGameStartAnim();
- end
-
- --- huamajiangRoomView:playGameStartAnim 播放整起动画
- function huamajiangRoomView:playGameStartAnim ()
- if self.gameStartAnim then
- self.gameStartAnim = nil;
- end
-
- -- 整起音效
- local userInfo=app.room:getUserInfoByViewId(MJDefine.MyViewId);
- MJSound.PlayGameStartSound(userInfo.sex)
-
- local visibleSize = cc.Director:getInstance():getVisibleSize();
- local GameStartAnim = import("mj_huamajiang.luaScript.Views.Animation.huamajiangGameStartAnimation");
- self.gameStartAnim = GameStartAnim:new();
- self.gameStartAnim:play(nil);
- self:addToLayer("anim", self.gameStartAnim);
- end
-
- -- 大局结算
- function huamajiangRoomView:onGameDaJuResponse(data)
-
- app.club_php:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM})
-
- if self._gameoverview then
- return
- end
-
- runDelay(0.3, function ()
- if app.room.roomInfo.needJieSuanInfo == 1 then--显示总结算
- self:showGameOverResult(data.response)
- else
- --[[local roomInfo=app.room.roomInfo
- --如果是解散直接跳转总结算
- if roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo:getStopFlag() == MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- self:showGameOverResult(data.response)
- end --]]
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE})
- end
- end)
- end
-
- -- 大局结算
- function huamajiangRoomView:showGameOverResult(data)
- if self._gameoverview ~= nil then
- return
- end
- if not tolua.isnull(self.direcionView) then
- self.direcionView:stopAllActions()
- end
- self:resetGame()
- local view=MJRoomDaJuView:new(data)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- self._gameoverview = view
- app.room:dispatchEvent({name = MJDefine.MJEvent.EVENT_DAJU_VIEW_SHOWED});
- self:showGameOverAward()
- end
-
- function huamajiangRoomView:onOtherLogoutResponse(data)
- if (not data or not data.nUserId or not data.nSeatShowId) then
- return
- end
- local function test(onEnd)
- self.playerView:updatePlayerInfo(data.nSeatShowId)
- self:onUserReadyResponse()
- --更新GPS
- -- self:updateAllGpsInfo()
- -- self:checkGpsDistance()
- -- 是否显示邀请好友
- self.toolView:updateButton()
-
- if self._fastRequestView then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
-
- logE("88888-onOtherLogoutResponse onEnd")
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(test)
- end
-
-
- function huamajiangRoomView:resetGame()
- huamajiangRoomView.super.resetGame(self)
- app.room.roomInfo:setLastOutViewId(nil);
- self.ui.Items.Layout_Effect:removeAllChildren()
- self.ui.Items.Layout_Effect_luobo_Lable:removeAllChildren()
- self.ui.Items.Layout_Effect_luobo:removeAllChildren()
- self.playerView:clearBao()
- self.playerView:clearAllPiao()
- self.playerView:clearHu();
-
- self.isTing = false;
- if self._tingCardView then
- self:setTingCardVisible(false);
- end
- end
-
- function huamajiangRoomView:showPiao()
- self:stopDirection()
- local roomInfo=app.room.roomInfo
- local gameInfo= roomInfo:getGameRule();
-
- if not gameInfo.piaomode or tonumber(gameInfo.piaomode)==0 then return end
-
- self:hidePiao()
- local ui=loadUI("mj_huamajiang/res/ui_fangjian/mj_huamajiang_piao.ui")
- self:addToLayer("game", ui);
- self.piaoView = ui
-
- ui.Items.Button_BuPiao:registerClick(function ()
- playBtnEffect()
- self:hidePiao()
- local request = MJMessage.PiaoRequest:new()
- request.isPiao = 0
- self.ui:sendMsg(app.room,MJDefine.MJEvent.PiaoRequest,request)
- end)
-
- ui.Items.Button_Piao:registerClick(function ()
- playBtnEffect()
- self:hidePiao()
- local request = MJMessage.PiaoRequest:new()
- request.isPiao = 1
- self.ui:sendMsg(app.room,MJDefine.MJEvent.PiaoRequest,request)
- end)
-
- end
-
- function huamajiangRoomView:hidePiao()
- if self.piaoView then
- self.piaoView:removeFromParent()
- self.piaoView = nil
- end
- end
-
- --显示飘操作按钮
- function huamajiangRoomView:onStartPiao(response)
- local function runPiao(onEnd)
- logD("huamajiangRoomView:onStartPiao")
- self:showPiao()
- if onEnd then
- onEnd()
- end
- end
- logD("huamajiangRoomView:runPiao")
- self:addCallBack(runPiao)
- end
-
- --飘结果
- function huamajiangRoomView:onPiaoResponse(response)
- local function runonPiaoResponse(onEnd)
-
- logD("huamajiangRoomView:runonPiaoResponse")
- local data = response.response
- local userId = data.nUserId--操作的玩家
- local myUserId = app.room:getMyUserId()
- if myUserId == userId then
- self:hidePiao()
- end
-
- local playersPiaostate = data.playerPiaoState--所有玩家的飘状态
- if playersPiaostate then
- for i,v in pairs(playersPiaostate) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- local userInfo=app.room:getUserInfoByViewId(viewId)
-
- self.playerView:showPiao(viewId,v.piaostate==1)
- if v.piaostate==1 and userId == v.nUserId then
- --飘音效
- MJSound.PlayPiaoSound(userInfo.sex)
- local effect = MJAnimationCompnent.CreatePiaoEffect()
- if effect then
- self.ui.Items.Layout_Effect_luobo:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- end
- else
- local viewId = app.room:getViewIdByUserId(userId)
- self.playerView:showPiao(viewId,data.piaostate==1)
- if data.piaostate and data.piaostate == 1 then
- --飘音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- MJSound.PlayPiaoSound(userInfo.sex)
- local effect = MJAnimationCompnent.CreatePiaoEffect()
- if effect then
- self.ui.Items.Layout_Effect_luobo:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- end
- if onEnd then
- onEnd()
- end
- end
- logD("huamajiangRoomView:runonPiaoResponse--------")
- self:addCallBack(runonPiaoResponse)
- end
-
- function huamajiangRoomView:showBaoJiao()
- self:hideBaoJiao()
- local ui=loadUI("mj_huamajiang/res/ui_fangjian/mj_huamajiang_baojiao.ui")
- self:addToLayer("game", ui, 5);
- self._baojiaoView=ui
-
- ui.Items.Button_Bao:registerClick(function ()
- playBtnEffect()
- self:hideBaoJiao()
- local request = MJMessage.BaoPaiRequest:new()
- request.isBaoPai = 1
- logD(request.isBaoPai,"发送爆:1")
- self.ui:sendMsg(app.room, MJDefine.MJEvent.BaoPaiRequest, request)
- end)
-
- ui.Items.Button_guo:registerClick(function ()
- playBtnEffect()
- self:hideBaoJiao()
- local request = MJMessage.BaoPaiRequest:new()
- request.isBaoPai = 0
- logD(request.isBaoPai,"发送爆:0")
- self.ui:sendMsg(app.room, MJDefine.MJEvent.BaoPaiRequest, request)
- end)
-
- end
-
- function huamajiangRoomView:hideBaoJiao()
- if self._baojiaoView then
- self._baojiaoView:removeFromParent()
- self._baojiaoView=nil
- end
- end
-
- function huamajiangRoomView:onBtnTingInfoClicked( )
- playBtnEffect()
- if self._tingCardView:isVisible() then
- self:setTingCardVisible(false);
- else
- self:setTingCardVisible(true);
- end
- end
-
- function huamajiangRoomView:onFanLuoBoResponse (data)
- local onFanLuoBoCallback = function (onEnd)
- self.playerHandCards[MJDefine.MyViewId]:refreshLuoBoCards()
- if not self.isShowFanLuoBo then
- -- 游戏中,不显示翻牌
- if onEnd then
- onEnd();
- end
- return ;
- end
-
- self.isShowFanLuoBo = false;
-
- logD("huamajiangRoomView:onFanLuoBoResponse");
-
- MJSound.PlayLuoBoSound();
-
- local luoboCards = app.room.roomInfo:getLuoBoCards();
- local luoboCount = table.nums(luoboCards);
-
- if luoboCount <= 0 then
- return ;
- end
-
- if self._luoboView then
- self._luoboView:removeFromParent();
- self._luoboView = nil;
- end
-
- -- local showCards = {};
- -- if luoboCount <= 4 then
- -- showCards = luoboCards;
- -- else
- -- local lastCard = luoboCards[luoboCount]
- -- table.insert(showCards, lastCard);
- -- end
- local showCards = {};
- for i = 1, luoboCount do
- if luoboCards[i] then
- table.insert(showCards, luoboCards[i]);
- end
- end
-
- self._luoboView = MJFramework.MJImport("mj_huamajiang.luaScript.Views.Components.huamajiangFanLuoBoView"):new(self.desktopType);
- self._luoboView:setCards(showCards);
- self:addToLayer("anim", self._luoboView);
-
- if onEnd then
- onEnd();
- end
- end
-
- self:addCallBack(onFanLuoBoCallback);
- end
- -- 等待操作消息
- function huamajiangRoomView:onWaitOperate(data)
- if true then
- -- 花麻将不需要显示“我要碰”、“我要杠”等操作
- return ;
- end
-
- huamajiangRoomView.super.onWaitOperate(self, data);
- --等待操作的UID
- local nUserId = data.response.nUserId
- -- 有操作,则不能操作手牌
- local viewId = app.room:getViewIdByUserId(nUserId);
- if viewId == MJDefine.MyViewId and data.response and data.response.opType > 0 then
- self.playerHandCards[viewId]:setOutCardEnable(false);
- end
- end
-
- function huamajiangRoomView:onApplicationWillEnterForeground ()
- end
-
- function huamajiangRoomView:onApplicationDidEnterBackground( )
- end
-
- function huamajiangRoomView:onEventChangeViewType(data)
-
- MJDefine.MJConfig = MJDefine.loadMJConfig()
-
- self:changeGameBg(true)
-
- self.ui:sendMsg(app.room, MJDefine.MJEvent.GetTableInfo);
- end
- ---
- -- 托管通知
- -- @param data
- -- @return
- --
- function huamajiangRoomView:onHostingRequest( data )
- local response = data.response
- if response.nUserId == app.user.loginInfo.uid then
- if response.status == 1 then --托管状态
- self.toolView:showTuoGuan(true)
- elseif response.status == 0 then--取消托管状态
- self.toolView:showTuoGuan(false)
- end
- end
- local isTuoGuan = response.status == 1;
- local viewId = app.room:getViewIdByUserId(response.nUserId)
- self.playerView:showTuoGuanByViewId(viewId,isTuoGuan)
- end
-
- --设置换牌确定按钮可点击性
- function huamajiangRoomView:onCheckIsInSwapRule(data)
- if not data then return end
- if not self.swapCard then return end
- self.swapCard.Items.Button_sure:setEnabled(data.canCommit)
- end
-
- --显示换三张
- function huamajiangRoomView:showSwapCard(isOpered,time)--是否已经操作过
- self:stopDirection()
- local roomInfo=app.room.roomInfo
- local gameInfo=json.decode(roomInfo.strGameInfo)
-
- if not gameInfo.specRule or (not (getNumBand(gameInfo.specRule, 0x1000)>0) and not (getNumBand(gameInfo.specRule, 0x80000)>0)) then
- return
- end
- isOpered = isOpered or false
-
- self:hideSwapCard()
- local ui=loadUI("mj_huamajiang/res/ui_fangjian/mj_huamajiang_swap_card.ui")
- self.ui.Items.Layout_Player:addChild(ui)
- self.swapCard=ui
- self.swapCard.Items.ImageView_bg:setVisible(isOpered)
- for i=1,4 do--先隐藏全部
- if self.swapCard.Items["Layout_swapCard_"..i] then
- self.swapCard.Items["Layout_swapCard_"..i]:setVisible(false)
- end
- self:setSwapCardSucc(false,i)
- end
- for k,v in pairs(app.room.roomInfo.memberList) do--根据人数显示
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if self.playerHandCards[viewId] then
- if self.swapCard.Items["Layout_swapCard_"..viewId] then
- self.swapCard.Items["Layout_swapCard_"..viewId]:setVisible(true)
- end
- else
- if self.swapCard.Items["Layout_swapCard_"..viewId] then
- self.swapCard.Items["Layout_swapCard_"..viewId]:setVisible(false)
- end
- end
- end
-
- --确定换牌按钮
- ui.Items.Button_sure:registerClick(function ()
- playBtnEffect()
- self.swapCard.Items.ImageView_bg:setVisible(false)
- --请求换牌
- local cards = self.playerHandCards[MJDefine.MyViewId]:getSelectedCards()
- app.room:requestSwapCards(cards)
- --[[local request = MJMessage.PiaoRequest:new()
- request.isPiao = 0
- self.ui:sendMsg(app.room,MJDefine.MJEvent.PiaoRequest,request)--]]
- end)
-
- local swapcolourcard = getNumBand(gameInfo.specRule, 0x80000)
- local Text_tip1 = swapcolourcard > 0 and "选择以下三张 底牌" or "选择以下三张 底牌"
- local Text_tip2 = swapcolourcard > 0 and "任意花色" or "同花色"
- self.swapCard.Items.Text_tip1:setText(Text_tip1)
- self.swapCard.Items.Text_tip2:setText(Text_tip2)
-
- self.swapCard.Items.Button_sure:setText("确认("..time..")")
- if self.SwapTime then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.SwapTime)
- end
- self.SwapTime = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function ()
- time = time - 1
- if time < 0 then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.SwapTime)
- return
- end
- self.swapCard.Items.Button_sure:setText("确认("..time..")")
- end,1.0,false)
- end
- --隐藏换三张
- function huamajiangRoomView:hideSwapCard()
- if self.swapCard then
- if self.SwapTime then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.SwapTime)
- end
- self.swapCard:removeFromParent()
- self.swapCard=nil
- end
- end
-
- --换三张,服务器会通过0x8206通知换牌
- function huamajiangRoomView:onNoticeSwapCardResponse(response)
- local function runNoticeSwapCard(onEnd)
- logD("huamajiangRoomView:onNoticeSwapCardResponse")
- local data = response.response
- self:showSwapCard(true,data.time)
- self.playerHandCards[MJDefine.MyViewId]:initSwapCardTouchEvent()
- --弹出推荐牌
- self.playerHandCards[MJDefine.MyViewId]:resetHandCards()
- self.playerHandCards[MJDefine.MyViewId]:selectCardsByCards(data.swapCards)
- self.swapCard.Items.Button_sure:setEnabled(true)
-
- if onEnd then
- onEnd()
- end
- end
- logD("huamajiangRoomView:runNoticeSwapCard")
- self:addCallBack(runNoticeSwapCard)
- end
- --换三张失败
- function huamajiangRoomView:onChangeCardFail(response)
- local function runChangeCardFail(onEnd)
- logD("huamajiangRoomView:onChangeCardFail")
- self:hideSwapCard()
-
- local data = response.response
- if data.time > 0 then
- self:showSwapCard(true,data.time)
- self.swapCard.Items.Button_sure:setEnabled(false)
- end
-
- self.playerHandCards[MJDefine.MyViewId]:resetHandCards()
-
- if onEnd then
- onEnd()
- end
- end
- logD("huamajiangRoomView:runChangeCardFail")
- self:addCallBack(runChangeCardFail)
- end
- --换三张成功
- function huamajiangRoomView:onChangeCardSucc(response)
- local function runChangeCardSucc(onEnd)
- logD("huamajiangRoomView:onChangeCardSucc换三张成功1")
- local data = response.response
- local userId = data.nUserId--操作的玩家
- local viewId = app.room:getViewIdByUserId(userId)
- local swapCards = data.swapCards--换出去的牌
- if viewId == MJDefine.MyViewId then
- if self.swapCard and self.swapCard.Items.ImageView_bg then
- self.swapCard.Items.ImageView_bg:setVisible(false)
- end
-
- local tmpCards = {}
- for i=1,3 do
- table.insert(tmpCards,{card = swapCards[i].card})
- end
- self.playerHandCards[MJDefine.MyViewId]:removeHandCard(tmpCards)
- self.playerHandCards[viewId]:resetHandCards()
- else
- self:setSwapCardSucc(true,viewId)
- local tmpCards = {}
- for i=1,3 do
- table.insert(tmpCards,{card = 0})
- end
- self.playerHandCards[viewId]:removeHandCard(tmpCards)
- self.playerHandCards[viewId]:resetHandCards()
- end
- self.playerHandCards[viewId]:createSwapCards({0,0,0})
-
- if onEnd then
- onEnd()
- end
- end
- logD("huamajiangRoomView:runChangeCardSucc--------")
- self:addCallBack(runChangeCardSucc)
- end
- --换三张成功后的信息
- function huamajiangRoomView:onChangeCardInfo(response)
- local function runChangeCardInfo(onEnd)
- logD("huamajiangRoomView:onChangeCardInfo")
- self:hideSwapCard()
- local data = response.response
- self:showSwapDirection(data.swapType)
- for k,v in pairs(data.swapCards) do
- for i=1,4 do
- if i == MJDefine.MyViewId and self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:onGetCard(nil,tonumber(v.card),true)
- elseif self.playerHandCards[i] then
- self.playerHandCards[i]:onGetCard(nil,0,true)
- end
- end
- end
- self.playerHandCards[MJDefine.MyViewId]:resetHandCards()
-
- --删去桌面的显示的三张换牌
- for i=1,4 do
- if self.playerHandCards[i] then
- self.playerHandCards[i]:deleteSwapCards()
- end
- end
-
- self.playerHandCards[MJDefine.MyViewId]:removeTouchEventOnly()
- for i,v in pairs(data.swapCards) do
- local handCards = self.playerHandCards[MJDefine.MyViewId]:getHandCardNodes() or {}
- for j,mjCard in pairs(handCards) do
- if mjCard:getValue() == tonumber(v.card) and mjCard:getSelected() ~= MJDefine.MJStatus.Select then
- --local mjCard = self.playerHandCards[MJDefine.MyViewId]:getMjByValue(tonumber(v.card))
- --if mjCard and mjCard:getSelected() ~= MJDefine.MJStatus.Select then
- mjCard:setSelected(MJDefine.MJStatus.Select)
- mjCard:recordPostion()
- local initPos = mjCard:getPosition()
- local toPos = cc.p(initPos.x, initPos.y + 25)
- mjCard:setPosition(toPos)
- mjCard:runDeSelectAnimationWithTime(1.0)
- mjCard:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function()
- mjCard:setSelected(MJDefine.MJStatus.Normal)
- end)))
- break
- end
- --end
- end
- end
- --[[self:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function()
- self.playerHandCards[MJDefine.MyViewId]:initTouchEvent()
- end)))--]]
-
- if onEnd then
- onEnd()
- end
- end
- logD("huamajiangRoomView:runChangeCardInfo--------")
- self:addCallBack(runChangeCardInfo)
- end
-
- --设置换牌成功 isSwaped:true显示有勾的,false显示换牌中
- function huamajiangRoomView:setSwapCardSucc(isSwaped,viewId)
- isSwaped = isSwaped or false
- if not self.swapCard or tolua.isnull(self.swapCard) then
- return
- end
- if self.swapCard.Items["ImageView_swaping_"..viewId] then
- self.swapCard.Items["ImageView_swaping_"..viewId]:setVisible(not isSwaped)
- end
- if self.swapCard.Items["ImageView_swaped_"..viewId] then
- self.swapCard.Items["ImageView_swaped_"..viewId]:setVisible(false)--isSwaped 不显示选牌中了
- end
- end
-
- --换牌方式 1顺时针 2对家换牌 3逆时针
- function huamajiangRoomView:showSwapDirection(dir)
- if not dir then return end
- self:hideSwapDirection()
- local ui=loadUI("mj_huamajiang/res/ui_fangjian/mj_huamajiang_swap_direction.ui")
- self.ui.Items.Layout_Player:addChild(ui)
- self.swapDirection=ui
- self.swapDirection.Items.Layout_ShunShiZhen:setVisible(dir == 1)
- self.swapDirection.Items.Layout_NiShiZhen:setVisible(dir == 3)
- self.swapDirection.Items.Layout_DuiJia:setVisible(dir == 2)
- self.swapDirection.Items.ImageView_s:playClip("shunshizhen")
- self.swapDirection.Items.ImageView_n:playClip("nishizhen")
- self.swapDirection.Items.Layout_DuiJia:playClip("duijia")
- self.swapDirection:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function ()
- self:hideSwapDirection()
- end)))
- end
-
- function huamajiangRoomView:hideSwapDirection()
- if self.swapDirection then
- self.swapDirection:removeFromParent()
- self.swapDirection = nil
- end
- end
-
- function huamajiangRoomView:onAfterDingQue(data)
- local function runOnAfterDingQue(onEnd)
- logE("huamajiangRoomView onAfterDingQue 没定缺就是换牌流程完毕后:"..table.tostring(data.response))
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local card= data.response.card
- local operates=data.response.operates
- local nSeatId=data.response.nSeatId
- self.playerHandCards[MJDefine.MyViewId]:hideOperateItem()
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card,true)
-
- if viewId == MJDefine.MyViewId then
- --self.ui.Items.Button_Ting_Info:setVisible(false)
- self:setButtonTingInfoVisible(false)
- if operates and table.nums(operates)>0 then
- self.operates = operates
- local isCanHu = false
- for k,v in pairs(operates.Datas) do
- if (v.opType == MJDefine.MJOperateType.OPREATE_DIANPAOHU) or (v.opType == MJDefine.MJOperateType.OPREATE_ZIMOHU) then
- isCanHu = true
- break
- end
- end
- if isCanHu == true then
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(false)
- else
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- end
- else
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- self.operates = {}
- end
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- end
- app.room:dispatchEvent({name = MJDefine.MJEvent.SelectCard})
- app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing})
- end
- self:updateGameNums()
- self.direcionView:updateDirection(nSeatId)
- self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
- self.playerHandCards[MJDefine.MyViewId]:initTouchEvent()
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runOnAfterDingQue)
- end
-
- return huamajiangRoomView
|