|
- 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 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 MJAnimationComponent=MJFramework.MJImport("mj.luaScript.Views.Compnent.MJAnimationCompnent")
- local NeiJiangMJAnimationComponent = MJFramework.MJImport("mj_neijiang.luaScript.Views.Component.neijiangAnimationComponent")
- local MJFunction=MJFramework.MJImport("mj.luaScript.MJFunction")
- local MJSound = MJFramework.MJImport("mj.luaScript.MJSound")
-
- local MJRoomView = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomView")
- local NeiJiangMJRoomView = class("NeiJiangMJRoomView", MJRoomView)
-
- local zhongNiaoTime=1.33
- local HU_EFFECT_TAG = 100
- local PIAO_EFFECT_TAG = 200
- local BAOJIAO_EFFECT_TAG = 210;
-
- function NeiJiangMJRoomView:ctor()
- NeiJiangMJRoomView.super.ctor(self)
- self.operates = {}
- end
-
- function NeiJiangMJRoomView:loadUi()
- local ui = loadUI("mj_neijiang/res/ui_fangjian/mj_neijiang_room_view.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function NeiJiangMJRoomView:onEnter()
- NeiJiangMJRoomView.super.onEnter(self)
- self:doSound()
- end
-
- function NeiJiangMJRoomView:onExit()
- NeiJiangMJRoomView.super.onExit(self)
-
- end
-
- function NeiJiangMJRoomView:doSound()--1 普通话 2 方言
- -- local defaultValue = tonumber(loadUserInfo("mj_language")) or 1
- local cacheLan = "mj_language"..(MJDefine.GameID or app.gameId)
- local defaultValue = tonumber(loadUserInfo(cacheLan)) or 1
- MJSound.setSoundType(defaultValue)
- end
-
-
- -- 一键截屏
- function NeiJiangMJRoomView:onClickButtonShot( sender )
- playBtnEffect()
- showScreenShot()
- end
-
- --隐藏俱乐部
- function NeiJiangMJRoomView: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 NeiJiangMJRoomView: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 NeiJiangMJRoomView:loadTextureCache()
- NeiJiangMJRoomView.super.loadTextureCache(self)
- -- local defaultValue = tonumber(loadUserInfo("neijiang_mj_majhong")) or 1
-
- loadSpriteFrameFile("mj_neijiang/res/zy_fangjian/mj_neijiang_operation_effect.plist")
-
- end
-
-
- function NeiJiangMJRoomView: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)
- self:setTingCardViewVisible(false);
- end)
-
- --隐藏听牌模板
- 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)
-
- self.ui.Items.Button_Ting_Info:setVisible(false);
- self.ui.Items.Button_Ting_Info:registerClick(handler(self, self.onBtnTingInfoClicked))
- end
-
- function NeiJiangMJRoomView:onGameSendCardResponse()
- local function runGameSendCardResponse(onEnd)
- self.ui.Items.Layout_Effect:removeAllChildren();
- log("2000000000-NeiJiangMJRoomView - runGameSendCardResponse()" )
- 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.isTing and myUserId == v.nUserId then
- self:setBaoJiaoViewVisible(true);
- end
- end
-
- app.room.roomInfo.nLeaveCardNum = 72 - 13 * table.nums(app.room.roomInfo.memberList);
- self.direcionView:updateGameNums();
-
- -- local effect=MJAnimationComponent.CreateGameStart()
- -- self.ui.Items.Layout_Player:addChild(effect,5)
- -- MJSound.PlayStartGame()
-
- MJAnimationComponent.CreateStartSendCards(self.playerHandCards,onEnd)
-
- -- if onEnd then
- -- onEnd()
- -- end
- end
- log("2000000000-NeiJiangMJRoomView - addCallBack(runGameSendCardResponse)" )
- self:addCallBack(runGameSendCardResponse);
- end
- ---
- -- 玩家准备通知
- -- @param response
- -- @return
- --
- function NeiJiangMJRoomView:onUserReadyResponse(response)
- NeiJiangMJRoomView.super.onUserReadyResponse(self,response)
- if not response then
- return ;
- end
- local viewId = app.room:getViewIdByUserId(response.nUserId);
- self.playerView:setPiaoVisible(viewId, false);
- self.playerView:setBaoJiaoVisible(viewId, false);
- self.playerView:setBoZiMoVisible(viewId, false);
-
- for k, v in pairs(app.room.roomInfo.memberList) do
- v.nBaoCardState = -1;
- v.nPiaoState = -1;
- end
-
- self.ui.Items.Button_Ting_Info:setVisible(false);
- end
-
- -- 广播桌子上所有玩家庄家起手操作
- function NeiJiangMJRoomView: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("NeiJiangMJRoomView onBankerOutCard :"..table.tostring(data.response))
- -- if not data.response.nUserId then
- -- showTooltip("庄家起手操作nUserId is not exist")
- -- end
- 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
- -- 抓起手牌的时候,隐藏听牌按钮
- self.ui.Items.Button_Ting_Info:setVisible(false);
-
- 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.nBaoCardState == 1 or player.nBaoCardState == 2) 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})
-
- 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-NeiJiangMJRoomView - addCallBack(runOnBankerOutCard)")
- self:addCallBack(runOnBankerOutCard);
-
- end
-
- function NeiJiangMJRoomView: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 NeiJiangMJRoomView:onOutCardSuccess(data)
- logE("NeiJiangMJRoomView: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-NeiJiangMJRoomView - 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)
- if (player.nBaoCardState == 1 or player.nBaoCardState == 2) and app.room.roomInfo.lastOutViewId~=MJDefine.MyViewId then --点击爆牌的时候 前端已经打出牌 要判断上次出牌的人是不是自己 避免重复出牌
- self.playerHandCards[viewId]:onOutCard(card,callback)
- else
- callback()
- end
-
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo);
- if gameInfo.tingpai > 0 then
- self._isOutCardTingCheck = true;
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- end
- 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-NeiJiangMJRoomView - addCallBack(runOnOutCardSuccess)")
- -- self:addCallBack(runOnOutCardSuccess)
- end
-
- --已经发送了过操作,此时就算再勾选贴鬼碰,也不会显示操作
- function NeiJiangMJRoomView:onSendGuo()
- --发牌重置,主要用于贴鬼碰/杠
- MJDefine.isSendGuo = false
- self.operates = {}
- end
-
- -- 操作成功
- function NeiJiangMJRoomView: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 -- 没用,要删掉 by c.mj
- 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)
- 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)
- else
- if opType==MJDefine.MJOperateType.OPREATE_BAGANG then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,1)
- else
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,3)
- 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=MJAnimationComponent.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 NeiJiangMJRoomView: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 NeiJiangMJRoomView:onGameReconnection()
- NeiJiangMJRoomView.super.onGameReconnection(self)
- local roomInfo = app.room.roomInfo
- local myUserId = app.room:getMyUserId()
- 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)
- local effect
- if player.result>0 and self.playerHandCards[viewId] then
- effect = MJAnimationComponent.CreateHuOrderEffect(player.result,player.huOrder)
- -- if player.result == MJDefine.MJGameHuType.HU_ZIMO then
- -- effect=MJAnimationComponent.CreateHuOrderEffect("zimo",player.huOrder)
- -- else
- -- effect=MJAnimationComponent.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.nStatus == MJDefine.GameStatus.GAME_STATUS_WAIT_OP_PIAO then
- -- 飘状态
- for k, v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId);
- if viewId == MJDefine.MyViewId then
- if not (v.nPiaoState == 0 or v.nPiaoState == 1) then
- self:setPiaoViewVisible(true);
- end
-
- self.playerView:setPiaoVisible(viewId, v.nPiaoState == 1);
- end
-
- local piaoInfo = {
- userId = v.nUserId,
- nPiaoState = v.nPiaoState
- }
- self:onPiaoResponse({response = piaoInfo});
- end
- elseif roomInfo.nGameStartCount > 0 then--游戏中
- --local outCardUserId = app.room:getUserIdBySeatId(roomInfo.needOutCardId)
- -- 显示骰子数
- self:onRoolDiceAnimFinished(roomInfo.diceNum[1], roomInfo.diceNum[2]);
-
- if roomInfo.memberList[myUserId].nTingStatus == MJDefine.MJTingStatus.Ting then
- local gameInfo =json.decode(app.room.roomInfo.strGameInfo);
- if gameInfo.tingpai > 0 then
- self.ui.Items.Button_Ting_Info:setVisible(true);
- end
- end
-
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- local isMySelf = v.nUserId == myUserId;
- -- --可以爆牌玩家显示爆牌
- -- if v.canBaoPai == 1 and v.nUserId == myUserId then
- -- self.playerHandCards[viewId]:showBaoPai()
- -- end
-
- if isMySelf and (roomInfo.nStatus == MJDefine.GameStatus.GAME_STATUS_WAIT_OUT_CARD or roomInfo.nStatus == MJDefine.GameStatus.GAME_STATUS_WAIT_OP_BAO) then
- -- 有报叫,未操作
- self:setBaoJiaoViewVisible(v.nBaoCardState == 3);
- end
-
- -- 显示头像上的飘
- self.playerView:setPiaoVisible(viewId, v.nPiaoState == 1);
- self.playerView:setBaoJiaoVisible(viewId, v.nBaoCardState == 1);
- self.playerView:setBoZiMoVisible(viewId, v.nBaoCardState == 2);
-
- --已爆牌玩家不能出牌
- if (v.nBaoCardState == 1 or v.nBaoCardState == 2) and isMySelf then
- self.playerHandCards[viewId]:lockHandCard()
- -- self.playerHandCards[viewId]:setOutCardEnable(false)
- else
- --[[if roomInfo.outCardUserId == myUserId and table.nums(roomInfo.operates) > 0 then
- -- self.playerHandCards[viewId]:onGetCard(roomInfo.operates)
- end--]]
- if roomInfo.outCardUserId == v.nUserId then
- self.playerHandCards[viewId]:setOutCardEnable(true)
- end
- end
-
- if isMySelf then
- if roomInfo.operates and table.nums(roomInfo.operates)>0 then
- self.operates = roomInfo.operates
- else
- self.operates = {}
- 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=NeiJiangMJAnimationComponent.CreateHuOrderEffect(player.result,player.huOrder)
- else
- effect=NeiJiangMJAnimationComponent.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
- end
- end
- --[[
- function NeiJiangMJRoomView: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 NeiJiangMJRoomView: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 > 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.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
- local delaySeconds = #viewIds < 4 and 2 or 0;
- self:runDelay(delaySeconds, 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 = MJAnimationComponent.CreateHuEffect("zimo",callback)
- else
- effect = MJAnimationComponent.CreateHuEffect("hu",callback)
- end
- else
- if memberList[userId].result == MJDefine.MJGameHuType.HU_ZIMO then
- effect = MJAnimationComponent.CreateHuEffect("zimo")
- else
- effect = MJAnimationComponent.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=MJAnimationComponent.CreateLiuJuEffect(callback)
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- MJSound.PlayHuangZhuang()
- else
- callback();
- end
- end
- end
- self:addCallBack(runGameXiaoJuResponse);
- end
-
- -- 显示小局结算
- function NeiJiangMJRoomView: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 NeiJiangMJRoomView: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 and table.nums(tingCards) > 0) then
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(false);
- 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 NeiJiangMJRoomView:setChaTingCardViewVisible(bVisible,tingCards)
- end
-
- function NeiJiangMJRoomView: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)
- self.ui.Items.Button_Ting_Info:setVisible(false);
- end
- end
- end
-
- function NeiJiangMJRoomView:onTingCardResult(data)
- print("---------听牌结果-------------")
- if data.response.tingType==MJDefine.MJTingType.QuanTing then
- -- self:setChaTingCardViewVisible(true,{})
- else
- if self._isOutCardTingCheck then
- self._isOutCardTingCheck = false;
- local count = table.nums(data.response.tingCards);
- local isTing = count > 0;
- self.ui.Items.Button_Ting_Info:setVisible(isTing);
- self:setTingCardViewVisible(false, data.response.tingCards)
- else
- self:setTingCardViewVisible(true, data.response.tingCards)
- end
- end
- end
-
- function NeiJiangMJRoomView: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 NeiJiangMJRoomView: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 NeiJiangMJRoomView: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 = NeiJiangMJAnimationComponent.CreateHuEffect(response.huType,callback)
- if response.huType == MJDefine.MJGameHuType.HU_ZIMO then
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_ZIMOHU)
- -- effect=MJAnimationComponent.CreateHuEffect("zimo",callback)
- -- elseif response.huType == MJDefine.MJGameHuType.HU_QIANGGANG then
-
- else
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_DIANPAOHU)
- -- effect=MJAnimationComponent.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
-
- --放炮动画
- --[[
- by c.mj
- effect=MJAnimationComponent.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)
-
- else
- -- 其他人胡了倒牌
- local handCards = {}
- for k,v in pairs(self.playerHandCards[viewId].handCards) do
- table.insert(handCards,{card = v.value})
- 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
-
- if viewId == MJDefine.MyViewId then
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- end
- end
- self:addCallBack(runHuResponse);
- end
-
- function NeiJiangMJRoomView:playHuAni(response)
- local strGameInfo = json.decode(app.room.roomInfo.strGameInfo)
- local effect = MJAnimationComponent.CreateHuOrderEffect(response.huType,response.huOrder)
- -- if response.huType == 1 then
- -- effect=MJAnimationComponent.CreateHuOrderEffect("zimo",response.huOrder)
- -- else
- -- effect=MJAnimationComponent.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 NeiJiangMJRoomView:onQiangDuanOperates(data)
- local function runOnQiangDuanOperates(onEnd)
- logD("NeiJiangMJRoomView: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("NeiJiangMJRoomView:onQiangDuanOperates")
- self:addCallBack(runOnQiangDuanOperates)
- end
-
- --游戏消息
- function NeiJiangMJRoomView: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.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.RollDiceBroadcast, handler(self, self.onRollDiceBroadcast));
- -- 通知飘的结果
- self:bindEvent(app.room, MJDefine.MJEvent.PiaoBroadcast, handler(self, self.onPiaoBroadcast));
- self:bindEvent(app.room, MJDefine.MJEvent.PiaoResponse, handler(self, self.onPiaoResponse));
- -- 通知可以报叫
- self:bindEvent(app.room, MJDefine.MJEvent.BaoJiaoBroadcast, handler(self, self.onBaoJiaoBroadcast));
- self:bindEvent(app.room, MJDefine.MJEvent.BaoJiaoResponse, handler(self, self.onBaoJiaoResponse));
- end
-
-
- --[[--------------------------------------------------------------------------------------------------连打修改--]]
- --[[function NeiJiangMJRoomView: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
-
- NeiJiangMJRoomView.super.onUserExitResponseRoom(self, data)
- end--]]
-
- function NeiJiangMJRoomView: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 NeiJiangMJRoomView: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
- end
-
- -- 游戏开始
- function NeiJiangMJRoomView:onGameStartResponse()
- app.room.roomInfo.nLeaveCardNum = 72; -- 只是为了在飘界面显示牌数
-
- local function runGameStartResponse(onEnd)
- log("2000000000-NeiJiangMJRoomView - runGameStartResponse()" )
-
- --更新背景
- self:changeGameBg(true)
-
- --隐藏俱乐部
- self:hideClub()
-
- --重置玩家数据
- self:resetGame()
-
- self:initHandCardNodes()
-
- --写入数据
- for k,v in pairs(app.room.roomInfo.memberList) do
- v.nPlayerFlag = 2
- end
-
- --更新玩家状态状态
- self:onUserReadyResponse()
-
- self.toolView:updateButton()
- -- 隐藏邀请好友
- -- self:setWetChatVisible(false)
-
- -- 更新局数
- self:updateGameNums()
-
- --更新庄家
- self:updateBanker()
-
- --初始化方位
- self.direcionView:initDirection(self.desktopType)
- -- self.direcionView:updateDirection(app.room.roomInfo.nBankSeatId)
- 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("00");
-
- --展示洗牌
- local isHaveCallBack = false
- local function call()
- if not isHaveCallBack then
- isHaveCallBack = true
- logD("only one shuffle!!")
- if onEnd then
- onEnd()
- end
- end
- end
- local isFind = self:isHavePlayerShuffle()
- if isFind then
- for k,v in pairs(app.room.roomInfo.shuffleList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if v.bShuffle == 1 and self.playerHandCards[viewId] then
- MJAnimationComponent.CreateXiPai(self.ui.Items.Layout_Player,MJDefine.MJXiPaiConfig[viewId].position,call,viewId)
- end
- end
- else
- call()
- end
-
- -- cc.Device:vibrate(5)
- end
- log("2000000000-NeiJiangMJRoomView - addCallBack(runGameStartResponse)" )
- self:addCallBack(runGameStartResponse);
-
- self._gameoverview = nil
-
- self:setDiceViewVisible(false);
- end
-
- -- 大局结算
- function NeiJiangMJRoomView:onGameDaJuResponse(data)
- 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 NeiJiangMJRoomView: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
- end
-
- function NeiJiangMJRoomView: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 NeiJiangMJRoomView:resetGame()
- NeiJiangMJRoomView.super.resetGame(self)
- self.ui.Items.Layout_Effect:removeAllChildren()
- end
- --[[
- -- 广播玩家可以报叫了
- -- @param
- -- @return
- --]]
- function NeiJiangMJRoomView:onBaoJiaoBroadcast (data)
-
- local function onRunBaoJiaoBroadcast (onEnd)
- local response = data.response;
- if not response then
- return ;
- end
-
- if not response.isMySelf then
- return ;
- end
-
- self:setBaoJiaoViewVisible(true);
-
- if onEnd then
- onEnd()
- end
- end
-
- self:addCallBack(onRunBaoJiaoBroadcast)
- end
- --[[
- -- 有玩家操作了报叫,广播玩家结果
- -- @param response {userId = 123456, nBaoCardState = 0 or 1}
- -- @return
- --]]
- function NeiJiangMJRoomView:onBaoJiaoResponse( data )
- local response = data.response;
- if not response then
- return ;
- end
-
- local userId = response.userId or 0;
- local isBaoJiao = response.nBaoCardState == 1;
- local isBoZiMo = response.nBaoCardState == 2;
- if not (userId and userId > 0) then
- -- 玩家UID错误
- return ;
- end
-
- -- 在对应玩家处播放动画或打上标识
- local viewId = app.room:getViewIdByUserId(userId);
-
- if not (isBaoJiao or isBoZiMo) then return ; end
-
-
- -- 显示对应玩家相关飘的标识或动画
- local viewId = app.room:getViewIdByUserId(userId);
- local userInfo=app.room:getUserInfoByViewId(viewId)
- --爆牌音效
- MJSound.PlayBaoSound(userInfo.sex)
- if app.room:getMyUserId() == userId and (isBaoJiao or isBoZiMo) then
- self.playerHandCards[viewId]:lockHandCard()
- -- self.playerHandCards[viewId]:setOutCardEnable(false)
-
- local gameInfo =json.decode(app.room.roomInfo.strGameInfo);
- if gameInfo.tingpai > 0 then
- self.ui.Items.Button_Ting_Info:setVisible(true);
- app.room.roomInfo.memberList[userId].nTingStatus = MJDefine.MJTingStatus.Ting;
- end
- else
- --self.playerHandCards[viewId]:setOutCardEnable(true)
- end
- -- 显示头像标识
- self.playerView:setBaoJiaoVisible(viewId, isBaoJiao);
- self.playerView:setBoZiMoVisible(viewId, isBoZiMo);
-
- -- 播放动画
- local opType = isBaoJiao and MJDefine.MJOperateType.OPERATE_BAOJIAO or MJDefine.MJOperateType.OPERATE_BOZIMO;
- local effect = NeiJiangMJAnimationComponent.CreateOperareEffectExt(opType, function () end, true);
-
- if not effect then return ; end
-
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(BAOJIAO_EFFECT_TAG + viewId);
- 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
- --[[
- -- 通知摇骰子
- -- @param
- -- @return
- --]]
- function NeiJiangMJRoomView:onRollDiceBroadcast(data)
- self:runDelay(0.2, function ()
- self.ui.Items.Layout_Effect:removeAllChildren();
- end)
-
- self.diceNum = data.response;
- local response = data.response;
- if not tolua.isnull(self.diceAnim) then
- self.diceAnim:removeFromParent();
- self.diceAnim = nil;
- end
- local visibleSize = cc.Director:getInstance():getVisibleSize();
- self.diceAnim = MJFramework.MJImport("mj_neijiang.luaScript.Views.Animation.neijiangDiceAnimation"):new();
- self.diceAnim:play(response[1], response[2], handler(self, self.onRoolDiceAnimFinished));
- self.diceAnim:setPosition(cc.p(visibleSize.width / 2, visibleSize.height / 2));
- self:addChild(self.diceAnim);
- end
- ---
- -- 动画播放回调
- -- @return
- --
- function NeiJiangMJRoomView:onRoolDiceAnimFinished (dice1, dice2)
- if not self.diceView then
- self.diceView = MJFramework.MJImport("mj_neijiang.luaScript.Views.Component.neijiangDiceView"):new();
- self.ui.Items.ImageView_bg:addChild(self.diceView);
- end
- if dice1 <= 0 or dice2 <= 0 then
- self:setDiceViewVisible(false);
- return ;
- end
- self.diceView:setDice(dice1, dice2);
- self:setDiceViewVisible(true);
- end
- --[[/**
- * 设置骰子组件显示/隐藏
- * @param isVisible boolean 是否显示
- * @return
- */--]]
- function NeiJiangMJRoomView:setDiceViewVisible (isVisible)
- if tolua.isnull(self.diceView) then return end
- if self.diceView then
- self.diceView:setVisible(isVisible);
- end
- end
- --[[/**
- * 通知可以进行飘操作了
- * @param response {}
- * @return
- */--]]
- function NeiJiangMJRoomView:onPiaoBroadcast( data )
- self.ui.Items.Layout_Effect:removeAllChildren();
- self:setPiaoViewVisible(true);
- end
- --[[/**
- * 通知玩家操作飘结果
- * @param response {userId = 123456, nPiaoState = 1 or 0}
- * @return
- */--]]
- function NeiJiangMJRoomView:onPiaoResponse (data)
- local response = data.response;
- if not response then
- return ;
- end
- local userId = response.userId;
- local isPiao = response.nPiaoState == 1;
- if not (userId and userId > 0) then
- return ;
- end
-
- if not isPiao then
- return ;
- end
-
- -- 显示对应玩家相关飘的标识或动画
- local viewId = app.room:getViewIdByUserId(userId);
- local userInfo=app.room:getUserInfoByViewId(viewId);
- -- 飘音效
- MJSound.PlayPiaoSound(userInfo.sex);
-
- self.playerView:setPiaoVisible(viewId, isPiao)
- local effect = NeiJiangMJAnimationComponent.CreateOperareEffectExt(MJDefine.MJOperateType.OPERATE_PIAO, function ()
- end, response.isReplay or false);
- if not effect then
- return ;
- end
-
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(PIAO_EFFECT_TAG + viewId);
- effect:setLocalZOrder(1000);
- local visibleSize = cc.Director:getInstance():getVisibleSize();
- if viewId==MJDefine.PlayerViewType.My then
- effect:setPosition(visibleSize.width / 2, visibleSize.height / 2 - 100);
- elseif viewId==MJDefine.PlayerViewType.Left then
- effect:setPosition(visibleSize.width / 2 - 300, visibleSize.height / 2 + 70);
- elseif viewId==MJDefine.PlayerViewType.Right then
- effect:setPosition(visibleSize.width / 2 + 300, visibleSize.height / 2 + 70);
- elseif viewId==MJDefine.PlayerViewType.Top then
- effect:setPosition(visibleSize.width / 2, visibleSize.height / 2 + 250);
- end
- end
- --[[/**
- * 设置飘是否显示
- * @param isVisible 是否显示 true or false
- * @return
- */--]]
- function NeiJiangMJRoomView:setPiaoViewVisible (isVisible)
- if not self.piaoView then
- self.piaoView = MJFramework.MJImport("mj_neijiang.luaScript.Views.Component.neijiangPiaoView"):new();
- self.toolView.ui.Items.toolPanel:addChild(self.piaoView);
- end
- self.piaoView:setVisible(isVisible);
- end
- --[[/**
- * 设置报叫是否显示
- * @param isVisible 是否显示 true or false
- * @return
- */--]]
- function NeiJiangMJRoomView:setBaoJiaoViewVisible (isVisible)
- if not self.baojiaoView then
- self.baojiaoView = MJFramework.MJImport("mj_neijiang.luaScript.Views.Component.neijiangBaoJiaoView"):new();
- self.toolView.ui.Items.toolPanel:addChild(self.baojiaoView);
- end
- self.baojiaoView:setVisible(isVisible);
- end
- --[[/**
- * 听牌按钮事件
- * @param
- * @return
- */--]]
- function NeiJiangMJRoomView:onBtnTingInfoClicked( )
- playBtnEffect()
- if self.ui.Items.Layout_Ting_Tip_Card_Panel:isVisible() then
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(false)
- else
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- end
- end
-
- return NeiJiangMJRoomView
|