|
- local RoomView = class("luzhouguiRoomView_Coin", require("mj_luzhougui.luaScript.Views.Room.luzhouguiRoomView"))
-
- 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_luzhougui.luaScript.Coin.luzhouguiHandCardView_Coin")
- local MJRoomXiaoJuView=MJFramework.MJImport("mj_luzhougui.luaScript.Coin.luzhouguiRoomXiaoJuView_Coin")
- 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 CoinFunctions = import("luaScript.Views.Coin.Util.CoinFunctions")
- local CoinData = import("luaScript.Views.Coin.Data.CoinData")
- local CoinGameLogic = import("luaScript.Views.Coin.CoinGameLogic")
-
- function RoomView:ctor()
- RoomView.super.ctor(self)
-
- --监听礼券数据
- self:bindEvent(app.hall, "couponsAdd" , handler(self, self.changeLiquan))
- --获取礼券数量和所需局数
- self:bindEvent(app, "getLiquanNumSuccess" , handler(self, self.LiquanNum))
- --兑换成功
- self:bindEvent(app.phpShop , "exchangeCoinSuccess" , handler(self , self.onDuiHuanCoin))
- --开局后后台推送的信息
- self:bindEvent(app.room , "onGameInfoChange" , handler(self , self.onGameInfoChange))
- -- 托管
- self:bindEvent(app.room , MJDefine.MJEvent.HostingRequest, handler(self, self.onHostingRequest))
- end
-
- function RoomView:onEnter()
- RoomView.super.onEnter(self)
-
- if not tolua.isnull(self.xiangQingView) then
- self.xiangQingView:removeFromParent()
- self.xiangQingView = nil
- end
- end
-
- function RoomView:loadUi()
- RoomView.super.loadUi(self)
-
- end
-
- function RoomView:initToolView()
- RoomView.super.initToolView(self)
-
-
- end
-
- function RoomView:initChatView()
- -- 添加语音相关的界面
-
- self.messageView = require("luaScript.Views.CoinRoom.CoinChatView"):new({ chatList = MJDefine.MJChatTxt, faceList = MJDefine.MJFaceConfig }, self.headInfos, true)
- self.coinTool.Items.Layout_1:addChild(self.messageView)
-
- --这里其实没什么用
- --self.messageView:setBtnFace(cc.p(1236,348),"room_room_img_face.png")
- self.messageView:setBtnVoice(cc.p(1236,257),"room_room_img_voice.png")
-
- --捷语按钮
- self.messageView:setBtnFace(cc.p(1236, 237), "mj_btn_face2.png")
- end
-
- function RoomView:onGameInfoChange(data)
- local gameInfo = json.decode(data.response.Datas.gameInfoChange)
- for k,v in pairs(gameInfo) do
- if tonumber(k) == tonumber(app.room:getMyUserId()) then
- app.user.loginInfo.curJingbiNum = tonumber(v.nTotalMoney)
- end
- local memberInfo = app.room.roomInfo.memberList[tonumber(k)]
- if memberInfo then
- memberInfo.nTotalMoney = v.nTotalMoney
- self.playerView:updatePlayerInfo(app.room:getViewIdByUserId(memberInfo.nUserId))
- end
- end
- end
-
- function RoomView:initHandCardNodes()
- --玩家手牌相关
- if MJDefine.MJRoomPlayerSitConfig[app.room.roomInfo.nMaxPlayCount] then
- for k,v in pairs(MJDefine.MJRoomPlayerSitConfig[app.room.roomInfo.nMaxPlayCount]) do
- if self.playerHandCards[v] then
- self.playerHandCards[v]:removeFromParent()
- end
- self.playerHandCards[v] = MJHandCardView:new(v,self.desktopType)
- self.ui.Items.Layout_Player:addChild(self.playerHandCards[v],v)
- end
- end
- end
-
- function RoomView:defaultState()
- RoomView.super.defaultState(self)
-
- self.headInfos = {}
- for k,v in pairs(self.playerView.allNodes) do
- local pos = cc.pAdd(v.player:getPosition(),cc.p(38,66))
- table.insert(self.headInfos,{headPos=pos})
- end
- --初始化金币场Tool
- self:initCoinTool()
-
- --礼券数
- self.add_coupons = 0
-
- --设置房间等级
- self.coinTool.Items.Text_CoinLevel:setText(string.format("%d人%s", app.room.roomInfo.nMaxPlayCount, CoinFunctions.getLevelDisplayText(app.room.roomInfo.serverLevel)))
-
- --设置底分
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- self.coinTool.Items.Text_BaseScore:setText(string.format("底分%s", gameInfo.baseScore or 50))
-
- --设置底分
- --隐藏桌面信息
- --self.ui.Items.ImageView_8:setVisible(false)
- self.ui.Items.Layout_GameInfoPanel:setVisible(false)
- --隐藏菜单按钮
- self.toolView.ui.Items.Button_Menu:setVisible(false)
- self.toolView.ui.Items.Layout_Button:setVisible(false)
- --隐藏语音按钮
- --self.messageView:setBtnVoiceVisible(false)
- --隐藏GPS按钮
- self.ui.Items.Button_GPS:setVisible(false)
- --隐藏快速成局按钮
- self.toolView.ui.Items.Button_FastStart:setOpacity(0)
- self.toolView.showFastStart = function()
- self.toolView.ui.Items.Button_fastStart:setVisible(false)
- end
- self.toolView.ui.Items.Button_Rule:setVisible(false)
- self.toolView.ui.Items.Button_Rule:setOpacity(0)
- self.toolView.ui.Items.Layout_Rule:setVisible(false)
- self.toolView.ui.Items.Layout_Rule:setOpacity(0)
- self:showTuoGuan(false)
-
- --隐藏玩法详情
- self:hideXiangQing(false)
-
- --隐藏托管icon
- self:hideAllTuoGuanIcon()
-
- --设置菜单的离开按钮状态
- self.coinTool.Items.Button_Leave:setEnabled(not isPlaying)
- self.coinTool.Items.Button_ChangeTable:setEnabled(not isPlaying)
-
- --记录正在匹配中文字初始位置
- if not self.fontPos then
- self.fontPos = {}
- for i = 1,3 do
- local imgNode = string.format("ImageView_font_%d", i)
- self.fontPos[i] = self.coinTool.Items[imgNode]:getPosition()
- end
- end
-
- --默认准备
- self:onClickReady()
-
- app.waitDialogManager:closeWaitNetworkDialog()
- end
-
- --隐藏托管icon
- function RoomView:hideAllTuoGuanIcon()
- --隐藏托管
- for i = 1, 4 do
- if self.playerView["tuoguanicon" .. i] then
- self.playerView["tuoguanicon" .. i]:setVisible(false)
- end
- end
- end
-
- --GPS屏蔽
- function RoomView:checkGpsDistance()
-
- end
-
- --GPS屏蔽
- function RoomView:updateAllGpsInfo()
-
- end
-
- --兑换金币成功
- function RoomView:onDuiHuanCoin(eventData)
- local myMemberInfo = app.room.roomInfo.memberList[app.room:getMyUserId()]
- if myMemberInfo then
- myMemberInfo.nTotalMoney = tonumber(eventData.response.gold)
- end
- if self.playerView then
- self.playerView:updatePlayerInfo(app.room:getViewIdByUserId(app.room:getMyUserId()))
- end
- end
-
- --准备
- function RoomView:onClickReady(notPlayEffect)
- RoomView.super.onClickReady(self, true)
- --准备阶段隐藏 贴鬼碰/杠和自动对齐
- self.ui.Items.Layout_WanFa:setVisible(false)
- self:playPipeiAction()
- end
-
- --礼券数
- function RoomView:changeLiquan(eventData)
- self.add_coupons = eventData.attr.add_coupons
- end
-
- --游戏开始
- function RoomView:onGameStartResponse()
- RoomView.super.onGameStartResponse(self)
-
- --停止匹配动画
- self:stopPipeiAction()
- --设置菜单的离开按钮状态
- self.coinTool.Items.Button_Leave:setEnabled(false)
- self.coinTool.Items.Button_ChangeTable:setEnabled(false)
- self:hideDirectionZJ()
- end
-
- --隐藏方向盘两旁的剩余张数和局数
- function RoomView:hideDirectionZJ()
- if self.direcionView.ui and self.direcionView.ui.Items.ImageView_1 then
- self.direcionView.ui.Items.ImageView_1:setVisible(false)
- self.direcionView.ui.Items.ImageView_2:setVisible(false)
- end
- if self.direcionView.ui and self.direcionView.ui.Items.ImageView_3 then
- self.direcionView.ui.Items.ImageView_3:setVisible(false)
- self.direcionView.ui.Items.ImageView_4:setVisible(false)
- end
- end
-
- --初始化金币场Tool
- function RoomView:initCoinTool()
- if not tolua.isnull(self.coinTool) then
- self.coinTool:removeFromParent()
- self.coinTool = nil
- end
- --加载金币场Tool
- self.coinTool = loadUI("mj_luzhougui/res/ui_fangjian/mj_luzhou_coinTool.ui")
- self:addChild(self.coinTool)
-
- --设置时间
- self.coinTool.Items.Text_SystemTime:runAction(
- cc.RepeatForever:create(
- cc.Sequence:create(
- cc.CallFunc:create(function()
- self.coinTool.Items.Text_SystemTime:setText(getTimeString3())
- end),
- cc.DelayTime:create(1.0)
- )
- )
- )
-
- --获取金币
- self.coinTool.Items.Button_HuoQuJinBi:registerClick(handler(self , self.onClickHuoQuJinBi))
-
- --礼券
- self.coinTool.Items.Layout_LiQuan_Close:setVisible(false)
- self.coinTool.Items.Layout_LiQuan_Close:registerClick(function()
- self.coinTool.Items.Layout_liquan:playClip("moveBack")
- self.coinTool.Items.Layout_LiQuan_Close:setVisible(false)
- end)
- self.coinTool.Items.Button_liquan:registerClick(handler(self , self.onClickLiquan))
- self.coinTool.Items.Button_liquan:setVisible(false)
- self.coinTool.Items.Layout_liquan:setVisible(false)
- --设置默认值
- --app.php:requestGetLiquan(app.gameId, app.room.roomInfo.serverLevel)
- local liquanInfo = {
- [11] = { need = 3, prize = 2 },
- [12] = { need = 3, prize = 2 },
- [21] = { need = 3, prize = 8 },
- [22] = { need = 3, prize = 8 },
- [31] = { need = 3, prize = 15 },
- [32] = { need = 3, prize = 15 },
- }
- -- --获取礼券所需局数
- -- self.leftJushu = self.leftJushu or liquanInfo[tonumber(app.room.roomInfo.serverLevel)].need
- -- --奖励礼券数
- -- self.getLiquan = self.getLiquan or liquanInfo[tonumber(app.room.roomInfo.serverLevel)].prize
- -- --刷新界面
- -- self.coinTool.Items.Text_jushu:setText(self.leftJushu)
- -- self.coinTool.Items.Text_liquan:setText(self.getLiquan)
- --礼券信息收回
- --self:onClickLiquan(true)
-
- --隐藏剩余牌提示
- self.coinTool.Items.Image_CardNumBg:setVisible(false)
-
- --菜单按钮
- self.coinTool.Items.Button_Menu:registerClick(function()
- playBtnEffect()
- self.coinTool.Items.Layout_Menu:setVisible(not self.coinTool.Items.Layout_Menu:isVisible())
- end)
-
- --隐藏菜单界面
- self.coinTool.Items.Layout_Menu:setVisible(false)
- self.coinTool.Items.Layout_Menu:registerClick(function()
- self.coinTool.Items.Layout_Menu:setVisible(not self.coinTool.Items.Layout_Menu:isVisible())
- end)
-
- --菜单的设置按钮
- self.coinTool.Items.Button_Set:registerClick(function()
- self.toolView:onClickSet()
- end)
-
- --菜单的离开按钮
- self.coinTool.Items.Button_Leave:registerClick(function()
- if app.room.roomInfo.nGameStartCount == 0 then
- --每次如果有礼券赠送,则会主动请求一次剩余局数和礼券数量
- if app.room.roomInfo.isGameOver == true then
- runInNextFrame(function()
- setShowCountAll(false)
- self.toolView:onClickLeave()
- self:backToCoinHall()
- end)
- return
- --[[
- local function clickOk()
- runInNextFrame(function()
- setShowCountAll(false)
- self.toolView:onClickLeave()
- self:backToCoinHall()
- end)
- end
- local function clickCancel()
-
- end
- showConfirmDialog(
- string.format("再打%d局送%d礼券,是否退出?", tonumber(self.leftJushu or 0), tonumber(self.getLiquan or 0)),
- clickOk,
- clickCancel
- )
- ]]
- else
- setShowCountAll(false)
- self.toolView:onClickLeave()
- self:backToCoinHall()
- end
- end
- end)
-
- --换桌
- self.coinTool.Items.Button_ChangeTable:registerClick(function()
- playBtnEffect()
- app.room.roomInfo.changeTable = true
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallLeaveRequest)
- local gameData = CoinData.getInstance():getGameData() or {}
- local ruleList = gameData.ruleList or {}
- local gameId = tonumber(app.gameId)
- local gameRuleInfo = ruleList[gameId]
- if gameRuleInfo then
- local serverLevel = app.room.roomInfo.serverLevel
- local minServerLevel = 10
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- gameInfo.gamerule = gameInfo.gamerule or 1
- minServerLevel = minServerLevel + tonumber(gameInfo.gamerule)
- local minCoinInfo = gameRuleInfo["" .. minServerLevel]
- local curCoinInfo = gameRuleInfo["" .. serverLevel]
-
- if tonumber(app.user.loginInfo.curJingbiNum) < tonumber(minCoinInfo.min_money) or
- tonumber(app.user.loginInfo.curJingbiNum) >= tonumber(curCoinInfo.min_money)
- then
- CoinGameLogic.requestEnterCoinGame(gameId, gameInfo.gamerule, serverLevel, tonumber(curCoinInfo.min_money))
- else
- CoinGameLogic.requestEnterCoinGame(gameId, gameInfo.gamerule)
- end
- else
- CoinData.getInstance():requestGameServerConfig()
- end
- end)
-
- --托管按钮
- self.coinTool.Items.Button_TuoGuan:registerClick(function()
- playBtnEffect()
- local request = MJMessage.HostingRequest:new()
- request.nUserId = 0
- request.status = 1 --1托管 0取消托管
- self.ui:sendMsg(app.room, MJDefine.MJEvent.HostingRequest, request)
- end)
- --取消托管
- self.coinTool.Items.Button_guoguan:registerClick(function()
- playBtnEffect()
- local request = MJMessage.HostingRequest:new()
- request.nUserId = 0
- request.status = 0 --1托管 0取消托管
- --app.room.roomInfo.hosting = 0
- self.ui:sendMsg(app.room, MJDefine.MJEvent.HostingRequest, request)
- end)
-
- --玩法界面
- self:initXiangQing()
- end
-
- --获取金币
- function RoomView:onClickHuoQuJinBi()
- playBtnEffect()
- local view = import("luaScript.Views.Main.RechargeView"):new(STORE_TYPE.CHANGE_COIN, false, true)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- --礼券
- function RoomView:onClickLiquan(notPlayEffect)
- if notPlayEffect ~= true then
- playBtnEffect()
- end
- if self.coinTool.Items.Layout_liquan:getScaleX() < 1 then
- app.php:requestGetLiquan(app.gameId, app.room.roomInfo.serverLevel)
- self.coinTool.Items.Layout_liquan:playClip("moveTo")
- self.coinTool.Items.Layout_LiQuan_Close:setVisible(true)
- else
- self.coinTool.Items.Layout_liquan:playClip("moveBack")
- self.coinTool.Items.Layout_LiQuan_Close:setVisible(false)
- end
- end
-
- -- 小局结算
- function RoomView:onGameXiaoJuResponse(data)
- --设置停留
- setShowCountAll(true)
- --自动离开
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallLeaveRequest)
- --停止方位时间
- self.direcionView:stopAllActions()
- --self.direcionView:cleanDirectionTimer()
- --隐藏托管
- self:showTuoGuan(false)
- --隐藏托管icon
- self:hideAllTuoGuanIcon()
- --设置菜单的离开按钮状态
- self.coinTool.Items.Button_Leave:setEnabled(true)
- self.coinTool.Items.Button_ChangeTable:setEnabled(true)
- --隐藏听牌
- self:setTingCardViewVisible(false)
-
- RoomView.super.onGameXiaoJuResponse(self, data)
- end
-
- --显示隐藏托管
- function RoomView:showTuoGuan(vis)
-
- if not tolua.isnull(self.toolView) then
- self.toolView:showTuoGuan(vis)
- end
-
- self.coinTool.Items.Layout_tuoguan:setVisible(false)
- self:setTieGuiAndDisableIt(vis)
-
- -- if vis and true == vis then
- -- --是否托管标识
- -- --[[self.isTuoGuan = true
- -- if self.playerHandCards[MJDefine.MyViewId] then
- -- self.playerHandCards[MJDefine.MyViewId]:removeTouchEventOnly()
- -- end--]]
- -- self.coinTool.Items.Button_TuoGuan:setEnabled(false)
- -- else
- -- --[[if self.playerHandCards[MJDefine.MyViewId] and self.isTuoGuan then
- -- self.isTuoGuan = nil
- -- self.playerHandCards[MJDefine.MyViewId]:initTouchEvent()
- -- end--]]
- -- self.coinTool.Items.Button_TuoGuan:setEnabled(true)
- -- end
- end
-
- --设置贴鬼碰杠且不可点
- function RoomView:setTieGuiAndDisableIt(able)
- if able then
- if self.ui.Items.CheckBox_TieGui then
- self.ui.Items.CheckBox_TieGui:setSelectedState(true)
- saveUserInfo("luzhou_mj_tiegui", 1)
- MJDefine.isTieGui = true
- end
- else
- end
- self.ui.Items.CheckBox_TieGui:setTouchEnabled(not able)
- self.ui.Items.CheckBox_Automatic:setTouchEnabled(not able)
- end
-
- -- 显示小局结算
- function RoomView:showXiaoJuView()
- --获取最新礼券
- --app.php:requestGetLiquan(app.gameId, app.room.roomInfo.serverLevel)
- --停止方位时间
- self.direcionView:stopAllActions()
- --self.direcionView:cleanDirectionTimer()
- --刷新分数
- for _,v in pairs(app.room.roomInfo.memberList) do
- self.playerView:updatePlayerInfo(app.room:getViewIdByUserId(v.nUserId))
- end
- --显示小局结算
- if self.xiaojuView then
- self.xiaojuView:removeFromParent()
- end
- self.xiaojuView = MJRoomXiaoJuView:new(self.add_coupons)
- self:addChild(self.xiaojuView)
- end
-
- --隐藏微信
- function RoomView:setWetChatVisible(bVisible)
- RoomView.super.setWetChatVisible(self, false)
- end
-
- --更新牌数
- function RoomView:updateGameNums()
- if self.coinTool then
- self.coinTool.Items.Image_CardNumBg:setVisible(true)
- self.coinTool.Items.Text_CardNum:setText(app.room.roomInfo.nLeaveCardNum or 0)
- end
- end
-
- --初始化法详情
- function RoomView:initXiangQing()
- local size = self.coinTool.Items.Layout_XQ_content:getContentSize()
- self.xiangQingViewShowPos = self.coinTool.Items.Layout_XQ_content:getPosition()
- self.xiangQingViewHidePos = cc.vec3(self.xiangQingViewShowPos.x, self.xiangQingViewShowPos.y + size.height, self.xiangQingViewShowPos.z)
-
- self.coinTool.Items.ListView_Xq:getVBar():setVisible(false)
- self.coinTool.Items.Button_XiangQing:registerClick(handler(self , self.showXiangQing))
- self.coinTool.Items.Layout_XQ_content:registerClick(handler(self , self.hideXiangQing))
- self.coinTool.Items.Button_XiangQing_Back:registerClick(handler(self , self.hideXiangQing))
- self.coinTool.Items.Button_XiangQing_Close:registerClick(handler(self , self.hideXiangQing))
- --self.coinTool.Items.Layout_XiangQing:setVisible(false)
-
- local roomInfo = app.room.roomInfo
- local listviewSize = self.coinTool.Items.ListView_Xq:getContentSize()
- local wanfaList = {"80颗(5颗起胡)", "12鬼", "报叫", "过张升番可胡", "听牌提示", "一炮多响头家庄"}
- table.insert(wanfaList, 1, roomInfo.nMaxPlayCount .. "人")
- for i,v in pairs(wanfaList) do
- if v ~= "" and 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, 40))
- layout:addChild(wanfaText)
- wanfaText:setPosition(cc.p(listviewSize.width / 2, 15))
- wanfaText:setString(v)
- self.coinTool.Items.ListView_Xq:pushBackCustomItem(layout)
- end
- end
- end
-
- --显示法详情
- function RoomView:showXiangQing(doAction)
- self.coinTool.Items.Button_XiangQing:setVisible(false)
- self.coinTool.Items.Layout_XQ_content:stopAllActions()
- if doAction then
- playBtnEffect()
- self.coinTool.Items.Layout_XQ_content:runAction(
- cc.Sequence:create(
- cc.MoveTo:create(0.35 , self.xiangQingViewShowPos),
- cc.CallFunc:create(function()
- self.coinTool.Items.ListView_Xq:setVisible(true)
- self.coinTool.Items.Button_XiangQing_Close:setVisible(true)
- end)
- )
- )
- else
- self.coinTool.Items.ListView_Xq:setVisible(true)
- self.coinTool.Items.Button_XiangQing_Close:setVisible(true)
- self.coinTool.Items.Layout_XQ_content:setPosition(self.xiangQingViewShowPos)
- end
- end
-
- --隐玩法详情
- function RoomView:hideXiangQing(doAction)
- self.coinTool.Items.Button_XiangQing_Close:setVisible(false)
- self.coinTool.Items.Layout_XQ_content:stopAllActions()
- self.coinTool.Items.ListView_Xq:setVisible(false)
- if doAction then
- playBtnEffect()
- self.coinTool.Items.Layout_XQ_content:runAction(
- cc.Sequence:create(
- cc.MoveTo:create(0.35 , self.xiangQingViewHidePos),
- cc.CallFunc:create(function()
- self.coinTool.Items.Button_XiangQing:setVisible(true)
- end)
- )
- )
- else
- self.coinTool.Items.Button_XiangQing:setVisible(true)
- self.coinTool.Items.Layout_XQ_content:setPosition(self.xiangQingViewHidePos)
- end
- end
-
- --托管
- function RoomView:onHostingRequest(data)
- --RoomView.super.onHostingRequest(self, data)
- local response = data.response
- if app.room:getMyUserId() == response.nUserId then
- if response.status == 1 then --托管状态
- self:showTuoGuan(true)
- self.coinTool.Items.Button_TuoGuan:setEnabled(false)
- if not tolua.isnull(self.firstTingTipsView) then
- self.firstTingTipsView:killSelf()
- self.firstTingTipsView = nil
- end
- elseif response.status == 0 then--取消托管状态
- self:showTuoGuan(false)
- self.coinTool.Items.Button_TuoGuan:setEnabled(true)
- end
- end
-
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- if self.playerView and viewId then
- if data.response.status == 1 then --托管状态
- if not self.playerView["tuoguanicon" .. viewId] then
- local tuoguanicon = cc.ImageView:createNode()
- tuoguanicon:loadTexture("res/ui/zy_jinbichang/coin_game/coin_game_tuoguanicon.png")
- --重新计算大小
- local headSize = self.playerView.allNodes[viewId].head:getContentSize()
- local tuoguanSize = tuoguanicon:getContentSize()
- tuoguanicon:setAutoSize(false)
- tuoguanicon:setSize(cc.size(headSize.width, headSize.width / tuoguanSize.width * tuoguanSize.height))
- --重新位置
- local posEx = self.headInfos[viewId].headPos
- posEx = cc.p(posEx.x, posEx.y - headSize.height / 2 + tuoguanicon:getSize().height / 2 - 1)
- tuoguanicon:setPosition(posEx)
- --添加节点
- self.playerView:addChild(tuoguanicon)
- --保存引用
- self.playerView["tuoguanicon" .. viewId] = tuoguanicon
- end
- self.playerView["tuoguanicon" .. viewId]:setVisible(true)
- else --取消托管状态
- if self.playerView["tuoguanicon" .. viewId] then
- self.playerView["tuoguanicon" .. viewId]:setVisible(false)
- end
- end
- end
- end
-
- --重连
- function RoomView:onGameReconnection()
- RoomView.super.onGameReconnection(self)
-
- local roomInfo = app.room.roomInfo
-
- if roomInfo.nGameStartCount > 0 then
- --停止正在匹配中动画
- self:stopPipeiAction()
- --设置菜单的离开按钮状态
- self.coinTool.Items.Button_Leave:setEnabled(false)
- self.coinTool.Items.Button_ChangeTable:setEnabled(false)
- else
- --正在匹配中动画
- self.ui.Items.Layout_WanFa:setVisible(false)
- local myMemberInfo = roomInfo.memberList[app.room:getMyUserId()]
- if myMemberInfo.nPlayerFlag == 1 then
- self:playPipeiAction()
- end
- end
-
- if roomInfo.nStatus ~= MJDefine.GameStatus.GAME_STATUS_ROUND_OVER then
- --显示托管
- for k,v in pairs(roomInfo.memberList) do
- self:onHostingRequest({ response = { nUserId = k, status = (v.hosted or 0) }})
- end
- else
- --隐藏托管
- self:showTuoGuan(false)
- end
- self:hideDirectionZJ()
- end
-
- --正在匹配中动画
- function RoomView:playPipeiAction()
- --先暂停之前的
- self:stopPipeiAction()
- --显示动画
- self.coinTool.Items.Layout_action:setVisible(true)
- local index = 1
- local function fontAction(idx)
- local seq = cc.Sequence:create(
- cc.MoveTo:create(0.3,cc.p(self.fontPos[idx].x, self.fontPos[idx].y + 10)),
- cc.CallFunc:create(function ()
- idx = idx + 1
- if idx > 3 then
- idx = 1
- end
- local imgNode = string.format("ImageView_font_%d", idx)
- self.coinTool.Items[imgNode]:runAction(fontAction(idx))
- end),
- cc.MoveTo:create(0.3,cc.p(self.fontPos[idx].x, self.fontPos[idx].y))
- )
- return seq
- end
- self.coinTool.Items.ImageView_font_1:runAction(fontAction(index))
- end
-
- --停止正在匹配中动画
- function RoomView:stopPipeiAction()
- self.coinTool.Items.Layout_action:setVisible(false)
- for i = 1,3 do
- local imgNode = string.format("ImageView_font_%d", i)
- self.coinTool.Items[imgNode]:stopAllActions()
- --重新设置文字位置,回归原位
- self.coinTool.Items[imgNode]:setPosition(self.fontPos[i])
- end
- end
-
- --获取礼券数量和所需局数返回
- function RoomView:LiquanNum(event)
- if not event then
- return
- end
-
- if event.result then
- if event.result.need then
- --所需局数
- self.leftJushu = tonumber(event.result.need)
- self.coinTool.Items.Text_jushu:setText(self.leftJushu)
- end
- if event.result.prize then
- --可获得礼券数
- self.getLiquan = tonumber(event.result.prize)
- self.coinTool.Items.Text_liquan:setText(self.getLiquan)
- end
- end
- end
-
- --- RoomView:backToCoinHall 返回金币场大厅
- function RoomView:backToCoinHall()
- local data = {
- gameId = app.gameId,
- isCoin = true
- }
- app:gotoView(import("luaScript.Views.Main.MainView"):new(data))
- end
-
- -- 发牌
- function RoomView:onGameSendCardResponse()
- RoomView.super.onGameSendCardResponse(self)
- local function showHosting( onEnd )
- if app.room.roomInfo.hosting then
- self:showTuoGuan(app.room.roomInfo.hosting==1)
- self.coinTool.Items.Button_TuoGuan:setEnabled(app.room.roomInfo.hosting==0)
- end
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addCallBack(showHosting)
- end
-
- -- 出牌成功
- function RoomView: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 typr = operates.opType
-
- if operates and table.nums(operates)>0 then
- self.operates = operates
- else
- self.operates = {}
- end
-
- local function callback()
- self.playerHandCards[MJDefine.MyViewId].handOutCard = nil
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
- if onEnd then
- onEnd()
- end
- end
-
- if self.playerHandCards[viewId] then
- if viewId==MJDefine.MyViewId then
- local player = app.room.roomInfo.memberList[data.response.nUserId]
- self.playerHandCards[viewId]:setTing(false)
- if player.isBaoPai==1 and app.room.roomInfo.lastOutViewId~=MJDefine.MyViewId then --点击爆牌的时候 前端已经打出牌 要判断上次出牌的人是不是自己 避免重复出牌
- self.playerHandCards[viewId]:onOutCard(card,callback)
- --音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- if userInfo then
- MJSound.PlayMJSound(userInfo.sex,card)
- end
- elseif app.room.roomInfo.hosting and app.room.roomInfo.hosting == 1 then
- self.playerHandCards[viewId]:hideOperate()
- if self.playerHandCards[viewId].handOutCard then
- self.playerHandCards[viewId].handOutCard = nil
- callback()
- else
- self.playerHandCards[viewId]:onOutCard(card,callback)
- --音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- if userInfo then
- MJSound.PlayMJSound(userInfo.sex,card)
- end
- end
- else
- --self.playerHandCards[viewId]:onOutCard(card,callback)
- callback()
- self.playerHandCards[MJDefine.MyViewId]:lockHongZhong(false)
- 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
- self:addCallBack(runOnOutCardSuccess)
- end
-
- function RoomView:onWaitOperate(data)
- RoomView.super.onWaitOperate(self,data)
- --等待操作的UID
- local nUserId = data.response.nUserId
- local viewId = app.room:getViewIdByUserId(nUserId)
-
- if MJDefine.MyViewId == viewId then--自己预操作了,隐藏操作按钮
- self.playerHandCards[viewId]:hideOperate()
- end
- end
-
- return RoomView
|