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 luzhouguiRoomView = class("luzhouguiRoomView", MJRoomView) local zhongNiaoTime=1.33 local HU_EFFECT_TAG = 100 function luzhouguiRoomView:ctor() luzhouguiRoomView.super.ctor(self) self.operates = {} MJDefine.MJConfig = MJDefine.loadMJConfig(self.desktopType) end function luzhouguiRoomView:loadUi() local ui = loadUI("mj_luzhougui/res/ui_fangjian/mj_luzhou_roomView.ui") self.ui = ui self:addChild(ui) end function luzhouguiRoomView:onEnter() luzhouguiRoomView.super.onEnter(self) self.ui.Items.Layout_WanFa:setVisible(false) if app.room.roomInfo.nGameStartCount > 0 then self.ui.Items.Layout_WanFa:setVisible(true) end local x= self.ui.Items.Layout_WanFa:getPositionX() local y= self.ui.Items.Layout_WanFa:getPositionY() if self.desktopType==MJDefine.DesktopType.TwoD then --self.ui.Items.Layout_WanFa:setPositionY(y-20) end --获取是否贴鬼杠和是否自动对齐 self:setCheckDefault() self:doSound() end function luzhouguiRoomView:onExit() luzhouguiRoomView.super.onExit(self) end function luzhouguiRoomView:initView () luzhouguiRoomView.super.initView(self); if app.room.roomInfo.isEapCreate == 1 then return; end self:initRuleView(); end --- -- 初始化规则弹框 -- @return -- function luzhouguiRoomView:initRuleView () if self._ruleView then -- 已经创建过了 return ; end local RuleViewClass = require("mj.luaScript.Views.Room.MJRuleViewVertical"); local ruleView = RuleViewClass:new(); self:addChild(ruleView); local roomInfo = app.room.roomInfo or {}; local ruleList = MJWanFa.getWanFaInfoTab(roomInfo.strGameInfo, roomInfo.nTotalGameNum) ruleView:setRuleList(ruleList or {}); ruleView:setBtnRuleOffset(60, nil); self._ruleView = ruleView; end function luzhouguiRoomView:doSound()--1 普通话 2 方言 local cacheLan = "mj_language"..(MJDefine.GameID or app.gameId) local defaultValue = tonumber(loadUserInfo(cacheLan)) or 1 -- saveUserInfo("mj_language", defaultValue) MJSound.setSoundType(defaultValue) end function luzhouguiRoomView:setCheckDefault() local tiegui = 1--tonumber(loadUserInfo("luzhou_mj_tiegui")) or 0 saveUserInfo("luzhou_mj_tiegui", tiegui) if tiegui == 1 then self.ui.Items.CheckBox_TieGui:setSelectedState(true) MJDefine.isTieGui = true else self.ui.Items.CheckBox_TieGui:setSelectedState(false) MJDefine.isTieGui = false end local automatic = 1--tonumber(loadUserInfo("luzhou_mj_automatic")) or 1 saveUserInfo("luzhou_mj_automatic", automatic) if automatic == 1 then self.ui.Items.CheckBox_Automatic:setSelectedState(true) MJDefine.isAutomatic = true else self.ui.Items.CheckBox_Automatic:setSelectedState(false) MJDefine.isAutomatic = false end end -- 一键截屏 function luzhouguiRoomView:onClickButtonShot( sender ) playBtnEffect() showScreenShot() end --隐藏俱乐部 function luzhouguiRoomView: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 luzhouguiRoomView:defaultState() --队列初始化 self.callbackQueue = {} self.callbackRunning = false self.playerView:setOffLineVisible(false) self.playerView:setPlayerVisible(false) if self.waitOperates and #self.waitOperates>0 then for k,v in pairs(self.waitOperates) do v:removeFromParent() end end self.waitOperates = {} self:resetGame() end function luzhouguiRoomView:loadTextureCache() luzhouguiRoomView.super.loadTextureCache(self) -- local defaultValue = tonumber(loadUserInfo("luzhou_mj_majhong")) or 1 loadSpriteFrameFile("mj_luzhougui/res/zy_fangjian/luzhou_operateEffect.plist") end function luzhouguiRoomView: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.ui.Items.Layout_Rule:setVisible(false) -- self.ui.Items.Button_Rule:setVisible(true) end) self.ui.Items.CheckBox_TieGui:addEventListener(handler(self , self.onClickTieGui)) self.ui.Items.CheckBox_Automatic:addEventListener(handler(self , self.onClickAutomatic)) --隐藏听牌模板 self.ui.Items.Item_Ting:setVisible(false) -- self.ui.Items.Button_Rule:registerClick(function() -- self.ui.Items.Layout_Rule:setVisible(true) -- self.ui.Items.Button_Rule:setVisible(false) -- end) -- self.ui.Items.Layout_Rule:setVisible(false) -- self.ui.Items.Layout_Ting_Tip_Card_Panel:setLocalZOrder(100) -- self:setTingCardViewVisible(true) end function luzhouguiRoomView:initGpsComponent() if cc.Application:getInstance():getTargetPlatform() == 0 or app.room.roomInfo.isEapCreate == 1 then self.ui.Items.Button_GPS:setVisible(false) return end local versionCode = getAppVersionCode() versionCode = tonumber(versionCode) or 0 logD("luzhouguiRoomView:initGpsComponent() versionCode = ", versionCode) logD("luzhouguiRoomView:initGpsComponent() isReviewVersion = ", isReviewVersion()==true and 1 or 0) self.singleComponent = import("luaScript.Views.Room.RoomSinglePowerComponent"):new(self.ui.Items.ImageView_Single,self.ui.Items.LoadingBar_Power) if isReviewVersion() then -- or versionCode < 110 self.ui.Items.Button_GPS:setVisible(false) return end local function exitRoomCallback() local isGameStart = app.room.roomInfo.nGameStartCount > 0 if isGameStart then app.room:requestDismissRoom(1) else self.ui:sendMsg(app.room, MJDefine.MJEvent.CallLeaveRequest) end end self.gpsComponent = import("luaScript.Views.Room.RoomGpsComponentView"):new(4,self.ui.Items.Button_GPS,exitRoomCallback,exitRoomCallback) self:addChild(self.gpsComponent) -- GPS 按钮 self.ui.Items.Button_GPS:registerClick(handler(self, self.showGpsView)) end function luzhouguiRoomView:onTieGuiAndAutomatic(event) self.ui.Items.CheckBox_TieGui:setTouchEnabled(event.able) self.ui.Items.CheckBox_Automatic:setTouchEnabled(event.able) end --通知庄家可以爆牌 function luzhouguiRoomView:onBankerBaoPai(data) local function runBankerBaoPai(onEnd) local myUserId = app.room:getMyUserId() local viewId = app.room:getViewIdByUserId(myUserId) if data.response.nUserId == myUserId then self.playerHandCards[viewId]:showBaoPai() self.playerHandCards[viewId]:setOutCardEnable(false) end if onEnd then onEnd() end end self:addCallBack(runBankerBaoPai) end --广播玩家爆牌 function luzhouguiRoomView:onBaoPai(data) --local function runBaoPaiResponse(onEnd) 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(true) self.playerHandCards[viewId]:setOutCardEnable(false) else --self.playerHandCards[viewId]:setOutCardEnable(true) end self.playerView:playBaoAnim(viewId) end --end --self:addCallBack(runBaoPaiResponse); end function luzhouguiRoomView:onGameSendCardResponse() local function runGameSendCardResponse(onEnd) log("2000000000-luzhouguiRoomView - runGameSendCardResponse()" ) --走过重连标志值为false self.isRunGameReconnection = false 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() end end -- local effect=MJAnimationCompnent.CreateGameStart() -- self.ui.Items.Layout_Player:addChild(effect,5) -- MJSound.PlayStartGame() local function callback() local viewId = app.room:getViewIdByUserId(myUserId) if self.playerHandCards[viewId] then self.playerHandCards[viewId]:resetHandCardsPosAndOpacity() end if onEnd then onEnd() end end MJAnimationCompnent.CreateStartSendCards(self.playerHandCards,callback) self.toolView:showTuoGuan(app.room:getMeIsHosting()) -- if onEnd then -- onEnd() -- end end log("2000000000-luzhouguiRoomView - addCallBack(runGameSendCardResponse)" ) self.playerView:clearBao()--发牌了清理一次爆动画 self:addCallBack(runGameSendCardResponse); end function luzhouguiRoomView:onUserReadyResponse(response) luzhouguiRoomView.super.onUserReadyResponse(self,response) local myUserId = app.room:getMyUserId() if response and response.nUserId==myUserId then self.playerView:clearBao() -- local roomInfo = app.room.roomInfo -- for k,v in pairs(roomInfo.memberList) do -- self.ui.Items.Layout_Player:removeChildByTag(HU_EFFECT_TAG) -- end end end -- 广播桌子上所有玩家庄家起手操作 function luzhouguiRoomView:onBankerOutCard(data) --[[ -- 庄家uid , defVar("nUserId", VT_Int, 0) -- 庄家操作类型 , defVar("mainOpCode", VT_Short, 0) --庄家是否需要出牌0不需要 1:需要 , defVar("IsShouldOutCard", VT_UChar, 0)--]] local function runOnBankerOutCard(onEnd) logE("luzhouguiRoomView onBankerOutCard :"..table.tostring(data.response)) -- if not data.response.nUserId then -- showTooltip("庄家起手操作nUserId is not exist") -- end self.ui.Items.Layout_WanFa:setVisible(true) local viewId = app.room:getViewIdByUserId(data.response.nUserId) local card= data.response.card local operates=data.response.operates local nSeatId=data.response.nSeatId -- app.room.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 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 = app.room.roomInfo.memberList[data.response.nUserId] if player and player.isBaoPai==1 then self.playerHandCards[MJDefine.MyViewId]:lockHandCard(true) end end app.room:dispatchEvent({name = MJDefine.MJEvent.SelectCard}) app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing}) -- app.room:dispatchEvent({name = MJDefine.MJEvent.ShowTing}) --杠后抓到牌后,重新锁定一下红中牌,解决摸上来的牌也是红中时不锁住bug if self.isOutHongZhong then self.playerHandCards[MJDefine.MyViewId]:lockHongZhong(self.isOutHongZhong == 1) self.isOutHongZhong = nil end 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 self:updateGameNums() self.direcionView:updateDirection(nSeatId) if onEnd then onEnd() end end log("2000000000-luzhouguiRoomView - addCallBack(runOnBankerOutCard)") self:addCallBack(runOnBankerOutCard); end function luzhouguiRoomView:onTurnOutCard(data) local function runOnTurnOutCard(onEnd) logE("MJRoomView:runOnOutCard(), response = ", table.tostring(data.response)) log("2000000000-MJRoomView - runOnOutCard") if app.room.roomInfo.lastOutViewId~=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 luzhouguiRoomView:onOutCardSuccess(data) logE("luzhouguiRoomView:onOutCardSuccess(), response = ", table.tostring(data.response)) --[[ -- 出牌用户id , defVar("nOutCardUserId", VT_Int, -1) -- 出的牌 , defVar("byOutCard", VT_UChar, -1) -- 可以的操作ma , defVar("mainOpCode", VT_Short, -1) -- 玩家操作 , defVar("operations", VT_Vector(ChuPaiPlayerOperation), {})--]] local function runOnOutCardSuccess(onEnd) log("2000000000-luzhouguiRoomView - runOnOutCardSuccess---------") -- app.room.roomInfo.outCardUserId = data.response.nUserId local viewId = app.room:getViewIdByUserId(data.response.nUserId) local card= data.response.card local operates=data.response.operates local typr = operates.opType if operates and table.nums(operates)>0 then self.operates = operates else self.operates = {} end local function callback() -- app.room.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 app.room.roomInfo.lastOutViewId~=MJDefine.MyViewId if viewId==MJDefine.MyViewId then local player = app.room.roomInfo.memberList[data.response.nUserId] self.playerHandCards[viewId]:setTing(false) local curHandCards = self.playerHandCards[viewId]:getHandCardsNum() or 0 if player.isBaoPai==1 and app.room.roomInfo.lastOutViewId~=MJDefine.MyViewId then --点击爆牌的时候 前端已经打出牌 要判断上次出牌的人是不是自己 避免重复出牌 self.playerHandCards[viewId]:onOutCard(card,callback) elseif self.needDeleteOutCard and true == self.needDeleteOutCard then self.needDeleteOutCard = nil uploadLogs("mjduopai") self.playerHandCards[viewId]:onOutCard(card,callback) elseif app.room:getMeIsHosting() then -- 托管 self.playerHandCards[viewId]:onOutCard(card,callback) elseif self.isRunGameReconnection and true ==self.isRunGameReconnection and curHandCards%3 == 2 then--重连后,手牌是可以出牌的,则删除一张牌 self.playerHandCards[viewId]:onOutCard(card,callback) else callback() self.playerHandCards[MJDefine.MyViewId]:lockHongZhong(false) end self.isRunGameReconnection = false else self.playerHandCards[viewId]:onOutCard(card,callback) end app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value=card ,viewId=viewId}) else callback() end app.room.roomInfo.lastOutViewId = viewId end log("2000000000-luzhouguiRoomView - addCallBack(runOnOutCardSuccess)") self:addCallBack(runOnOutCardSuccess) end --已经发送了过操作,此时就算再勾选贴鬼碰,也不会显示操作 function luzhouguiRoomView:onSendGuo() --发牌重置,主要用于贴鬼碰/杠 MJDefine.isSendGuo = false self.operates = {} end -- 操作成功 function luzhouguiRoomView: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 redNum = response.redNum 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, redNum = redNum, 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.redNum) elseif v.showType==MJDefine.MJGroupType.Chi then --TODO:吃的牌删除两张 elseif v.showType==MJDefine.MJGroupType.AnGang or v.showType==MJDefine.MJGroupType.MAnGang then self.playerHandCards[viewId]:removeHandCardByNum(opCard,4,v.redNum) else if opType==MJDefine.MJOperateType.OPREATE_BAGANG then self.playerHandCards[viewId]:removeHandCardByNum(opCard,1,v.redNum) else self.playerHandCards[viewId]:removeHandCardByNum(opCard,3,v.redNum) 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,redNum) else self.playerHandCards[viewId]:createGroupCards(groups)--创建显示的牌 end self.playerHandCards[viewId]:resetHandCards() self.playerHandCards[viewId]:hideOperate() self.playerHandCards[viewId]:setOutCardEnable(bIsOutCard) self.direcionView:updateDirection(app.room:getSeatIdByViewId(viewId)) end --播放动画 local effect=MJAnimationCompnent.CreateOperareEffect(opType)--,onEnd) if effect then self.ui.Items.Layout_Player:addChild(effect) effect:setLocalZOrder(1000) effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion()) -- else -- if onEnd then -- onEnd() -- end end --音效 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:setTingCardViewVisible(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 luzhouguiRoomView:test() self.playerHandCards={} self.playerHandCards[MJDefine.MyViewId] = MJHandCardView:new(MJDefine.MyViewId) self:addChild(self.playerHandCards[MJDefine.MyViewId]) self.playerView = MJRoomPlayerView:new() self:addChild(self.playerView) end function luzhouguiRoomView:onClickTieGui() if self.ui.Items.CheckBox_TieGui:getSelectedState() == true then self.ui.Items.CheckBox_TieGui:setSelectedState(true) saveUserInfo("luzhou_mj_tiegui", 1) MJDefine.isTieGui = true if self.playerHandCards[MJDefine.MyViewId] then self.playerHandCards[MJDefine.MyViewId]:showOperate(self.operates,nil,self.playerHandCards[MJDefine.MyViewId]:isCanOutCard()) end else self.ui.Items.CheckBox_TieGui:setSelectedState(false) saveUserInfo("luzhou_mj_tiegui", 0) MJDefine.isTieGui = false if self.playerHandCards[MJDefine.MyViewId] then self.playerHandCards[MJDefine.MyViewId]:showOperate(self.operates,nil,self.playerHandCards[MJDefine.MyViewId]:isCanOutCard()) end end end function luzhouguiRoomView:onClickAutomatic() if self.ui.Items.CheckBox_Automatic:getSelectedState() == true then self.ui.Items.CheckBox_Automatic:setSelectedState(true) MJDefine.isAutomatic = true saveUserInfo("luzhou_mj_automatic", 1) local myUserId = app.room:getMyUserId() local myViewId = app.room:getViewIdByUserId(myUserId) if self.playerHandCards[myViewId] then self.playerHandCards[myViewId]:resetHandCards() end else self.ui.Items.CheckBox_Automatic:setSelectedState(false) MJDefine.isAutomatic = false saveUserInfo("luzhou_mj_automatic", 0) end end function luzhouguiRoomView:onGameReconnection() luzhouguiRoomView.super.onGameReconnection(self) self.isRunGameReconnection = true local roomInfo = app.room.roomInfo self.ui.Items.Layout_WanFa:setVisible(true) local myUserId = app.room:getMyUserId() local showBaoPaiOp = false if roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_ROUND_OVER or roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_GAME_OVER 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 local effect if player.result>0 and self.playerHandCards[viewId] then effect = MJAnimationCompnent.CreateHuOrderEffect(player.result,player.huOrder) -- if player.result == MJDefine.MJGameHuType.HU_ZIMO then -- effect=MJAnimationCompnent.CreateHuOrderEffect("zimo",player.huOrder) -- else -- effect=MJAnimationCompnent.CreateHuOrderEffect("hu",player.huOrder) -- end if myUserId == player.nUserId then self.playerHandCards[viewId]:createHandCards(player.huCard) else self.playerHandCards[viewId]:createOpenHandCards(player.huCard) end self.playerHandCards[viewId]:moveLastCard() end if effect then self.ui.Items.Layout_Effect:addChild(effect) effect:setTag(HU_EFFECT_TAG) effect:setLocalZOrder(1000) local pos = self.playerHandCards[viewId]:getAnimationPostion() if viewId==MJDefine.PlayerViewType.My then effect:setPosition(pos.x,pos.y-60) elseif viewId==MJDefine.PlayerViewType.Left then effect:setPosition(pos.x-20,pos.y) elseif viewId==MJDefine.PlayerViewType.Right then effect:setPosition(pos.x+10,pos.y) elseif viewId==MJDefine.PlayerViewType.Top then effect:setPosition(pos.x,pos.y+10) end end end elseif roomInfo.nGameStartCount > 0 then--游戏中 if roomInfo.isOutHongZhong then self.isOutHongZhong = roomInfo.isOutHongZhong self.playerHandCards[MJDefine.MyViewId]:lockHongZhong(roomInfo.isOutHongZhong == 1) end --local outCardUserId = app.room:getUserIdBySeatId(roomInfo.needOutCardId) for k,v in pairs(roomInfo.memberList) do local viewId = app.room:getViewIdByUserId(v.nUserId) --可以爆牌玩家显示爆牌 if v.canBaoPai == 1 and v.nUserId == myUserId then showBaoPaiOp = true self.playerHandCards[viewId]:showBaoPai() end --已爆牌玩家不能出牌 if v.isBaoPai ~= 0 then self.playerView:playBaoAnim(viewId) if v.nUserId == myUserId then --自己爆牌 self.playerHandCards[viewId]:lockHandCard(true) -- self.playerHandCards[viewId]:setOutCardEnable(false) end else if roomInfo.outCardUserId == myUserId and table.nums(roomInfo.operates)>0 then -- self.playerHandCards[viewId]:onGetCard(roomInfo.operates) end end if viewId == MJDefine.MyViewId then if roomInfo.operates and table.nums(roomInfo.operates)>0 then self.operates = roomInfo.operates else self.operates = {} end end print("can out card-------1") if roomInfo.outCardUserId == v.nUserId then print("can out card-------2") if v.nUserId == myUserId and roomInfo.lastOpCard~=0 and roomInfo.isNeedOutCard > 0 then print("can out card-------3") self.playerHandCards[viewId]:removeHandCard(roomInfo.lastOpCard) self.playerHandCards[viewId]:resetHandCards() self.playerHandCards[viewId]:createHandCards(roomInfo.lastOpCard) end local handcardNum = #v.handCards print("can out card------- "..handcardNum) if (v.nUserId == myUserId and roomInfo.isNeedOutCard > 0) or handcardNum%3 == 2 then print("can out card-------4") self.playerHandCards[viewId]:setOutCardEnable(true) end end --需要出牌且听牌状态为1时,需要请求服务器推送听牌数据 --[[if roomInfo.isNeedOutCard==MJDefine.NeedOutCard.Need and v.nUserId == myUserId then if roomInfo.tingStatus == MJDefine.MJTingStatus.Ting then self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting) end end--]] end --显示哪些玩家胡牌 for i,player in pairs(roomInfo.memberList) do local viewId = app.room:getViewIdByUserId(player.nUserId) local effect if player.result>0 then --胡的类型大于0 if player.result == MJDefine.MJGameHuType.HU_ZIMO then effect=MJAnimationCompnent.CreateHuOrderEffect(player.result,player.huOrder) else effect=MJAnimationCompnent.CreateHuOrderEffect(player.result,player.huOrder) end if viewId == MJDefine.MyViewId then self.playerHandCards[viewId]:createHandCards(player.huCard) self.playerHandCards[viewId]:moveLastCard() else self.playerHandCards[viewId]:removeAllHandCards() self.playerHandCards[viewId]:createOpenHandCards(player.handCards) self.playerHandCards[viewId]:createOpenHandCards(player.huCard) self.playerHandCards[viewId]:moveLastOpenCard() end end if effect then self.ui.Items.Layout_Effect:addChild(effect) effect:setTag(HU_EFFECT_TAG) effect:setLocalZOrder(1000) local pos = self.playerHandCards[viewId]:getAnimationPostion() if viewId==MJDefine.PlayerViewType.My then effect:setPosition(pos.x,pos.y-60) elseif viewId==MJDefine.PlayerViewType.Left then effect:setPosition(pos.x-20,pos.y) elseif viewId==MJDefine.PlayerViewType.Right then effect:setPosition(pos.x+10,pos.y) elseif viewId==MJDefine.PlayerViewType.Top then effect:setPosition(pos.x,pos.y+10) end end end -- 显示托管 for i,player in pairs(roomInfo.memberList) do local viewId = app.room:getViewIdByUserId(player.nUserId) local extInfo = roomInfo.extJson or "" if type(extInfo)=='table' and extInfo[tostring(player.nUserId)] then local info = extInfo[tostring(player.nUserId)] local host = info.hosted or 0--托管状态 local isTuoGuan = host == 1; self.playerView:showTuoGuanByViewId(viewId,isTuoGuan) end end self.toolView:showTuoGuan(app.room:getMeIsHosting()) end --显示出牌角标(需要服务器修改outCardUserId为最后一位出牌玩家的id,而不是当前需要出牌玩家的ID) local lastOutCardViewId = app.room:getViewIdByUserId(roomInfo.outCardUserId); app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value = roomInfo.lastOpCard, viewId = lastOutCardViewId}); --显示听标示 app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing}); --如果有操作显示操作按钮 if self.playerHandCards[MJDefine.MyViewId] then self.playerHandCards[MJDefine.MyViewId]:showOperate(roomInfo.operates,roomInfo.lastOpCard); end if showBaoPaiOp and true == showBaoPaiOp then self.playerHandCards[MJDefine.MyViewId]:showBaoPai() end --如果一局结束,玩家点了准备,不再显示牌信息 if MJDefine.GameStatus.GAME_STATUS_ROUND_OVER == roomInfo.nStatus and roomInfo.memberList[myUserId].nPlayerFlag == 1 or MJDefine.GameStatus.GAME_STATUS_GAME_OVER == roomInfo.nStatus and roomInfo.memberList[myUserId].nPlayerFlag == 1 then --游戏为停止或开始状态 self:onUserReadyResponse({nUserId=myUserId}) end end function luzhouguiRoomView:getChangeGruopDatas(g) local opType=g.opType local showType=MJDefine.MJOperateToGroupType[g.opType] local opCard=g.opCard local redNum = g.redNum local fromViewId = nil local targetSeatId = g.targetSeatId--操作位置座位号 local fromUserId = g.opUserId or g.fromUserId --触发操作玩家 local fromViewId1 = app.room:getViewIdByUserId(fromUserId) if fromUserId<=0 or not targetSeatId then else 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 if showType == MJDefine.MJGroupType.Peng then fromViewId = 2 else fromViewId = 4 end end end --组合一下牌 local group={ opType=opType, showType=showType, values={}, opCard = opCard, redNum = redNum, 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 luzhouguiRoomView: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 self.direcionView:stopAllActions() self.operates = {} self:setTingCardViewVisible(false) app.room:resetTings() app.room:cleanTingStatus() --如果是解散直接return --[[if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo.stopFlag==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 and 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() for k,v in pairs(roomInfo.memberList) do local viewId = app.room:getViewIdByUserId(v.nUserId) if viewId and self.playerHandCards[viewId] then if viewId==MJDefine.MyViewId then else --倒牌 if v.huCard and v.huCard ~= 0 then self.playerHandCards[viewId]:createOpenHandCards(v.huCard) self.playerHandCards[viewId]:moveLastOpenCard() end end end end --被抢杠的人回退补杠 -- if resultInfo.hutype==MJDefine.MJHuType.QiangGangHu and roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_NORMAL then -- self.playerHandCards[failViewId]:retoreBuGang(resultInfo.hucard) -- end local function callback() self:showXiaoJuView() if onEnd then onEnd() end end if #viewIds>0 then -- self:runDelay(1.5,function() callback() -- end) --[[for k,viewId in pairs(viewIds) do local effect local memberList = roomInfo.memberList local userId = app.room:getUserIdByViewId(viewId) if k == #viewIds then --只有最后播放胡牌动画的回调一次就可以了 --self:showXiaoJuView() if memberList[userId].result == MJDefine.MJGameHuType.HU_ZIMO then effect = MJAnimationCompnent.CreateHuEffect("zimo",callback) else effect = MJAnimationCompnent.CreateHuEffect("hu",callback) end else if memberList[userId].result == MJDefine.MJGameHuType.HU_ZIMO then effect = MJAnimationCompnent.CreateHuEffect("zimo") else effect = MJAnimationCompnent.CreateHuEffect("hu") end end if effect then self.ui.Items.Layout_Player:addChild(effect) effect:setLocalZOrder(1000) effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion()) effect:setVisible(false) end end]]-- else if roomInfo.stopFlag==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 callback() end end end self:addCallBack(runGameXiaoJuResponse); end -- 显示小局结算 function luzhouguiRoomView:showXiaoJuView() self.direcionView:stopAllActions() self:setTingCardViewVisible(false) if self.xiaojuView then self.xiaojuView:removeFromParent() end local roomInfo = app.room.roomInfo self.xiaojuView = MJRoomXiaoJuView:new(self.desktopType) self:addChild(self.xiaojuView) end function luzhouguiRoomView:setTingCardViewVisible(bVisible,tingCards) -- tingCards= { -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- {card=0x01,count=1,fanshu=1}, -- } log("setTingCardViewVisible :"..table.tostring(tingCards)) self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(bVisible) -- self.ui.Items.ListView_Ting:removeAllItems() -- self.ui.Items.ListView_Ting:getHBar():setVisible(false) self.ui.Items.ListView_Ting:removeAllChildren() -- self.ui.Items.Item_Ting:setVisible(false) -- self.toolView:setVisible(false) if not tingCards then return end local count = #tingCards local row = math.ceil(count/5) --几行 self.ui.Items.ListView_Ting:setSize(cc.size(670,80*row)) self.ui.Items.Layout_Ting_Tip_Card_Panel:setSize(cc.size(row>1 and 786 or count*134+116,80*row+40)) self.ui.Items.ImageView_Ting:setPositionY(self.ui.Items.Layout_Ting_Tip_Card_Panel:getContentSize().height-60) for k,v in pairs(tingCards) do local item = self.ui.Items.Item_Ting:getCopied() item:setVisible(true) local items = getUIItems(item) items.Text_Num:setString(v.count.."张") items.Text_Fan:setString(v.fanshu.."番") local mj=MJ:new(v.card,MJDefine.MJType.Stand,MJDefine.MyViewId,self.desktopType) mj:setPosition(cc.p(20,30)) mj:setScale(0.5) items.Node:addChild(mj) self.ui.Items.ListView_Ting:addChild(item) end self.ui.Items.ListView_Ting:requestDoLayout() self.ui.Items.ListView_Ting:doLayout() -- local width=47 -- local padding=8 -- if #tingCards>=27 then -- local tingWidth=47+padding*2 -- self.ui.Items.ListView_Ting:setSize(cc.size(tingWidth,self.ui.Items.ListView_Ting:getContentSize().height)) -- self.ui.Items.Layout_Ting_Tip_Card_Panel:setSize(cc.size(tingWidth+60,self.ui.Items.Layout_Ting_Tip_Card_Panel:getContentSize().height)) -- local layout=cc.Layout:create() -- local mj=cc.Sprite:createWithSpriteFrameName("mj_img_quanting.png") -- layout:addChild(mj) -- layout:setSize(cc.size(mj:getContentSize().width,self.ui.Items.ListView_Ting:getContentSize().height)) -- self.ui.Items.ListView_Ting:pushBackCustomItem(layout) -- mj:setPosition(layout:getContentSize().width/2,layout:getContentSize().height/2) -- else -- local count=#tingCards>8 and 8 or #tingCards -- local tingWidth=count*47+padding*(count+1) -- self.ui.Items.ListView_Ting:setSize(cc.size(tingWidth,self.ui.Items.ListView_Ting:getContentSize().height)) -- self.ui.Items.Layout_Ting_Tip_Card_Panel:setSize(cc.size(tingWidth+60,self.ui.Items.Layout_Ting_Tip_Card_Panel:getContentSize().height)) -- local scale = 0.58 -- for k,v in pairs(tingCards) do -- local layout=cc.Layout:create() -- local mj=MJ:new(v.card,MJDefine.MJType.Stand,MJDefine.MyViewId) -- mj:setScale(scale) -- layout:addChild(mj) -- local mjWidth = mj:getContentSize().width*scale -- layout:setSize(cc.size(mjWidth+padding,self.ui.Items.ListView_Ting:getContentSize().height)) -- self.ui.Items.ListView_Ting:pushBackCustomItem(layout) -- mj:setPosition(layout:getContentSize().width/2,layout:getContentSize().height/2+9)--65) -- -- mj:setScale(0.5) -- local mjNum = cc.Text:createNode() -- mjNum:setDefaults() -- local config = mjNum:getFontConfig() -- config.fontSize = 18 -- config.texColor = cc.c4b(0x98,0xcf,0x7b,255) -- mjNum:setFontConfig(config) -- layout:addChild(mjNum) -- mjNum:setPosition(cc.p(mj:getPositionX(),10)) -- mjNum:setString(string.format("%d张", v.count)) -- end -- end end --显示查听的牌 function luzhouguiRoomView:setChaTingCardViewVisible(bVisible,tingCards) end function luzhouguiRoomView:onTingCardStatus() local myUserId=app.user.loginInfo.uid local memberList=app.room.roomInfo.memberList if memberList[myUserId] then local nTingStatus=memberList[myUserId].nTingStatus if nTingStatus == MJDefine.MJTingStatus.Ting then print("---------onTingCardStatus-----------1 "..myUserId) -- self:setChaTingCardViewVisible(true) -- self:setTingCardViewVisible(true, ) self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting) else print("---------onTingCardStatus-----------0 "..myUserId) -- self:setChaTingCardViewVisible(false) self:setTingCardViewVisible(false) end end end function luzhouguiRoomView:onTingCardResult(data) print("---------听牌结果-------------") if data.response.tingType==MJDefine.MJTingType.QuanTing then -- self:setChaTingCardViewVisible(true,{}) else self:setTingCardViewVisible(true, data.response.tingCards) end end function luzhouguiRoomView:showTing(evet) local roomInfo=app.room.roomInfo -- if evet.card and roomInfo.tings and roomInfo.tings[evet.card] then -- self:setTingCardViewVisible(true,roomInfo.tings[evet.card]) -- else -- self:setTingCardViewVisible(false) -- end if evet.card and roomInfo.tings and #roomInfo.tings>0 then local isTing = false for k,v in pairs(roomInfo.tings) do if evet.card==v.outCard then self:setTingCardViewVisible(true,v.tingCards) isTing = true end end if not isTing then self:setTingCardViewVisible(false) end else self:setTingCardViewVisible(false) end end function luzhouguiRoomView:pushTing() local function runPushTing(onEnd) if self.playerHandCards[MJDefine.MyViewId] then self.playerHandCards[MJDefine.MyViewId]:pushTing() end if onEnd then onEnd() end end self:addCallBack(runPushTing); end function luzhouguiRoomView:onHuResponse(data) local function runHuResponse(onEnd) local response = data.response local function callback() self:playHuAni(response) if onEnd then onEnd() end end local viewId = app.room:getViewIdByUserId(response.nUserId) local userInfo=app.room:getUserInfoByViewId(viewId) --先播放胡牌动画和音效,再显示胡牌顺序 local effect = MJAnimationCompnent.CreateHuEffect(response.huType,callback) if response.huType == MJDefine.MJGameHuType.HU_ZIMO then MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_ZIMOHU) -- effect=MJAnimationCompnent.CreateHuEffect("zimo",callback) -- elseif response.huType == MJDefine.MJGameHuType.HU_QIANGGANG then else MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_DIANPAOHU) -- effect=MJAnimationCompnent.CreateHuEffect("hu",callback) -- --点炮显示 end if effect then self.ui.Items.Layout_Effect:addChild(effect) effect:setTag(HU_EFFECT_TAG) effect:setLocalZOrder(1000) effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion()) end --删除等待操作的显示 if self.waitOperates and #self.waitOperates>0 then for k,v in pairs(self.waitOperates) do v:removeFromParent() end self.waitOperates={} end if response.huType==MJDefine.MJGameHuType.HU_DIANPAO then local failViewId = app.room:getViewIdByUserId(response.dpId) --点炮胡或抢杠胡,胡牌类型都是发 点炮胡 if response.isQiangGng > 0 then local huCard = response.huCard == 65 and response.redRealCard or response.huCard --如果胡的牌是红中 用真实的牌 否则用胡的牌 -- logD("isQiangGng huCard:"..huCard) --抢杠胡 self.playerHandCards[viewId]:onGetCard(nil,huCard) --被抢杠的人回退补杠 self.playerHandCards[failViewId]:retoreBuGang(huCard,1) else self.playerHandCards[viewId]:onGetCard(nil,response.huCard) --将胡的牌收走 self.playerHandCards[failViewId]:removeOutCard(response.huCard) end --放炮动画 effect=MJAnimationCompnent.CreateDianPaoEffect() self.ui.Items.Layout_Effect:addChild(effect) effect:setLocalZOrder(1000) effect:setPosition(self.playerHandCards[failViewId]:getAnimationPostion()) if failViewId==MJDefine.MyViewId and app.room.roomInfo.lastOutViewId==MJDefine.MyViewId then --修改点炮的人连续二次出牌 不删除牌 app.room.roomInfo.lastOutViewId = 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[failViewId]:retoreBuGang(response.redRealCard,1) end end if response.nUserId == app.room:getMyUserId() then self.playerHandCards[viewId]:setOutCardEnable(false) self:setTingCardViewVisible(false) self.playerHandCards[viewId]:setTing(false) self.operates = {} else -- 其他人胡了倒牌 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() end self.playerHandCards[MJDefine.MyViewId]:hideOperate() end self:addCallBack(runHuResponse); end function luzhouguiRoomView:playHuAni(response) local strGameInfo = json.decode(app.room.roomInfo.strGameInfo) local effect = MJAnimationCompnent.CreateHuOrderEffect(response.huType,response.huOrder) -- if response.huType == 1 then -- effect=MJAnimationCompnent.CreateHuOrderEffect("zimo",response.huOrder) -- else -- effect=MJAnimationCompnent.CreateHuOrderEffect("hu",response.huOrder) -- end local viewId = app.room:getViewIdByUserId(response.nUserId) if effect then self.ui.Items.Layout_Effect:addChild(effect) effect:setTag(HU_EFFECT_TAG) effect:setLocalZOrder(1000) local pos = self.playerHandCards[viewId]:getAnimationPostion() if viewId==MJDefine.PlayerViewType.My then effect:setPosition(pos.x,pos.y-60) elseif viewId==MJDefine.PlayerViewType.Left then effect:setPosition(pos.x-20,pos.y) elseif viewId==MJDefine.PlayerViewType.Right then effect:setPosition(pos.x+10,pos.y) elseif viewId==MJDefine.PlayerViewType.Top then effect:setPosition(pos.x,pos.y+10) end end end function luzhouguiRoomView:onQiangDuanOperates(data) local function runOnQiangDuanOperates(onEnd) logD("luzhouguiRoomView: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("luzhouguiRoomView:onQiangDuanOperates") self:addCallBack(runOnQiangDuanOperates) end function luzhouguiRoomView:onOutRedCardInfo(data) logD("luzhouguiRoomView:onOutRedCardInfo") local response = data.response self.isOutHongZhong = response.isOut self.playerHandCards[MJDefine.MyViewId]:lockHongZhong(response.isOut == 1) --logD("luzhouguiRoomView:onOutRedCardInfo") --self:addCallBack(runOnQiangDuanOperates) end --游戏消息 function luzhouguiRoomView: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.room , MJDefine.MJEvent.OutRedCardInfo, handler(self , self.onOutRedCardInfo)) self:bindEvent(app , MJDefine.MJEvent.ChangeLanguage , handler(self , self.doSound)) self:bindEvent(app, MJDefine.MJEvent.ChangeViewType, handler(self, self.onEventChangeViewType )) self:bindEvent(app, MJDefine.MJEvent.TieGuiAndAutomatic, handler(self, self.onTieGuiAndAutomatic )) -- 托管 self:bindEvent(app.room , MJDefine.MJEvent.HostingRequest, handler(self, self.onHostingRequest)) end --[[--------------------------------------------------------------------------------------------------连打修改--]] --[[function luzhouguiRoomView:onUserExitResponseRoom(data) local response = data.response --长时间未开始强制退出,否则不退出 if app.room.roomInfo.stopFlag ~= MJDefine.TABLE_OVER_FLAG.TABLE_OVER_LONG_TIME_NO_START and app.room.roomInfo.nGameStartCount ~= 0 then data.response.logoutFlag = 0; else data.response.logoutFlag = 1; end app.room.roomInfo.tableOverFlag = response.tableOverFlag --如果是自己点离开必须退出 if app.room.roomInfo.bQuitRoom then data.response.logoutFlag = 1; app.room.roomInfo.bQuitRoom = nil end --房间结束原因(0:正常结束,1:俱乐部群主解散,2:房主解散,3:长时间未开始,4:长时间未结束) --正常结束不提示,其他都要提示 if app.room.roomInfo.tableOverFlag >= MJDefine.TABLE_OVER_FLAG.TABLE_OVER_GROUP_DISBAND then showTooltip(MJDefine.TABLE_OVER_FLAG_TEXT[app.room.roomInfo.tableOverFlag]) end app.room.roomInfo.stopFlag = response.logoutFlag luzhouguiRoomView.super.onUserExitResponseRoom(self, data) end--]] function luzhouguiRoomView: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 luzhouguiRoomView:updateReady() local nUserId = app.room:getMyUserId()--app.user.loginInfo.uid if app.room.roomInfo.nGameStartCount > 0 then self.toolView.ui.Items.Button_Leave:setEnabled(false) self:setBtnSitDownVisible(false) else self.toolView.ui.Items.Button_Leave:setEnabled(true) end if app.room.roomInfo.nGameStartCount == 0 and app.room.roomInfo.nRoomOwnedUid ~= nUserId then self.toolView.ui.Items.Button_Dismiss:setEnabled(false) else self.toolView.ui.Items.Button_Dismiss:setEnabled(true) end self:checkCanDismiss() end -- 游戏开始 function luzhouguiRoomView:onGameStartResponse() luzhouguiRoomView.super.onGameStartResponse(self) if app.room.roomInfo.isEapCreate == 1 then local function runEapSdkPopup(onEnd) local function call() if onEnd then onEnd() end end G_EapSdkMgr:showBeginLayer(call) end self:addCallBack(runEapSdkPopup); end self._gameoverview = nil end -- 大局结算 function luzhouguiRoomView:onGameDaJuResponse(data) app.club_php:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM}) if self._gameoverview then return end if app.room.roomInfo.needJieSuanInfo == 1 then--显示总结算 self:showGameOverResult(data.response) else --[[local roomInfo=app.room.roomInfo --如果是解散直接跳转总结算 if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then self:showGameOverResult(data.response) end --]] app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE}) end end -- 大局结算 function luzhouguiRoomView:showGameOverResult(data) if self._gameoverview ~= nil then return end self.direcionView:stopAllActions() self:resetGame() local view=MJRoomDaJuView:new(data) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) self._gameoverview = view self:showGameOverAward() end function luzhouguiRoomView:onOtherLogoutResponse(data) -- local jushu = app.room.roomInfo.nGameStartCount or 0 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() -- self:setWetChatVisible(table.nums(app.room.roomInfo.memberList) < app.room.roomInfo.nMaxPlayCount) -- if isReviewVersion() then -- self:setWetChatVisible(false); -- end -- if app.room.roomInfo.nGameStartCount > 0 then -- self:setWetChatVisible(false) -- end logE("88888-onOtherLogoutResponse onEnd") if onEnd then onEnd() end end self:addCallBack(test) end -- 发牌 -- function luzhouguiRoomView:onGameSendCardResponse() -- luzhouguiRoomView.super.onGameSendCardResponse(self) -- end function luzhouguiRoomView:resetGame() luzhouguiRoomView.super.resetGame(self) self.ui.Items.Layout_Effect:removeAllChildren() if G_LayerMain then G_LayerMain:showBoard(false) G_LayerMain:showFloat(false) end end function luzhouguiRoomView:onEventChangeViewType(data) MJDefine.MJConfig = MJDefine.loadMJConfig() self:changeGameBg(true) self.ui:sendMsg(app.room, MJDefine.MJEvent.GetTableInfo); end -- 等待操作消息 function luzhouguiRoomView:onWaitOperate(data) luzhouguiRoomView.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 luzhouguiRoomView: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 --- -- 检测是否可以解散房间 -- @param -- @return -- function luzhouguiRoomView:checkCanDismiss( ) local onCanDismissCallback = function (info) local nUserId = app.room:getMyUserId() local roomInfo = app.room.roomInfo or {} local canDismiss = (tonumber(info.canDismiss or 1) == 1) or roomInfo.nRoomOwnedUid == nUserId or dd.IClub.isAdmin() if roomInfo.nGameStartCount == 0 and roomInfo.nRoomOwnedUid ~= nUserId then canDismiss = false end if roomInfo.isEapCreate == 1 then canDismiss = false end self:onCanDismissCallback(canDismiss) end if dd.IClub.getCanDismiss then local canDismiss = dd.IClub.getCanDismiss(onCanDismissCallback) if canDismiss then onCanDismissCallback({canDismiss = canDismiss}) end end end return luzhouguiRoomView