|
- 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 hongzhongRoomView = class("hongzhongRoomView", MJRoomView)
-
-
-
- local zhongNiaoTime=1.33
-
-
- function hongzhongRoomView:loadUi()
- local ui = loadUI("hongzhong/res/ui_fangjian/hongzhong_ui_fangjian.ui")
- self.ui = ui
- self:addChild(ui)
-
- if isReviewVersion() then
- self.ui.Items.Layout_3:setVisible(false)
- self.ui.Items.Layout_4:setVisible(false)
- end
- end
-
- function hongzhongRoomView:ctor()
- hongzhongRoomView.super.ctor(self)
- local defaultValue = tostring(loadUserInfo("hongzhong_mj_color")) or "2d"
- if defaultValue == "" then
- defaultValue = "2d"
- saveUserInfo("hongzhong_mj_color", defaultValue)
- end
- self.desktopType = defaultValue
-
- MJDefine.MJConfig = MJDefine.loadMJConfig(self.desktopType)
- end
-
- function hongzhongRoomView:onEnter()
- hongzhongRoomView.super.onEnter(self)
- -- self:test()
- -- self:onGameXiaoJuResponse()
-
- -- self:showPiao()
- self.ui.Items.Text_Rule:setVisible(false)
- self:doSound()
- --记录3D位置
- -- self:init3DPos()
- --初始化详情
- self:initGameRule()
-
- --更换桌布
- self:bindEvent(app , MJDefine.MJEvent.ChangeTableBg , handler(self , self.onChangeTableBg));
- end
-
- function hongzhongRoomView:onExit()
- hongzhongRoomView.super.onExit(self)
- self:cleanCache()
- end
-
- function hongzhongRoomView:cleanCache()
- local preload = package.loaded
- for k, v in pairs(package.loaded or {}) do
- local res1 = string.find( k, "mj.luaScript") or 0
- local res2 = string.find( k, "hongzhong.luaScript") or 0
- if res1 > 0 or res2 > 0 then
- print("cleanCache-------"..k)
- package.loaded[k] = nil
- end
- end
- end
-
- ---
- -- 更新房间基础数据
- -- @return
- --
- function hongzhongRoomView:updateRoomBaseData (...)
- hongzhongRoomView.super.updateRoomBaseData(self, ...)
-
- -- 更新房间号
- local roomInfo = app.room.roomInfo;
- self.ui.Items.Text_roomNum:setText(tostring(roomInfo.nShowTableId));
- end
-
- --更换桌布(同维度)
- function hongzhongRoomView:onChangeTableBg()
- local defaultValue = tonumber(loadUserInfo("hongzhong_mj_desktop_group")) or 2
- local bgData = MJDefine.CHANGE_GAME_BG[defaultValue]
- if self.curDeskType==MJDefine.DesktopType.TwoD or self.curDeskType==MJDefine.DesktopType.TwoDGold then
- self.ui.Items.ImageView_bg:loadTexture(bgData['2d'])
- else
- self.ui.Items.ImageView_bg:loadTexture(bgData['3d'])
- end
- end
-
-
- function hongzhongRoomView:initView()
- hongzhongRoomView.super.initView(self)
-
- if not self.messageView or tolua.isnull(self.messageView) then
- return
- end
-
- --互动表情
- local faceKG = tonumber(loadUserInfo("hongzhongHuDongBiaoQingKG")) or 1--0关 1开
- --屏蔽语音
- local voiceKG = tonumber(loadUserInfo("hongzhongPingBiYuYinKG")) or 1--0关 1开
- self.messageView:setPropEnabled(faceKG == 1)
- self.messageView:setVoiceEnabled(voiceKG == 1)
-
- self.messageView:setBtnFace(nil,"mj_btn_face2.png")
- self.messageView:setBtnVoice(nil,"mj_btn_voice2.png")
- end
-
-
- function hongzhongRoomView:onUserReadyResponse(response)
- hongzhongRoomView.super.onUserReadyResponse(self, response)
- self:updateReady()
-
- local roomInfo = app.room.roomInfo
- local isShow = roomInfo.nGameStartCount <= 0
- local memberInfo = app.room.roomInfo.memberList[app.user.loginInfo.uid]
- if memberInfo then
- self.ui.Items.Button_Ready:getParent():setVisible(memberInfo.nPlayerFlag == 0 and isShow)
- self.ui.Items.Layout_Button:requestDoLayout()
- self.ui.Items.Layout_Button:doLayout()
- end
- end
-
- function hongzhongRoomView: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
-
- --[[
- --初始记录一些位置,切换2D桌面时需要移动一些位置,记录这些需要移动元素的位置
- function hongzhongRoomView:init3DPos()
- --游戏顶部信息
- self.topBgPos = self.ui.Items.ImageView_top_bg:getPosition()
- self.layoutGameInfoPos = self.ui.Items.Layout_GameInfo:getPosition()
- self.layoutRoomInfoPos = self.ui.Items.Layout_RoomInfo:getPosition()
- self.Text_JuShuPos = self.ui.Items.Text_JuShu:getPosition()
- self.Text_TimePos = self.ui.Items.Text_Time:getPosition()
- self.btn_baoJianPos = self.ui.Items.Button_Club:getPosition()
- --菜单按钮
- self.toolMenuBtnPos = self.toolView.ui.Items.Button_Menu:getPosition()
- --菜单展开按钮
- self.toolMenuLayoutPos = self.toolView.ui.Items.Layout_Menu:getPosition()
- --菜单展开按钮背景
- self.toolMenuBgPos = self.toolView.ui.Items.ImageView_menubg:getPosition()
- --聊天语音按钮
- self.messgaeBtnFacePos = self.messageView.ui.Items.Button_Face:getPosition()
-
- self.messgaeBtnVoicePos = self.messageView.ui.Items.Button_Voice:getPosition()
-
- self.playerNodePos = {}
- for i=1,4 do
- if self.playerView.allNodes[i].player then
- self.playerNodePos[i] = self.playerView.allNodes[i].player:getPosition()
- end
- end
- -- self.chatRecordPos = self.messageView.ui.Items.Button_Record:getPosition()
- -- self.chatFacePos = self.messageView.ui.Items.Button_Face:getPosition()
- self.tingPos = self.ui.Items.Layout_Ting_Tip_Card_Panel:getPosition()
- self.gpsPos = self.ui.Items.Button_GPS:getPosition()
- self:changeGameBg()
- self.ui.Items.Button_GPS:setVisible(true)
- end
-
- function hongzhongRoomView:changePosToAdapt2D()
- self.ui.Items.ImageView_top_bg:setVisible(false)
- self.ui.Items.Layout_GameInfo:setPositionY(self.layoutGameInfoPos.y-15)
- self.ui.Items.Layout_RoomInfo:setPositionY(self.layoutRoomInfoPos.y-15)
- --self.ui.Items.Text_JuShu:setPositionX(self.Text_JuShuPos.x+20)
- self.ui.Items.Text_Time:setPosition(cc.p(5,40))
- self.toolView.ui.Items.btnMenu:setPosition(cc.p(self.toolMenuBtnPos.x-10,self.toolMenuBtnPos.y - 10))
- self.toolView.ui.Items.Layout_Menu:setPosition(cc.p(self.toolMenuLayoutPos.x-10,self.toolMenuLayoutPos.y+10))
- self.ui.Items.Button_Club:setPosition(cc.p(self.btn_baoJianPos.x-10,self.btn_baoJianPos.y + 25))
- self.toolView.ui.Items.ImageView_menubg:setPosition(cc.p(self.toolMenuBgPos.x+10,self.toolMenuBgPos.y+15))
-
- self.messageView.ui.Items.Button_Voice:setPosition(cc.p(self.messgaeBtnVoicePos.x - 5,self.messgaeBtnVoicePos.y - 20))
- self.messageView.ui.Items.Button_Face:setPosition(cc.p(self.messgaeBtnFacePos.x - 5,self.messgaeBtnFacePos.y - 20))
- self.playerView.allNodes[1].player:setPositionX(self.playerNodePos[1].x-8)
- self.playerView.allNodes[2].player:setPositionY(self.playerNodePos[2].y-7)
- self.playerView.allNodes[3].player:setPositionX(self.playerNodePos[3].x+8)
- self.playerView.allNodes[4].player:setPosition(cc.p(self.playerNodePos[4].x+8,self.playerNodePos[4].y+10))
- -- self.messageView.ui.Items.Button_Record:setPositionX(self.chatRecordPos.x-10)
- -- self.messageView.ui.Items.Button_Face:setPositionX(self.chatFacePos.x-10)
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setPositionY(self.tingPos.y+10)
- self.ui.Items.Button_GPS:setPositionY(self.gpsPos.y-2)
- end
-
- function hongzhongRoomView:changePosToAdapt3D()
- self.ui.Items.ImageView_top_bg:setVisible(false)
- self.ui.Items.Layout_GameInfo:setPositionY(self.layoutGameInfoPos.y)
- self.ui.Items.Layout_RoomInfo:setPositionY(self.layoutRoomInfoPos.y)
- self.ui.Items.Text_JuShu:setPositionX(self.Text_JuShuPos.x)
- self.ui.Items.Text_Time:setPosition(self.Text_TimePos)
- self.toolView.ui.Items.btnMenu:setPosition(self.toolMenuBtnPos)
- self.toolView.ui.Items.Layout_Menu:setPosition(self.toolMenuLayoutPos)
-
- self.messageView.ui.Items.Button_Voice:setPosition(cc.p(self.messgaeBtnVoicePos.x ,self.messgaeBtnVoicePos.y - 20))
- self.messageView.ui.Items.Button_Face:setPosition(cc.p(self.messgaeBtnFacePos.x ,self.messgaeBtnFacePos.y - 20))
- self.ui.Items.Button_Club:setPositionY(self.btn_baoJianPos.y + 22)
- self.toolView.ui.Items.ImageView_menubg:setPosition(self.toolMenuBgPos)
- self.playerView.allNodes[1].player:setPositionX(self.playerNodePos[1].x)
- self.playerView.allNodes[2].player:setPositionY(self.playerNodePos[2].y)
- self.playerView.allNodes[3].player:setPositionX(self.playerNodePos[3].x)
- self.playerView.allNodes[4].player:setPosition(self.playerNodePos[4])
- -- self.messageView.ui.Items.Button_Record:setPositionX(self.chatRecordPos.x)
- -- self.messageView.ui.Items.Button_Face:setPositionX(self.chatFacePos.x)
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setPositionY(self.tingPos.y)
- self.ui.Items.Button_GPS:setPositionY(self.gpsPos.y)
- end]]
-
-
- function hongzhongRoomView:updateGameNums()
- -- 更新当前局数
- local roomInfo = app.room.roomInfo
- local curCount = roomInfo.nGameStartCount or 0
- --local str = string.format("牌局:%d/%d", curCount, roomInfo.nTotalGameNum)
- --local str = string.format("牌局: /%02d", roomInfo.nTotalGameNum)
- local str = string.format("牌局: /%02d", roomInfo.nTotalGameNum)
- local str1 = string.format("%02d", curCount)
- self.ui.Items.Text_JuShu:setText(str)
- self.ui.Items.Text_curJuShu:setText(str1)
-
- --更新牌数
- self.ui.Items.Text_CardNum:setText(roomInfo.nLeaveCardNum or 0)
- if curCount>0 then
- self.ui.Items.Layout_GameInfo:setVisible(true)
- else
- self.ui.Items.Layout_GameInfo:setVisible(false)
- end
-
- self:updateInviteButtonState()
- self:updateInviteClubButtonState()
- self:updateReadyButtonState()
- end
-
- function hongzhongRoomView:initGameButton()
- hongzhongRoomView.super.initGameButton(self)
- -- 邀请好友
- self.ui.Items.Button_Invite:registerClick(handler(self , self.onClickFriends2))
- -- 准备
- self.ui.Items.Button_Ready:registerClick(handler(self , self.onClickReady))
- -- 亲友圈邀请
- self.ui.Items.Button_Invite_Club:registerClick(handler(self , self.onClickInviteClub))
- -- 包间
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- self.ui.Items.Button_Club:setVisible(true)
- --切换回俱乐部
- self.ui.Items.Button_Club:registerClick(handler(self, self.onClickBaoJian))
- else
- self.ui.Items.Button_Club:setVisible(false)
- end
- end
-
- function hongzhongRoomView:doSound()--1 普通话 2 长沙话
- local defaultValue = tonumber(loadUserInfo("hongzhong_mj_sound")) or 1
- saveUserInfo("hongzhong_mj_sound", defaultValue)
- MJSound.setSoundType(defaultValue)
- end
-
- function hongzhongRoomView:loadTextureCache()
- hongzhongRoomView.super.loadTextureCache(self)
- loadSpriteFrameFile("hongzhong/res/zy_fangjian/hl_old_mj.plist")
- loadSpriteFrameFile("hongzhong/res/zy_fangjian/hl_old_mj_2d.plist")
- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("hongzhong/res/zy_fangjian/mj_piao_fen.plist")
- end
-
-
- function hongzhongRoomView:bindExtendMessage()
- --下飘
- self:bindEvent(app.room , MJDefine.MJEvent.XiaPiaoTime , handler(self , self.onXiaPiaoTime))
- self:bindEvent(app.room , MJDefine.MJEvent.XiaPiaoResponse , handler(self , self.onXiaPiaoResponse))
-
- -- 玩家请求快速开始广播
- self:bindEvent(app.room, MJDefine.MJEvent.BraodcastFastStart, handler(self, self.onBroadcastFaststart))
- -- 快速开始成功
- self:bindEvent(app.room, MJDefine.MJEvent.FastStartSucc, handler(self, self.onFastStartSucc))
- -- 托管
- self:bindEvent(app.room , MJDefine.MJEvent.HostingRequest, handler(self, self.onHostingRequest))
- -- user pass
- self:bindEvent(app.room , MJDefine.MJEvent.USER_PASS, handler(self, self.onUserPassRequest))
-
- --设置互动表情开关事件
- self:bindEvent(app.room,"ontSetPropEnabled" , handler(self , self.ontSetPropEnabled));
- --设置语音开关事件
- self:bindEvent(app.room,"onSetVoiceEnabled" , handler(self , self.onSetVoiceEnabled));
- --切换视图
- self:bindEvent(app, MJDefine.MJEvent.ChangeViewType, handler(self, self.onChangeViewType))
- end
-
-
- function hongzhongRoomView:onChangeViewType(event)
- hongzhongRoomView.super.onChangeViewType(self,event)
-
- self:loadTextureCache()
- MJDefine.MJConfig = MJDefine.loadMJConfig(self.desktopType)
- self:changeGameBg(true)
- self.ui:sendMsg(app.room, MJDefine.MJEvent.GetTableInfo)
- end
-
-
- function hongzhongRoomView:ontSetPropEnabled(event)
- -- local idx = event.value
- if self.messageView then
- self.messageView:setPropEnabled(event.value == 1)
- end
- end
-
- function hongzhongRoomView:onSetVoiceEnabled(event)
- -- local idx = event.value
- if self.messageView then
- self.messageView:setVoiceEnabled(event.value == 1)
- end
- end
-
- function hongzhongRoomView:onXiaPiaoTime(event)
- local roomInfo=app.room.roomInfo
- local t=roomInfo.nPiaoLeftTime
- self.direcionView:updateDirection(roomInfo.memberList[app.room:getMyUserId()].nSeatId)
- self.direcionView:runShotTime(MJDefine.MyViewId,t)
- self:showPiao()
- --倒计时
- -- self.ui.Items.Text_Time:setString(string.format("%02d",t))
- -- self:stopAllActions()
- -- self:runAction(cc.RepeatForever:create(
- -- cc.Sequence:create(
- -- cc.DelayTime:create(1),
- -- cc.CallFunc:create(function()
- -- t=t-1
- -- if t<0 then
- -- t=0
- -- self:hidePiao()
- -- self:stopAllActions()
- -- end
- -- -- self.ui.Items.Text_Time:setString(string.format("%02d",t))
- -- end)
- -- )
- -- ))
- end
-
- function hongzhongRoomView:onXiaPiaoResponse(event)
- local nUserId=event.nUserId
- if nUserId==app.room:getMyUserId() then
- self:hidePiao()
- end
- -- self:updatePiao()
- local roomInfo=app.room.roomInfo
- local memberList=roomInfo.memberList
- for k,v in pairs(memberList) do
- if v.nPiaoNum then
- local viewId = app.room:getViewIdByUserId(k)
- logD("hongzhongRoomView:onXiaPiaoResponse: viewId="..viewId.." nPiaoNum="..v.nPiaoNum)
- self:updatePiao(viewId,v.nPiaoNum)
- end
- end
- end
-
-
- function hongzhongRoomView: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 hongzhongRoomView:showPiao()
- local roomInfo=app.room.roomInfo
- local gameInfo=json.decode(roomInfo.strGameInfo)
-
- if not gameInfo.piaotype or tonumber(gameInfo.piaotype)==0 then return end
-
- --飘风分数
- local piaoFen={
- 1,2,3,5
- -- [0] = {},
- -- [2]={1,2,3},
- -- [3]={2,3,5},
- }
-
- self:hidePiao()
- local ui=loadUI("hongzhong/res/ui_fangjian/hongzhong_ui_piao.ui")
- self:addChild(ui)
- self.piao=ui
-
- ui.Items.Button_BuPiao:registerClick(function()
- playBtnEffect()
- self:hidePiao()
- local request = MJMessage.XiaPiao:new()
- request.nPiaoNum = 0
- self.ui:sendMsg(app.room,MJDefine.MJEvent.XiaPiao,request)
- end)
-
- for i=1,4 do
- -- local piaoNum=
- ui.Items["Button_Piao_"..i]:registerClick(function()
- playBtnEffect()
- self:hidePiao()
- local request = MJMessage.XiaPiao:new()
- request.nPiaoNum = piaoFen[i]
- logD("nPiaoNum="..request.nPiaoNum)
- self.ui:sendMsg(app.room,MJDefine.MJEvent.XiaPiao,request)
- end)
- end
- end
-
- function hongzhongRoomView:hidePiao()
- if self.piao then
- self.piao:removeFromParent()
- self.piao=nil
- end
- end
-
- function hongzhongRoomView:updatePiao(viewId,piaoNum)
-
- local roomInfo=app.room.roomInfo
- local gameInfo=json.decode(roomInfo.strGameInfo)
- if not gameInfo.piaotype or tonumber(gameInfo.piaotype)==0 then return end
- if not piaoNum or piaoNum==-1 then return end
-
- local head=self.playerView:getHead(viewId)
-
- if not head.piao then
- local piao = cc.Sprite:createWithSpriteFrameName("mj_img_piao_fen_flag.png")
- head:addChild(piao)
- piao:setPosition(25,41)
- head.piao=piao
-
- local labNum = cc.Text:createNode()
- labNum:setDefaults()
- local config = labNum:getFontConfig()
- config.fontSize = 18
- config.texColor = cc.c4b(254,247,183,255)
- config.outlineSize = 1
- config.effectColor = cc.c4b(64,42,172,255)
- labNum:setFontConfig(config)
- piao:addChild(labNum)
- labNum:setAnchorPoint(cc.p(0.5,0.5))
- labNum:setPosition(cc.p(20,42))
- -- labNum:setString("飘 "..piaoNum)
- labNum:setRotation(7.1)
- head.piaoNum=labNum
- end
- if piaoNum==0 then
- head.piaoNum:setString("不飘")
- else
- head.piaoNum:setString("飘 "..piaoNum)
- end
- -- head.piao:loadTexture("3d/mj_dir_3d_2_down.png",cc.TextureResType.plistType)
- end
-
- --中鸟展示
- function hongzhongRoomView:showZhongNiaoView(cards,viewIds,callback)
- local ui=loadUI("mj/res/ui/ui_animation/mj_zhong_niao.ui")
- self:addChild(ui)
-
-
-
- ui.Items.Layout_Content:setSize(cc.size(#cards*100,ui.Items.Layout_Content:getContentSize().height))
- -- ui.Items.Layout_Content:requestDoLayout()
- -- ui.Items.Layout_Content:doLayout()
-
- local scale=0.7
- local pad=10
- local mjWidth=87*scale
- local x=(ui.Items.Layout_Content:getContentSize().width-#cards*(mjWidth+pad))/2+mjWidth/2
-
-
- for k,v in pairs(cards) do
-
- local light=cc.Sprite:createWithSpriteFrameName("bird/mj_animation_bird_bg_light.png")
- ui.Items.Layout_Content:addChild(light)
- light:setPosition(x,ui.Items.Layout_Content:getContentSize().height/2)
- light:runAction(cc.RotateTo:create(zhongNiaoTime,30))
- light:setScale(1.2)
-
-
- local mj=MJ:new(v,MJDefine.MJType.Stand,MJDefine.MyViewId,self.desktopType)
- mj:setScale(scale)
- ui.Items.Layout_Content:addChild(mj,1)
- mj:setPosition(x,ui.Items.Layout_Content:getContentSize().height/2)
- x=x+mjWidth+pad
-
-
- end
-
- ui.Items.Layout_Content:playClip("start",function()
- if callback then
- callback()
- end
- ui:removeFromParent()
- end)
-
-
-
- local head=self.playerView:getHead(viewIds[1])
- local pos=head:getPosition()
- pos=head:convertToWorldSpace(pos)
- if pos.x<640 then
- ui:setPosition(cc.p(pos.x+ui.Items.Layout_Content:getContentSize().width/2+50,pos.y-40))
- else
- ui:setPosition(cc.p(pos.x-ui.Items.Layout_Content:getContentSize().width/2-50,pos.y-40))
- end
-
- end
-
- --鸟飞行动画
- function hongzhongRoomView:showNiaoAniamtion(viewIds,callback)
- local size = self:getContentSize()
- local bird=cc.Sprite:createWithSpriteFrameName("bird/mj_animation_bird.png")
- bird:setPosition(size.width / 2,size.height / 2)
- self:addChild(bird)
-
- local head=self.playerView:getHead(viewIds[1])
-
-
- local function showLight()
- local light=cc.Sprite:createWithSpriteFrameName("bird/mj_animation_bird_head_light.png")
- head:addChild(light)
- light:setPosition(head:getContentSize().width/2,head:getContentSize().height/2)
-
- light:runAction(cc.Sequence:create(
- cc.DelayTime:create(zhongNiaoTime),
- -- cc.CallFunc:create(function()
- -- if callback then callback() end
- -- end),
- cc.RemoveSelf:create()
- ))
- end
-
-
- local pos=head:getPosition()
- pos=head:convertToWorldSpace(pos)
-
- if pos.x<bird:getPositionX() then
- bird:setFlippedX(true)
- end
-
-
- local actions={
- cc.MoveTo:create(0.5,pos),
- cc.CallFunc:create(function()
- showLight()
- -- self:showZhongNiaoView()
- if callback then callback() end
- end),
- cc.RemoveSelf:create(),
-
- }
- bird:runAction(cc.Sequence:create(actions))
-
- end
-
- --抓鸟展示
- function hongzhongRoomView:showNiaoView(cards,callback)
- MJSound.PlayZhaNiao()
- local ui=loadUI("mj/res/ui/ui_animation/mj_niao.ui")
- self:addChild(ui)
- local size = self:getContentSize()
- ui:setPosition(size.width / 2,size.height / 2)
-
- local mjWidth=87
- local pad=5
- local x=(ui.Items.Layout_Content:getContentSize().width-#cards*(mjWidth+pad))/2+mjWidth/2
-
- for k,v in pairs(cards) do
- local mj=MJ:new(v,MJDefine.MJType.Stand,MJDefine.MyViewId,self.desktopType)
- ui.Items.Layout_Content:addChild(mj)
- mj:setPosition(x,ui.Items.Layout_Content:getContentSize().height/2)
- x=x+mjWidth+pad
- end
-
-
-
- ui.Items.Layout_Content:playClip("start",function()
- if callback then
- callback()
- end
- ui:removeFromParent()
- end)
- end
-
-
-
- function hongzhongRoomView:onGameReconnection()
- hongzhongRoomView.super.onGameReconnection(self)
-
- local roomInfo = app.room.roomInfo
-
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- self:updatePiao(viewId,v.nPiaoNum)
-
- local extInfo = roomInfo.extJson or ""
- if extInfo and type(extInfo)=='table' and extInfo[tostring(v.nUserId)] then
- local info = extInfo[tostring(v.nUserId)]
- local host = info.hosted or 0--托管状态
- local isTuoGuan = host == 1;
- self.playerView:showTuoGuanByViewId(viewId,isTuoGuan)
- end
- end
-
- -- 游戏开始后才有
- if roomInfo.nStatus and roomInfo.nStatus>=MJDefine.GameStatus.GAME_STATUS_WAIT_BANKER_START and roomInfo.nStatus<MJDefine.GameStatus.GAME_STATUS_GAME_OVER then
- self.toolView:showTuoGuan(app.room.roomInfo.hosting == 1)
- self.toolView:showFastStart(false)
- else
- --self.toolView:enableHosting(false)
- local quickStartInfo = app.room.roomInfo.quickStartInfo
- if quickStartInfo then
- if quickStartInfo.tablefaststate == true then
- local tmpInfo = {}
- for uid,status in pairs(quickStartInfo.list) do
- table.insert(tmpInfo, {nUserId=tonumber(uid), nStatus = status})
- end
- local response = {}
- response.pList = tmpInfo
- response.timeOut = app.room.roomInfo.quickStartInfo.time
- self:onBroadcastFaststart({response=response})
- else
- self.toolView:showFastStart(true)
- end
- else
- self.toolView:showFastStart(true)
- end
- end
-
-
- if roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_ROUND_OVER or roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_GAME_OVER then
- local resultInfo=json.decode(roomInfo.strResultInfo)
- --所有胡牌的人 考虑抢杠胡的问题
- local viewIds={}
- local failViewId=0
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if v.result==MJDefine.MJGameResultType.Win then
- table.insert(viewIds,viewId)
- elseif v.result==MJDefine.MJGameResultType.Fail then
- failViewId=viewId
- end
- end
-
- local zhaniaocards=string.ltrim(resultInfo.zhaniaocards)
- local tabZhaniaocards=string.split(zhaniaocards," ")
- if resultInfo.zhaniaocards=="" then
- tabZhaniaocards={}
- end
-
- self:outNiaoCards(viewIds,failViewId,tabZhaniaocards)
- end
- end
-
-
- -- 小局结算
- function hongzhongRoomView:onGameXiaoJuResponse(data)
- local function runGameXiaoJuResponse(onEnd)
- local roomInfo = app.room.roomInfo
- local resultInfo=json.decode(roomInfo.strResultInfo)
-
-
- self.direcionView:stopAllActions()
-
- --如果是解散直接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==MJDefine.MJGameResultType.Win then
- table.insert(viewIds,viewId)
- --播放音效
- if viewId==MJDefine.MyViewId then
- MJSound.PlayWinGame()
- end
- elseif v.result==MJDefine.MJGameResultType.Fail then
- failViewId=viewId
- if viewId==MJDefine.MyViewId then
- MJSound.PlayLoseGame()
- end
- end
- end
-
- self:showOpenCard()
-
- if app.room.roomInfo.hosting then
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- end
-
- --被抢杠的人回退补杠
- if resultInfo.hutype==MJDefine.MJHuType.QiangGangHu and roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_NORMAL then
- self.playerHandCards[failViewId]:retoreBuGang(resultInfo.hucard)
- end
-
-
- -- local zhaniaocards=string.ltrim(resultInfo.zhaniaocards)
- local tabZhaniaocards=MJFunction.convertToCards(resultInfo.zhaniaocards)--string.split(zhaniaocards," ")
- -- if resultInfo.zhaniaocards=="" then
- -- tabZhaniaocards={}
- -- end
-
-
- -- local zhongniaocards=string.ltrim(resultInfo.zhongniaocards)
- local tabZhongniaocards=MJFunction.convertToCards(resultInfo.zhongniaocards)--string.split(zhongniaocards," ")
- -- if resultInfo.zhongniaocards=="" then --and #tabZhongniaocards>0 then
- -- tabZhongniaocards={}
- -- end
-
- self:outNiaoCards(viewIds,failViewId,tabZhaniaocards)
-
- local function callback()
- self:showXiaoJuView()
- if onEnd then
- onEnd()
- end
- end
-
- local function zhongNiao()
- self:showZhongNiaoView(tabZhongniaocards,viewIds,callback)
- end
-
- local function niaoFly()
- if #tabZhongniaocards>0 then
- self:showNiaoAniamtion(viewIds,zhongNiao)
- else
- callback()
- end
- end
-
- local function niaoCallBack()
- if #tabZhaniaocards>0 then
- self:showNiaoView(tabZhaniaocards,niaoFly)
- else
- callback()
- end
- end
-
- if #viewIds>0 then
- for k,viewId in pairs(viewIds) do
- local effect
- if k == #viewIds then --只有最后播放胡牌动画的回调一次就可以了
- effect=MJAnimationCompnent.CreateHuEffect(niaoCallBack)
-
- local userInfo=app.room:getUserInfoByViewId(viewId)
- if userInfo then
- --音效
- local resultInfo=json.decode(roomInfo.strResultInfo)
- if resultInfo.hutype==MJDefine.MJHuType.Zimo then --1为自摸
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_ZIMOHU)
- else
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_DIANPAOHU)
- end
- end
- else
- effect=MJAnimationCompnent.CreateHuEffect()
- end
- if effect then
- self:addChild(effect)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- else
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- local effect=MJAnimationCompnent.CreateLiuJuEffect(callback)
- self:addChild(effect)
- MJSound.PlayHuangZhuang()
- else
- callback()
- end
- end
-
- end
- -- runGameXiaoJuResponse()
- log("2000000000-hongzhongRoomView - addCallBack(runGameXiaoJuResponse)" )
- self:addCallBack(runGameXiaoJuResponse);
- end
-
-
- function hongzhongRoomView:outNiaoCards(viewIds,failViewId,niaoCards)
- if #niaoCards==0 then return end
- --把鸟牌放入出牌区域
- local outNiaoCards={}
- for k,v in pairs(niaoCards) do
- table.insert(outNiaoCards,{card=v})
- end
- local outCards={}
- if #viewIds>1 then
- if self.playerHandCards[failViewId] then
- self.playerHandCards[failViewId]:createOutCards(outNiaoCards)
- outCards=self.playerHandCards[failViewId].outCards
- end
- elseif #viewIds==1 then
- local viewId=viewIds[1]
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:createOutCards(outNiaoCards)
- outCards=self.playerHandCards[viewId].outCards
- end
- end
-
-
- for i=#outCards,#outCards-#outNiaoCards+1,-1 do
- if outCards[i] then
- outCards[i]:setStatus(MJDefine.MJStatus.Disable)
- end
- end
- end
-
-
- function hongzhongRoomView:onFastStartSucc( data )
- if self._fastRequestView and not tolua.isnull(self._fastRequestView) then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
- self.toolView:showFastStart(false)
- self.playerView:setPlayerVisible(false)
- self:updateRoomBaseData()
- end
-
- -- 服务器广播快速开始
- function hongzhongRoomView:onBroadcastFaststart( data )
- local response = data.response
- local remove = false
- if response.nUserId and response.nStatus then
- if response.nStatus == 3 or response.nStatus>4 then
- remove = true
- end
- end
- if not remove then
- for _,v in ipairs(response.pList) do
- if v.nStatus == 3 or v.nStatus>4 then
- remove = true
- end
- end
- end
- if response.timeOut <=0 then remove = true end
-
- if self._fastRequestView == nil then
- if remove then return "" end
- local requesterId = 0
- for _,v in ipairs(response.pList) do
- if v.nStatus == 1 then
- requesterId = v.nUserId
- end
- end
- if requesterId<=0 then return "" end
- local view = import("hongzhong.luaScript.Views.Room.hongzhongRequestStartView"):new(requesterId)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- view:showItems(response)
- app:showWaitDialog(view)
- self._fastRequestView = view
- else
- if remove then
- local userInfo = app.room.roomInfo.memberList[response.nUserId]
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- if userInfo then
- local u = json.decode(userInfo.userInfo)
- local txt = string.format("玩家【%s】拒绝立即开局", u.nickname)
- showTooltip(txt)
- end
- app.room:resetFastInfo()
- self.toolView:showFastStart(true)
- else
- self._fastRequestView:updateView(response)
- end
- end
- end
-
- function hongzhongRoomView:onOtherSitDownResponse( data )
- hongzhongRoomView.super.onOtherSitDownResponse(self, data)
- -- fast start
- self.toolView:showFastStart(true)
-
- self:updateInviteButtonState()
- self:updateInviteClubButtonState()
- end
-
- function hongzhongRoomView:onOtherLogoutResponse(data)
- hongzhongRoomView.super.onOtherLogoutResponse(self, data)
- local function showFastStart( onEnd )
- -- fast start
- self.toolView:showFastStart(true)
-
- self:updateInviteButtonState()
- self:updateInviteClubButtonState()
-
- if not tolua.isnull(self._fastRequestView) then
- self._fastRequestView:removeFromParent()
- self._fastRequestView = nil
- end
-
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addCallBack(showFastStart)
- end
-
- function hongzhongRoomView:onHostingRequest( data )
- local response = data.response
- if app.room:isMyself(response.nUserId) then
- if response.status == 1 then --托管状态
- self.toolView:showTuoGuan(true)
- if not tolua.isnull(self.firstTingTipsView) then
- self.firstTingTipsView:killSelf()
- self.firstTingTipsView = nil
- end
- elseif response.status == 0 then--取消托管状态
- self.toolView:showTuoGuan(false)
- end
- end
- local isTuoGuan = response.status == 1;
- local viewId = app.room:getViewIdByUserId(response.nUserId)
- self.playerView:showTuoGuanByViewId(viewId,isTuoGuan)
- end
-
- -- 发牌
- function hongzhongRoomView:onGameSendCardResponse()
- hongzhongRoomView.super.onGameSendCardResponse(self)
- local function showHosting( onEnd )
- self.toolView:showTuoGuan(app.room.roomInfo.hosting==1)
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addCallBack(showHosting)
- end
-
- function hongzhongRoomView:onUserPassRequest( data )
- local response = data.response
- if app.room:isMyself(response.nUserId) then
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- end
- end
-
- --更换背景
- function hongzhongRoomView:changeGameBg()
- local defaultValue = tonumber(loadUserInfo("hongzhong_mj_desktop_group")) or 1
- local bgData = MJDefine.CHANGE_GAME_BG[defaultValue]
- --更换2D桌面
- if self.desktopType==MJDefine.DesktopType.TwoD or self.desktopType==MJDefine.DesktopType.TwoDGold then
- self.ui.Items.ImageView_bg:loadTexture(bgData['2d'])
- --[[
- if self.topBgPos then
- self:changePosToAdapt2D()
- end
- ]]
- else
- self.ui.Items.ImageView_bg:loadTexture(bgData['3d'])
- --[[
- if self.topBgPos then
- self:changePosToAdapt3D()
- end
- ]]
- end
- --记录当前的桌布类型(2d/3d)
- self.curDeskType = self.desktopType
- end
-
- --显示查听的牌
- function hongzhongRoomView:setChaTingCardViewVisible(bVisible,tingCards)
- end
-
- function hongzhongRoomView: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")
- -- self:setChaTingCardViewVisible(true)
- -- self:setTingCardViewVisible(true, )
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- else
- print("---------onTingCardStatus-----------0")
- -- self:setChaTingCardViewVisible(false)
- self:setTingCardViewVisible(false)
- end
- end
- end
-
- function hongzhongRoomView:onTingCardResult(data)
- if data.response.tingType==MJDefine.MJTingType.QuanTing then
- else
- self:setTingCardViewVisible(true, data.response.tingCards)
- end
- end
-
- function hongzhongRoomView: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
- end
-
- function hongzhongRoomView:onClickBaoJian()
- playBtnEffect()
- openClub();
- end
-
- function hongzhongRoomView:initGameRule()
- self.xiangQingView = loadUI("mj/res/ui/ui_fangjian/mj_fangjian_xiangqing2.ui")
- self:addChild(self.xiangQingView)
- self.xiangQingView.Items.Button_XiangQing:setVisible(false)
-
- --[[--先摆放初始化位置
- local pos = self.xiangQingView.Items.Layout_XQ_content:getPosition()
- self.xiangQingView.Items.Layout_XQ_content:setPosition(cc.p(pos.x + 27, pos.y + 26))
-
- --记录当前所在位置
- self.xqContentPos = self.xiangQingView.Items.Layout_XQ_content:getPosition()
-
- --记录玩法详情框大小
- self.xqContentSize = self.xiangQingView.Items.Layout_XQ_content:getContentSize()
-
- --移动至指定位置
- self.xiangQingView.Items.Button_XiangQing:runAction(cc.MoveTo:create(0, cc.p(250, 702)))
-
- --顺时针旋转90度
- self.xiangQingView.Items.Button_XiangQing:setEulerRotation(cc.vec3(180,180,90))
-
-
-
- --逆时针旋转90度
- self.xiangQingView.Items.Button_XiangQing_Back:setEulerRotation(cc.vec3(-180,-180,-270))--]]
-
- self.xiangQingView.Items.Layout_XiangQing:registerClick(handler(self , self.hideXiangQing))
- self.xiangQingView.Items.Layout_XiangQing:setVisible(true)
-
- self.xiangQingView.Items.Layout_XQ_content:registerClick(handler(self , self.hideXiangQing))
-
- self.xiangQingView.Items.Button_XiangQing_Back:registerClick(handler(self , self.hideXiangQing))
-
- self.xiangQingView.Items.Button_XiangQing:registerClick(handler(self, self.showXiangQing))
-
- self.xiangQingView.Items.ListView_Xq:getVBar():setVisible(false)
-
- local listviewSize = self.xiangQingView.Items.ListView_Xq:getContentSize()
-
- local roomInfo = app.room.roomInfo
- local ruleAll = MJWanFa.getWanFaInfo(roomInfo.strGameInfo)
- local wanfaList = string.split(ruleAll," ")
- for i,v in pairs(wanfaList) do
- if v ~= "" then
- local layout=cc.Layout:create()
- local wanfaText = cc.Text:createNode()
- wanfaText:setDefaults()
- local config = wanfaText:getFontConfig()
- config.fontSize = 24
- config.texColor = cc.c4b(255,192,101,255)
- wanfaText:setFontConfig(config)
- layout:setSize(cc.size(listviewSize.width,35))
- layout:addChild(wanfaText)
- wanfaText:setPosition(cc.p(listviewSize.width/2,15))
- wanfaText:setString(v)
- self.xiangQingView.Items.ListView_Xq:pushBackCustomItem(layout)
- end
- end
-
- if app.room.roomInfo.nGameStartCount > 0 or (not self:getIsNeedShowRule()) then
- --self.xiangQingView.Items.Layout_XQ_content:setPositionY(self.xqContentPos.y + self.xqContentSize.height + 47)
- self.xiangQingView.Items.Layout_XQ_content:setVisible(false)
-
- self.xiangQingView.Items.Button_XiangQing:setVisible(true)
-
- self.xiangQingView.Items.Layout_XiangQing:setVisible(false)
-
- self.xiangQingView.Items.ListView_Xq:setVisible(false)
- end
- end
-
- function hongzhongRoomView:showXiangQing()
- playBtnEffect()
-
- self.xiangQingView.Items.Button_XiangQing:setVisible(false)
-
- self.xiangQingView.Items.Layout_XiangQing:setVisible(true)
- self.xiangQingView.Items.ListView_Xq:setVisible(true)
- self.xiangQingView.Items.Layout_XQ_content:setVisible(true)
-
- --[[--执行动画时,先停止当前所有动画
- self.xiangQingView.Items.Layout_XQ_content:stopAllActions()
-
- --显示时,直接移动到初始化位置
- local action = cc.Sequence:create(
- cc.MoveTo:create(0.4 , cc.p(self.xqContentPos.x, self.xqContentPos.y)),
- cc.CallFunc:create(function()
- self.xiangQingView.Items.Layout_XiangQing:setVisible(true)
- self.xiangQingView.Items.ListView_Xq:setVisible(true)
- end)
- )
-
- self.xiangQingView.Items.Layout_XQ_content:runAction(action)--]]
- end
-
- function hongzhongRoomView:hideXiangQing()
- self.xiangQingView.Items.Layout_XiangQing:setVisible(false)
- self.xiangQingView.Items.Layout_XQ_content:setVisible(false)
- self.xiangQingView.Items.Button_XiangQing:setVisible(true)
-
- --[[self.xiangQingView.Items.Layout_XQ_content:stopAllActions()
-
- --隐藏时,在初始位置基础上加上整个layout的高度,再加上从layout顶部到屏幕边缘线位置,一般为固定值
- local movePosY = self.xqContentPos.y + (self.xqContentSize.height + 47)
-
- local action = cc.Sequence:create(
- cc.CallFunc:create(function ()
- self.xiangQingView.Items.ListView_Xq:setVisible(false)
- end),
- cc.MoveTo:create(0.4 , cc.p(self.xqContentPos.x, movePosY)),
- cc.CallFunc:create(function()
- self.xiangQingView.Items.Button_XiangQing:setVisible(true)
- end)
- )
-
- self.xiangQingView.Items.Layout_XQ_content:runAction(action)--]]
- end
-
- ---
- -- 刷新邀请按钮状态
- --
- function hongzhongRoomView:updateInviteButtonState()
- local roomInfo = app.room.roomInfo
- local curMemberNum = table.nums(roomInfo.memberList)
- --没有坐满
- local isNotSitFull = curMemberNum < roomInfo.nMaxPlayCount
- --更新邀请按钮
- self.ui.Items.Button_Invite:getParent():setVisible(isNotSitFull)
-
- if isReviewVersion() then
- self.ui.Items.Button_Invite:getParent():setVisible(false)
- end
-
- if self.ui.Items.Layout_Button then
- self.ui.Items.Layout_Button:requestDoLayout()
- self.ui.Items.Layout_Button:doLayout()
- end
- end
- ---
- -- 刷新亲友圈按钮状态
- --
- function hongzhongRoomView:updateInviteClubButtonState()
- local roomInfo = app.room.roomInfo
- local isShow = roomInfo.nGameStartCount <= 0 and app.club_php.clubID and app.club_php.clubID ~= 0
-
- if not self.ui.Items.Button_Invite_Club then
- return
- end
-
- self.ui.Items.Button_Invite_Club:getParent():setVisible(isShow)
-
- if isShow then
- -- 如果当前显示,则判断人数满了没有,满了则不再显示
- local curMemberNum = table.nums(roomInfo.memberList)
- --没有坐满
- local isNotSitFull = curMemberNum < roomInfo.nMaxPlayCount
- --更新邀请按钮
- self.ui.Items.Button_Invite_Club:getParent():setVisible(isNotSitFull)
- end
-
- local roomInfo = app.room.roomInfo or {}
- local gameId = roomInfo.gameId or app.gameId
- local gameConfig = getSubGameConfig(gameId)
- if gameConfig.isOpenClubInvite == false then
- self.ui.Items.Button_Invite_Club:getParent():setVisible(false)
- end
-
- if isReviewVersion() then
- self.ui.Items.Button_Invite_Club:getParent():setVisible(false)
- end
-
- if self.ui.Items.Layout_Button then
- self.ui.Items.Layout_Button:requestDoLayout()
- self.ui.Items.Layout_Button:doLayout()
- end
- end
- ---
- -- 刷新按钮状态
- --
- function hongzhongRoomView:updateReadyButtonState()
- local roomInfo = app.room.roomInfo
- local isShow = roomInfo.nGameStartCount <= 0
- self.ui.Items.Button_Ready:getParent():setVisible(isShow)
-
- if self.ui.Items.Layout_Button then
- self.ui.Items.Layout_Button:requestDoLayout()
- self.ui.Items.Layout_Button:doLayout()
- end
- end
-
- function hongzhongRoomView:initChatView()
-
- end
-
- --出牌成功
- function hongzhongRoomView:onOutCardSuccess(data)
- local function runOnOutCardSuccess(onEnd)
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local card= data.response.card
- local operates=data.response.operates
-
- local function callback()
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
-
- if viewId == MJDefine.MyViewId then
- if app.room.roomInfo.hosting == 1 then
- self.playerHandCards[viewId]:setTing(false)
- end
- end
-
- if onEnd then
- onEnd()
- end
- end
-
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:onOutCard(card,callback)--onOutCard(data.response,true)
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value=card ,viewId=viewId})
- else
- callback()
- end
- end
-
- log("2000000000-hongzhongRoomView - addCallBack(runOnOutCardSuccess)")
- self:addCallBack(runOnOutCardSuccess)
- end
-
- -- 本家出牌时不会收到出牌成功的,置灰收到弃牌。所以如果收到此消息时,当前手牌还是保持可出状态,说明出牌的时候导致了问题,需要重新删牌
- function hongzhongRoomView:onOutCard(data)
- local function runOnOutCard(onEnd)
- logE("hongzhongRoomView:runOnOutCard(), response = ", table.tostring(data.response))
- log("2000000000-hongzhongRoomView - runOnOutCard")
-
- -- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- -- local card= data.response.card
- -- if self.playerHandCards[viewId] then
- -- self.playerHandCards[viewId]:createOutCards(card)
- -- end
-
- local data = data.response
- if data.nUserId == app.room:getMyUserId() then
- local myCardLength = self.playerHandCards[MJDefine.MyViewId]:getHandCardsNum()
- if self.needDeleteOutCard or myCardLength % 3 == 2 then
- print('self.needDeleteOutCard', self.needDeleteOutCard)
- print('myCardLength', myCardLength)
- logD(string.format("hongzhongRoomView:onOutCard 手牌有问题,当前长度是 %s, 需要出的牌是%s ", myCardLength, data.card))
- self.playerHandCards[MJDefine.MyViewId]:onOutCard(data.card)
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg,value=data.card,viewId=MJDefine.MyViewId})
- end
- end
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-hongzhongRoomView - addCallBack(runOnOutCard)")
- self:addCallBack(runOnOutCard)
- end
-
- return hongzhongRoomView
|