您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字

2870 行
91 KiB

  1. local RoomView_53 = class("RoomView_53", cc.UIView)
  2. local Functions = require("pk_nanchongdoudizhu.luaScript.Functions_53")
  3. local defs = require("pk_nanchongdoudizhu.luaScript.Def_53")
  4. local Messages = require("pk_nanchongdoudizhu.luaScript.Protocol.ProtocolMessage_53")
  5. local PokerUtil = require('pk_nanchongdoudizhu.luaScript.Views.Room.newPokerUtil')
  6. local DDZ_New_Effect_Helper = require("pk_nanchongdoudizhu.luaScript.Views.Room.DDZNewEffectHelper"):new()
  7. local Card_Move_Up_Down_Time = 0.1 -- 手牌抬起下放动画时间
  8. local Card_Out_Down_Time = 0.15 -- 出牌下放动画时间
  9. local Card_Out_Down_Offset_Y = -5 -- 出牌下放位置
  10. function RoomView_53:ctor()
  11. RoomView_53.super.ctor(self)
  12. self._pokerUtil = nil
  13. self._isCanClickBg = true
  14. end
  15. function RoomView_53:initData()
  16. --事件队列
  17. self.callbackQueue = {}
  18. --手牌间距(越大越密集,越小越稀疏)
  19. self.handCardDif = 110
  20. --默认闹钟时间
  21. self.clockTime = 15
  22. --上家出的牌数据
  23. self.lastData = {}
  24. self:setLastData()
  25. end
  26. function RoomView_53:onEnter()
  27. RoomView_53.super.onEnter(self)
  28. --ui load
  29. local ui = loadUI("pk_nanchongdoudizhu/res/ui/ui_fangjian/doudizhu_ui_fangjian.ui")
  30. self:addChild(ui)
  31. self.ui = ui
  32. -- 添加合图缓存
  33. self:addloadSpriteFrame()
  34. -- 添加扑克牌型提示文件
  35. self:initPokerUtil()
  36. --初始化属性数据
  37. self:initData()
  38. --初始化所有的玩家节点
  39. self:initPlayerNodes()
  40. --初始化工具层
  41. self:initToolLayer()
  42. -- 初始化GPS组件
  43. self:initGpsComponent()
  44. -- 初始化电量和信号
  45. self:initSingleComponent()
  46. -- 初始化扑克牌
  47. self:initPoker()
  48. -- 初始化顶部栏扑克信息
  49. self:initTopData()
  50. --监听事件
  51. self:bindAllEvent()
  52. --显示桌面信息
  53. self:initDeskInfo()
  54. --初始游戏中按钮
  55. self:initGameButtons()
  56. --初始化玩法
  57. self:initGameRule()
  58. --播放音乐
  59. -- Functions.playMusic()
  60. self:onChangeBgm()
  61. --先收到8009再初始化的房间(房间还未监听8009事件),所以这里调用重连
  62. self:onGameReconnection()
  63. --恢复协议
  64. self:startGame()
  65. --测试
  66. --self.weaveCardList = self:getTip(self.handCards["" .. self:getMeViewId()])
  67. end
  68. function RoomView_53:addloadSpriteFrame()
  69. loadSpriteFrameFile("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cards/doudizhu_pokerCards.plist")
  70. -- 动画相关
  71. loadSpriteFrameFile("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/zy_ddz_shunzi/zy_ddz_CardFX_ShunZi_Sheet1.plist")
  72. loadSpriteFrameFile("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/zy_ddz_shunzi/zy_ddz_CardFX_ShunZi_Sheet2.plist")
  73. loadSpriteFrameFile("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/zy_ddz_bomb/zy_ddz_CardFX_ZhaDan_Sheet1.plist")
  74. loadSpriteFrameFile("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/zy_ddz_liandui/zy_ddz_CardFX_LianDui_Sprite_1.plist")
  75. loadSpriteFrameFile("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_player/zy_game_jingbao/ddz_Ani_BJ.plist")
  76. loadSpriteFrameFile('pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/zy_ddz_kingbomb/doudizhu_Ani_KingBomb.plist')
  77. end
  78. function RoomView_53:initPokerUtil()
  79. self._pokerUtil = PokerUtil:new()
  80. end
  81. function RoomView_53:initPoker()
  82. local changePoker = tonumber(loadUserInfo("ddz_setting_poker")) or defs.Default_Poker_Choose
  83. self:onNormalChangePoker({idx=changePoker})
  84. end
  85. function RoomView_53:initTopData()
  86. local dipaiCount = Functions.getRuleIncludeLzWanFa() and 4 or 3
  87. if dipaiCount == 3 then
  88. self.ui.Items.Layout_Card_4:setVisible(false)
  89. self.ui.Items.Layout_Top_Info:requestDoLayout()
  90. self.ui.Items.Layout_Top_Info:doLayout()
  91. end
  92. end
  93. function RoomView_53:onClickButtonDismiss( sender )
  94. playBtnEffect()
  95. local function onClickOk()
  96. app.room:requestDismissRoom(1)--发起解散
  97. end
  98. local function onClickCancel()
  99. end
  100. showConfirmDialog("确定要申请解散房间吗?", onClickOk, onClickCancel)
  101. end
  102. function RoomView_53:hideXiangQing(hideAction)
  103. self.xiangQingView.Items.Layout_XiangQing:setVisible(false)
  104. self.xiangQingView.Items.Layout_XQ_content:stopAllActions()
  105. self.xiangQingView.Items.ListView_Xq:setVisible(false)
  106. if hideAction == true then
  107. self.xiangQingView.Items.Layout_XQ_content:setPosition(self.xiangQingViewHidePos)
  108. self.xiangQingView.Items.Button_XiangQing:setVisible(true)
  109. else
  110. self.xiangQingView.Items.Layout_XQ_content:runAction(
  111. cc.Sequence:create(
  112. cc.MoveTo:create(0.35 , self.xiangQingViewHidePos),
  113. cc.CallFunc:create(function()
  114. self.xiangQingView.Items.Button_XiangQing:setVisible(true)
  115. end)
  116. )
  117. )
  118. end
  119. end
  120. function RoomView_53:initGameRule()
  121. self.xiangQingView = loadUI("pk_nanchongdoudizhu/res/ui/ui_fangjian/doudizhu_ui_wanfa.ui")
  122. self.ui.Items.Layout_RuleView:addChild(self.xiangQingView)
  123. self.xiangQingView.Items.Button_XiangQing:setVisible(false)
  124. self.xiangQingView.Items.Layout_XiangQing:setVisible(true)
  125. local offsetX = 20
  126. self.xiangQingView.Items.Button_XiangQing:setPositionX(self.xiangQingView.Items.Button_XiangQing:getPositionX() + offsetX)
  127. self.xiangQingView.Items.Layout_XQ_content:setPositionX(self.xiangQingView.Items.Layout_XQ_content:getPositionX() + offsetX)
  128. local size = self.xiangQingView.Items.Layout_XQ_content:getContentSize()
  129. self.xiangQingViewShowPos = self.xiangQingView.Items.Layout_XQ_content:getPosition()
  130. self.xiangQingViewHidePos = cc.vec3(self.xiangQingViewShowPos.x,self.xiangQingViewShowPos.y + size.height,self.xiangQingViewShowPos.z)
  131. self.xiangQingView.Items.Button_XiangQing_Back:registerClick(handler(self , self.hideXiangQing))
  132. self.xiangQingView.Items.Layout_XiangQing:registerClick(handler(self , self.hideXiangQing))
  133. self.xiangQingView.Items.Layout_XQ_content:registerClick(handler(self , self.hideXiangQing))
  134. self.xiangQingView.Items.Button_XiangQing:registerClick(function()
  135. playBtnEffect()
  136. self.xiangQingView.Items.Button_XiangQing:setVisible(false)
  137. self.xiangQingView.Items.Layout_XQ_content:stopAllActions()
  138. self.xiangQingView.Items.Layout_XQ_content:runAction(
  139. cc.Sequence:create(
  140. cc.MoveTo:create(0.35 , self.xiangQingViewShowPos),
  141. cc.CallFunc:create(function()
  142. self.xiangQingView.Items.ListView_Xq:setVisible(true)
  143. self.xiangQingView.Items.Layout_XiangQing:setVisible(true)
  144. end)
  145. )
  146. )
  147. end)
  148. self.xiangQingView.Items.ListView_Xq:getVBar():setVisible(false)
  149. local roomInfo = app.room.roomInfo
  150. local ruleAll = Functions.getRuleStr()
  151. local wanfaList = string.split(ruleAll," ")
  152. local listviewSize = self.xiangQingView.Items.ListView_Xq:getContentSize()
  153. for i,v in pairs(wanfaList) do
  154. if v ~= "" and v ~= " " then
  155. local layout=cc.Layout:create()
  156. local wanfaText = cc.Text:createNode()
  157. wanfaText:setDefaults()
  158. local config = wanfaText:getFontConfig()
  159. config.fontSize = 24
  160. config.texColor = cc.c4b(255,192,101,255)
  161. wanfaText:setFontConfig(config)
  162. layout:setSize(cc.size(listviewSize.width,35))
  163. layout:addChild(wanfaText)
  164. wanfaText:setPosition(cc.p(listviewSize.width/2,15))
  165. wanfaText:setString(v)
  166. self.xiangQingView.Items.ListView_Xq:pushBackCustomItem(layout)
  167. end
  168. end
  169. if app.room.roomInfo.nGameStartCount > 0 then
  170. self:hideXiangQing(true)
  171. else
  172. self:runAction(cc.Sequence:create(
  173. cc.DelayTime:create(2),
  174. cc.CallFunc:create(self.hideXiangQing)
  175. ))
  176. end
  177. end
  178. function RoomView_53:defaultState()
  179. --队列初始化
  180. self.callbackQueue = {}
  181. self.callbackRunning = false
  182. --刷新按钮
  183. self:updateButtons()
  184. --刷新用户信息
  185. self:refreshPlayer(true)
  186. --隐藏地主底牌、炸弹等信息
  187. self:setBanderCardsVisible(false)
  188. --是否开局
  189. if app.room.roomInfo.nGameStartCount > 0 then
  190. --隐藏加倍界面
  191. self:setAskBeiVisible(false)
  192. --隐藏叫分界面
  193. self:setAskLoardVisible(false)
  194. --隐藏玩家出牌操作信息
  195. self:hideAllOutCardOperation()
  196. --隐藏界面
  197. for _,v in pairs(app.room.roomInfo.memberList) do
  198. local viewId = app.room:getViewIdByUserId(v.nUserId)
  199. --隐藏桌面加倍标识
  200. self.PlayerView:setTipsVisible("tips_jiabei", false, viewId)
  201. --隐藏桌面叫分标识
  202. self.PlayerView:setTipsVisible("tips_jiaofen", false, viewId)
  203. --隐藏手牌
  204. local handLayout = self.ui.Items["Layout_Hand_" .. viewId]
  205. if handLayout then
  206. handLayout:removeAllChildren()
  207. if self.handCards then
  208. local handCards = self.handCards["" .. viewId]
  209. if handCards then
  210. self.handCards["" .. viewId] = nil
  211. end
  212. end
  213. end
  214. end
  215. end
  216. end
  217. function RoomView_53:onUserExitResponseRoom(data)
  218. local function runUserExitResponseRoom(onEnd)
  219. print('runUserExitResponseRoom..')
  220. local response = data.response
  221. --房间号
  222. local roomid = app.room.roomInfo.nShowTableId
  223. app.room.roomInfo.tableOverFlag = response.tableOverFlag
  224. -- --长时间未开始强制退出,否则不退出
  225. -- if app.room.roomInfo.tableOverFlag ~= defs.TABLE_OVER_FLAG.TABLE_OVER_LONG_TIME_NO_START and app.room.roomInfo.nGameStartCount ~= 0 then
  226. -- response.logoutFlag = 0
  227. -- else
  228. -- response.logoutFlag = 1
  229. -- end
  230. -- --如果是自己点离开必须退出
  231. -- if app.room.roomInfo.bQuitRoom then
  232. -- response.logoutFlag = 1
  233. -- end
  234. -- --正常结束不提示,其他都要提示
  235. -- if app.room.roomInfo.tableOverFlag >= defs.TABLE_OVER_FLAG.TABLE_OVER_GROUP_DISBAND then
  236. -- showTooltip(defs.TABLE_OVER_FLAG_TEXT[app.room.roomInfo.tableOverFlag])
  237. -- end
  238. print('app.room.roomInfo.bQuitRoom->', app.room.roomInfo.bQuitRoom)
  239. print('app.room.roomInfo.tableOverFlag', app.room.roomInfo.tableOverFlag)
  240. -- 0: 不退出, 1: 退出
  241. if response.logoutFlag == 1 then
  242. app:gotoView(import("luaScript.Views.Main.MainView"):new(GAME_IDS.NanChongDouDiZhu, roomid))
  243. end
  244. app.room:dispatchEvent({name = "onUserExitResponseHall"})
  245. if onEnd then
  246. onEnd()
  247. end
  248. end
  249. self:addCallBack(runUserExitResponseRoom)
  250. end
  251. -- function RoomView_53:showProp(data)
  252. -- local response = data.response
  253. -- logE("RoomView_53:showProp response = "..table.tostring(response))
  254. -- --ui表现开始
  255. -- local uidStarId = response.uidStarId
  256. -- local uidEndId = response.uidEndId
  257. -- local propId = response.propId
  258. -- local isQunFa = response.isQunFa
  259. -- local beginViewId = app.room:getViewIdByUserId(uidStarId)
  260. -- local endViewId = app.room:getViewIdByUserId(uidEndId)
  261. -- if not self.allNodes[beginViewId] or not self.allNodes[endViewId]
  262. -- or not self.allNodes[endViewId].head or not self.allNodes[beginViewId].head then
  263. -- logE("场景还没初始化完成就收到道具消息果断return!")
  264. -- return
  265. -- end
  266. -- --播放动画
  267. -- if isQunFa == 1 then
  268. -- local onLineList = app.room.roomInfo.memberList
  269. -- for nUserId,v in pairs(onLineList) do
  270. -- local endViewId = app.room:getViewIdByUserId(nUserId)
  271. -- if endViewId ~= beginViewId then
  272. -- self.PropAniManager:playAnimation(self.allNodes[beginViewId].head,self.allNodes[endViewId].head,propId)
  273. -- end
  274. -- end
  275. -- else
  276. -- self.PropAniManager:playAnimation(self.allNodes[beginViewId].head,self.allNodes[endViewId].head,propId)
  277. -- end
  278. -- end
  279. function RoomView_53:initPlayerNodes()
  280. self.PlayerView = import("pk_nanchongdoudizhu.luaScript.Views.Room.RoomPlayerView_53"):new()
  281. self.ui.Items.Layout_Player:addChild(self.PlayerView)
  282. end
  283. function RoomView_53:refreshPlayer(bVisible, viewId, playerInfo)
  284. if bVisible then
  285. self.PlayerView:updatePlayer(playerInfo, viewId)
  286. else
  287. self.PlayerView:hidePlayer(viewId)
  288. end
  289. local uids = {}
  290. for k,v in pairs(app.room.roomInfo.memberList) do
  291. uids[v.nUserId] = true
  292. end
  293. -- if self.messageView then
  294. -- self.messageView:setPlayerUids(uids)
  295. -- end
  296. end
  297. function RoomView_53:initToolLayer()
  298. --加载工具层
  299. self.toolView = import("pk_nanchongdoudizhu.luaScript.Views.Room.RoomToolView_53"):new()
  300. self.ui.Items.Layout_Tool:addChild(self.toolView)
  301. --ChatView
  302. -- self.messageView = require("luaScript.Views.Room.ChatView"):new({chatList = defs.GAME_CHAT_TXT}, self.PlayerView:getChatViewPos(), true)
  303. -- self.toolView.ui.Items.Layout_ChatView:addChild(self.messageView)
  304. --设置语言
  305. -- self.messageView:setLanguage(Functions.getCurLanguage() == defs.LANGUAGE_TYPE.PU_TONG_HUA)
  306. --互动表情,语音
  307. -- self.messageView:setBtnFace(defs.FACE_POS)
  308. -- self.messageView:setBtnVoice(defs.VOICE_POS)
  309. -- self.messageView.ui.Items.Button_Face:loadTextureNormal("res/ui/zy_fangjian/RoomMenu/room_menu_3/room_menu3_room_btn_kjy.png")
  310. -- self.messageView.ui.Items.Button_Face:loadTexturePressed("res/ui/zy_fangjian/RoomMenu/room_menu_3/room_menu3_room_btn_kjy.png")
  311. -- self.messageView.ui.Items.Button_Face:loadTextureDisabled("res/ui/zy_fangjian/RoomMenu/room_menu_3/room_menu3_room_btn_kjy.png")
  312. -- self.messageView.ui.Items.Button_Voice:loadTextureNormal("res/ui/zy_fangjian/RoomMenu/room_menu_3/room_menu3_room_btn_yuyin.png")
  313. -- self.messageView.ui.Items.Button_Voice:loadTexturePressed("res/ui/zy_fangjian/RoomMenu/room_menu_3/room_menu3_room_btn_yuyin.png")
  314. -- self.messageView.ui.Items.Button_Voice:loadTextureDisabled("res/ui/zy_fangjian/RoomMenu/room_menu_3/room_menu3_room_btn_yuyin.png")
  315. --是否屏蔽互动表情
  316. -- self.messageView:setPropEnabled((tonumber(loadUserInfo("HuDongBiaoQingKG" .. app.gameId)) or 1) == 1)--0关 1开
  317. --是否屏蔽屏蔽语音
  318. -- self.messageView:setVoiceEnabled((tonumber(loadUserInfo("PingBiYuYinKG" .. app.gameId)) or 1) == 1)--0关 1开
  319. --道具播放管理器
  320. -- self.PropAniManager = import("luaScript.Tools.PropAniPlayer"):new(self.ui.Items.Layout_Touch)
  321. if Functions.getRuleIncludeNotChatPlayWanFa() then
  322. -- self.messageView:hideBtns()
  323. end
  324. end
  325. function RoomView_53:initGpsComponent()
  326. local versionCode = getAppVersionCode()
  327. versionCode = tonumber(versionCode) or 0
  328. logD("RoomView_53:initGpsComponent() versionCode = ", versionCode)
  329. if isReviewVersion() then
  330. self.toolView.ui.Items.Button_GPS:registerClick(handler(self, self.showGpsView))
  331. self.toolView.ui.Items.Button_GPS:setVisible(false)
  332. return
  333. end
  334. -- 创建 gps 组件
  335. self.gpsComponent = import("luaScript.Views.Room.RoomGpsComponent"):new()
  336. -- GPS 按钮
  337. self.toolView.ui.Items.Button_GPS:registerClick(handler(self, self.showGpsView))
  338. -- 我的GPS数据发生变化时检测是否需要通知服务器
  339. self:bindEvent(app, "onGpsInoChanged", handler(self, self.checkMyGpsNeedUpdate))
  340. -- 进入时检测一遍我的GPS数据是否需要更新
  341. self:checkMyGpsNeedUpdate()
  342. end
  343. -- 初始化电量和信号
  344. function RoomView_53:initSingleComponent()
  345. self.singleComponent = import("luaScript.Views.Room.RoomSinglePowerComponent"):new(self.ui.Items.ImageView_Single, self.ui.Items.LoadingBar_Power);
  346. end
  347. -- 注销电量、网络信号
  348. function RoomView_53:deInitSingleComponent()
  349. if self.singleComponent then
  350. self.singleComponent:exit()
  351. end
  352. end
  353. function RoomView_53:bindAllEvent()
  354. --用户状态(包括准备,其他玩家进入或者离开通知,离线等)
  355. self:bindUserStatedMessage()
  356. --私人场消息(包括解散等)
  357. self:bindPrivateMessage()
  358. --游戏消息
  359. self:bindGameMessage()
  360. --游戏场景消息
  361. self:bindGameSceneMessage()
  362. --绑定更换桌布事件
  363. self:bindEvent(app , "onChangeTable" , handler(self , self.onChangeTable))
  364. --发送道具
  365. -- self:bindEvent(app.room,"showProp" , handler(self , self.showProp))
  366. --绑定更换背景音乐种类
  367. self:bindEvent(app , "onChangeBgm" , handler(self , self.onChangeBgm))
  368. --设置互动表情开关事件
  369. self:bindEvent(app.room,"ontSetPropEnabled" , handler(self , self.ontSetPropEnabled))
  370. --设置语音开关事件
  371. self:bindEvent(app.room,"onSetVoiceEnabled" , handler(self , self.onSetVoiceEnabled))
  372. -- 游戏设置里更换扑克
  373. self:bindEvent(app.room, "ddzNormalEvent_changePoker" , handler(self , self.onNormalChangePoker))
  374. -- 小结算内通知解散
  375. self:bindEvent(app.room, 'onResultInformDisMiss', handler(self, self.onClickButtonDismiss))
  376. end
  377. function RoomView_53:initDeskInfo()
  378. --设置房间号
  379. self.ui.Items.Text_roomNum:setText("房间号: " .. app.room.roomInfo.nShowTableId)
  380. -- 更新当前局数
  381. self:updateGameNums()
  382. --系统时间
  383. if not app.room.roomInfo.isRecord then
  384. self.ui.Items.Text_systemTime:stopAllActions()
  385. self.ui.Items.Text_systemTime:runActions(
  386. cc.RepeatForever:create(
  387. cc.Sequence:create(
  388. cc.CallFunc:create(function()
  389. self.ui.Items.Text_systemTime:setText(string.format("%s", os.date("%H:%M:%S", os.time())))
  390. end),
  391. cc.DelayTime:create(0.5)
  392. )
  393. )
  394. )
  395. end
  396. --刷新桌面背景和Logo
  397. self:setTableImg(Functions.getDefaultBg())
  398. end
  399. function RoomView_53:startGame()
  400. --起飞
  401. app.net:onMsgResume()
  402. end
  403. function RoomView_53:updateGameNums()
  404. -- 更新当前局数
  405. local roomInfo = app.room.roomInfo
  406. local curCount = roomInfo.nGameStartCount or 0
  407. local str = string.format("%02d / %02d", curCount, roomInfo.nTotalGameNum)
  408. self.ui.Items.Text_JuShu:setText(str)
  409. end
  410. function RoomView_53:onExit()
  411. RoomView_53.super.onExit(self)
  412. self:deInitSingleComponent()
  413. app.room:dispatchEvent({name = "onGameOverResponse"})
  414. stopBGMusic()
  415. self:cleanCache() -- jxtd 记得验证是否要删除
  416. end
  417. -- 清理缓存,用于测试
  418. function RoomView_53:cleanCache()
  419. local preload = package.loaded
  420. for k, v in pairs(package.loaded or {}) do
  421. local res1 = string.find( k, "pk_nanchongdoudizhu.luaScript") or 0
  422. if res1 > 0 then
  423. package.loaded[k] = nil
  424. end
  425. end
  426. end
  427. -- 其他玩家坐下成功
  428. function RoomView_53:onOtherSitDownResponse(data)
  429. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  430. self:checkGpsDistance(data.response.nUserId)
  431. self:refreshPlayer(true, viewId, app.room.roomInfo.memberList[data.response.nUserId])
  432. self:updateButtons()
  433. if not tolua.isnull(self.quickStartView) then
  434. self.quickStartView:removeView()
  435. self.quickStartView = nil
  436. end
  437. end
  438. function RoomView_53:updateButtons()
  439. local nGameStartCount = app.room.roomInfo.nGameStartCount or 0
  440. if nGameStartCount > 0 then
  441. -- 准备按钮
  442. self.toolView:setReadyVisible(false)
  443. -- 是否显示邀请好友
  444. self.toolView:setInviteVisible(false)
  445. -- 离开按钮
  446. self.toolView:setLeaveEnabled(false)
  447. -- 解散按钮
  448. self.toolView:setDissmissEnabled(true)
  449. else
  450. local myUserId = app.room:getMyUserId()
  451. -- 是否显示邀请好友
  452. if isReviewVersion() then
  453. self.toolView:setInviteVisible(false)
  454. else
  455. self.toolView:setInviteVisible(table.nums(app.room.roomInfo.memberList) < app.room.roomInfo.nMaxPlayCount)
  456. end
  457. -- 准备按钮
  458. local readyState = app.room.roomInfo.memberList[myUserId].nPlayerFlag or 0
  459. self.toolView:setReadyVisible(readyState == 0)
  460. -- 离开按钮
  461. self.toolView:setLeaveEnabled(true)
  462. -- 解散按钮
  463. local nRoomOwnedUid = app.room.roomInfo.nRoomOwnedUid or 0
  464. self.toolView:setDissmissEnabled(nRoomOwnedUid == app.room:getMyUserId() and (not app.club_php.clubID or (app.club_php.clubID and app.club_php.clubID == 0)))
  465. end
  466. end
  467. -- 因为updatebutton是在游戏开始才算,但是漂消息比游戏开始前还快
  468. function RoomView_53:updateButtonInPiao()
  469. -- 准备按钮
  470. self.toolView:setReadyVisible(false)
  471. -- 是否显示邀请好友
  472. self.toolView:setInviteVisible(false)
  473. -- 离开按钮
  474. self.toolView:setLeaveEnabled(false)
  475. -- 解散按钮
  476. self.toolView:setDissmissEnabled(true)
  477. end
  478. function RoomView_53:onOtherDroppedResponse(data)
  479. if not data.response then
  480. return
  481. end
  482. self:setPlayerOffLine(data.response.nOnlineStatus == 0, app.room:getViewIdByUserId(data.response.nUserId))
  483. end
  484. function RoomView_53:setPlayerOffLine(bVisible, viewId, times)
  485. --离线
  486. self.PlayerView:setOffLineVisible(bVisible, viewId)
  487. --[[
  488. if bVisible then
  489. local startTime = os.time()
  490. self.allNodes[viewId].offLine:stopAllActions()
  491. self.allNodes[viewId].offLine:runAction(
  492. cc.RepeatForever:create(
  493. cc.Sequence:create(
  494. cc.CallFunc:create(function()
  495. local endTime = os.time()
  496. local difTime = endTime - startTime + (times or 0)
  497. local timeStr = string.format("%02d : %02d", difTime / 60, difTime % 60)
  498. self.allNodes[viewId].offLineTime:setText(timeStr)
  499. end),
  500. cc.DelayTime:create(1.0)
  501. )
  502. )
  503. )
  504. end
  505. --]]
  506. end
  507. function RoomView_53:onOtherLogoutResponse(data)
  508. self:refreshPlayer(false, data.response.viewId)
  509. self:updateButtons()
  510. end
  511. function RoomView_53:onUserReadyResponse(data)
  512. --自己准备
  513. if app.room:getMyUserId() == data.response.nUserId then
  514. --重置桌面
  515. self:defaultState()
  516. --更新按钮状态
  517. self:updateButtons()
  518. end
  519. --显示准备
  520. self.PlayerView:setReadyVisible(true, app.room:getViewIdByUserId(data.response.nUserId))
  521. end
  522. --用户状态消息
  523. function RoomView_53:bindUserStatedMessage()
  524. --默认状态
  525. self:bindEvent(app.room , "defaultState", handler(self , self.defaultState))
  526. -- 玩家准备
  527. self:bindEvent(app.room , "onUserReadyResponse", handler(self , self.onUserReadyResponse))
  528. -- 其他玩家进入房间
  529. self:bindEvent(app.room , "onOtherSitDownResponse", handler(self , self.onOtherSitDownResponse))
  530. -- 其他玩家退出房間
  531. self:bindEvent(app.room , "onOtherLogoutResponse", handler(self , self.onOtherLogoutResponse))
  532. -- 其他玩家掉线
  533. self:bindEvent(app.room , "onOtherDroppedResponse", handler(self , self.onOtherDroppedResponse))
  534. -- 用户T出
  535. self:bindEvent(app.room , "onUserExitResponseRoom", handler(self , self.onUserExitResponseRoom))
  536. -- 玩家的GPS信息发生变化
  537. self:bindEvent(app.room , "onGpsChangeResponse", handler(self , self.onGpsChangeResponse))
  538. end
  539. --私人场消息
  540. function RoomView_53:bindPrivateMessage()
  541. -- 玩家收到解散房间的请求
  542. self:bindEvent(app.room , "onDismissResponse", handler(self , self.onDismissResponse))
  543. end
  544. --场景恢复
  545. function RoomView_53:bindGameSceneMessage()
  546. app.hall:addEventListener("onEnterRoomSuccess", handler(self , self.onEnterRoomSuccess))
  547. end
  548. function RoomView_53:onEnterRoomSuccess()
  549. if tolua.isnull(self.ui) then
  550. logE("self.is null")
  551. return
  552. end
  553. self:stopAllActions()
  554. self:onGameReconnection()
  555. self:startGame()
  556. end
  557. function RoomView_53:onGameReconnection()
  558. --默认状态
  559. self:defaultState()
  560. --是否开局
  561. if app.room.roomInfo.nGameStartCount > 0 then
  562. --恢复手牌
  563. self:initHandCards(app.room.roomInfo.memberList[app.room:getMyUserId()].handCards, self:getMeViewId())
  564. --显示头标记
  565. self:showHeadTip('piao')
  566. -- 漂阶段
  567. if app.room.roomInfo.nStatus == defs.GAME_STATUS.ASK_PIAO then
  568. for k,v in pairs(app.room.roomInfo.memberList) do
  569. if v.bAskPiao == 1 then -- 本轮操作过
  570. if v.nPiaoState ~= defs.PIAO_STATE.PIAO_STATE_WAIT then
  571. self.PlayerView:setTipsVisible("tips_piao", true, app.room:getViewIdByUserId(v.nUserId), { piaoState = v.nPiaoState })
  572. else
  573. self.PlayerView:setChoosePiaoVisible(true, app.room:getViewIdByUserId(v.nUserId))
  574. end
  575. else -- 本轮没操作,或者是之前操作过的
  576. if v.nPiaoState == defs.PIAO_STATE.PIAO_STATE_WAIT then
  577. self.PlayerView:setChoosePiaoVisible(true, app.room:getViewIdByUserId(v.nUserId))
  578. end
  579. end
  580. end
  581. local myMemberInfo = app.room.roomInfo.memberList[app.room:getMyUserId()]
  582. if myMemberInfo.nPiaoState == defs.PIAO_STATE.PIAO_STATE_WAIT then
  583. self:setPiaoVisible(true)
  584. end
  585. -- 闷抓/闷倒/闷拉 阶段
  586. elseif app.room.roomInfo.nStatus == defs.GAME_STATUS.MENZHUA then
  587. self.curViewId = app.room:getViewIdByUserId(app.room.roomInfo.currentUserId_Men)
  588. self.PlayerView:setClockVisibel(true, self.curViewId, app.room.roomInfo.currentLeftTime)
  589. -- 显示标记
  590. for k,v in pairs(app.room.roomInfo.memberList) do
  591. if self.curViewId ~= app.room:getViewIdByUserId(v.nUserId)then
  592. if v.nMenZhuaState <= defs.MEN_STATE.MEN_STATE_ZHUAI then -- 闷抓
  593. if v.nMenZhuaState ~= defs.MEN_STATE.MEN_STATE_WAIT then
  594. self.PlayerView:setTipsVisible("tips_menzhua", true, app.room:getViewIdByUserId(v.nUserId), { menzhua = v.nMenZhuaState })
  595. end
  596. elseif v.nMenZhuaState <= defs.MEN_STATE.MEN_STATE_DAO then -- 闷拉
  597. if v.nMenZhuaState ~= defs.MEN_STATE.MEN_STATE_DAO_WAIT then
  598. self.PlayerView:setTipsVisible("tips_mendao", true, app.room:getViewIdByUserId(v.nUserId), { mendao = v.nMenZhuaState })
  599. end
  600. end
  601. end
  602. end
  603. -- 显示界面
  604. if self.curViewId == self:getMeViewId() then
  605. local myMemberInfo = app.room.roomInfo.memberList[app.room:getMyUserId()]
  606. if myMemberInfo.nMenZhuaState == defs.MEN_STATE.MEN_STATE_WAIT then
  607. self:setMenZhuaVisible(true)
  608. elseif myMemberInfo.nMenZhuaState == defs.MEN_STATE.MEN_STATE_DAO_WAIT then
  609. self:setMenDaoVisible(true)
  610. elseif myMemberInfo.nMenLaState == defs.MEN_LA_STATE.MEN_STATE_LA_WAIT then
  611. self:setMenLaVisible(true)
  612. end
  613. end
  614. --叫地主阶段
  615. elseif app.room.roomInfo.nStatus == defs.GAME_STATUS.ASK_LOARD then
  616. --当前操作位置
  617. self.curViewId = app.room:getViewIdByUserId(app.room.roomInfo.currentUserId)
  618. --显示方位
  619. self.PlayerView:setClockVisibel(true, self.curViewId, app.room.roomInfo.currentLeftTime)
  620. --显示叫分状态
  621. for k,v in pairs(app.room.roomInfo.memberList) do
  622. if app.room.roomInfo.menZhuaUserId ~= v.nUserId then
  623. if v.bAskLoard == 1 then
  624. self.PlayerView:setTipsVisible("tips_jiaofen", true, app.room:getViewIdByUserId(v.nUserId), { askLoard = v.askLoard })
  625. end
  626. end
  627. end
  628. --是否显示叫分
  629. if self.curViewId == self:getMeViewId() then
  630. self:setAskLoardVisible(true, app.room.roomInfo.opType == 1)
  631. end
  632. --加倍阶段 倒/拉
  633. elseif app.room.roomInfo.nStatus == defs.GAME_STATUS.ASK_BEI then
  634. self.curViewId = app.room:getViewIdByUserId(app.room.roomInfo.currentUserId)
  635. -- 显示闹钟
  636. self.PlayerView:setClockVisibel(true, self.curViewId, app.room.roomInfo.currentLeftTime)
  637. --显示庄家
  638. self.PlayerView:setBankerVisible(true, app.room:getViewIdByUserId(app.room.roomInfo.nBankerId))
  639. --显示加倍状态
  640. for k,v in pairs(app.room.roomInfo.memberList) do
  641. -- if v.nDaoState == defs.DAO_STATE.DAO_STATE_YES then
  642. -- self.PlayerView:setTipsVisible("tips_jiabei", true, app.room:getViewIdByUserId(v.nUserId), { askBei = v.nDaoState })
  643. -- elseif v.nLaState == defs.DAO_STATE.LA_STATE_YES then
  644. -- self.PlayerView:setTipsVisible("tips_jiabei_la", true, app.room:getViewIdByUserId(v.nUserId), { askBei = v.nLaState })
  645. -- end
  646. if self.curViewId ~= app.room:getViewIdByUserId(v.nUserId)then
  647. if v.nDaoState ~= defs.DAO_STATE.DAO_STATE_WAIT then
  648. self.PlayerView:setTipsVisible("tips_jiabei", true, app.room:getViewIdByUserId(v.nUserId), { askBei = v.nDaoState })
  649. elseif v.nLaState ~= defs.DAO_STATE.LA_STATE_WAIT then
  650. self.PlayerView:setTipsVisible("tips_jiabei_la", true, app.room:getViewIdByUserId(v.nUserId), { askBei = v.nLaState })
  651. end
  652. end
  653. end
  654. --是否显示加倍(倒or拉)
  655. if self.curViewId == self:getMeViewId() then
  656. local myMemberInfo = app.room.roomInfo.memberList[app.room:getMyUserId()]
  657. if myMemberInfo.nDaoState == defs.DAO_STATE.DAO_STATE_WAIT then
  658. self:setAskBeiVisible(true)
  659. elseif myMemberInfo.nLaState == defs.DAO_STATE.LA_STATE_WAIT then
  660. self:setLaVisible(true)
  661. end
  662. end
  663. --打牌阶段
  664. elseif app.room.roomInfo.nStatus == defs.GAME_STATUS.PLAYING then
  665. --当前操作位置
  666. self.curViewId = app.room:getViewIdByUserId(app.room.roomInfo.currentUserId_Men)
  667. --显示方位
  668. self.PlayerView:setClockVisibel(true, self.curViewId, app.room.roomInfo.currentLeftTime)
  669. --显示庄家
  670. self.PlayerView:setBankerVisible(true, app.room:getViewIdByUserId(app.room.roomInfo.nBankerId))
  671. --最后一手手牌
  672. if app.room:checkUserIDIsInTable(app.room.roomInfo.lastUserId) then
  673. local lastViewId = app.room:getViewIdByUserId(app.room.roomInfo.lastUserId)
  674. self:setOutCardsVisible(true, lastViewId, { cards = app.room.roomInfo.lastCards, opType = app.room.roomInfo.lastCardType })
  675. end
  676. -- 显示头标记
  677. self:showHeadTip()
  678. -- 玩家数据
  679. for k,v in pairs(app.room.roomInfo.memberList) do
  680. -- 显示过
  681. if v.nGuo == 1 then
  682. self.PlayerView:setTipsVisible("tips_yaobuqi", true, app.room:getViewIdByUserId(v.nUserId))
  683. end
  684. --显示剩余手牌
  685. self.PlayerView:setLeftNumVisible(true, app.room:getViewIdByUserId(v.nUserId), table.nums(v.handCards))
  686. end
  687. --是否显示操作
  688. if self.curViewId == self:getMeViewId() then
  689. self:setOperationVisible(true, app.room.roomInfo.opType)
  690. end
  691. --小局结算阶段
  692. elseif app.room.roomInfo.nStatus == defs.GAME_STATUS.ROUND_OVER then
  693. --服务器会推送一个结算消息
  694. --恢复最后一手出牌
  695. local myMemberInfo = app.room.roomInfo.memberList[app.room:getMyUserId()]
  696. if myMemberInfo.nPlayerFlag == 0 then
  697. self:setOutCardsVisible(true, app.room:getViewIdByUserId(app.room.roomInfo.lastUserId), { cards = app.room.roomInfo.lastCards, opType = app.room.roomInfo.lastCardType })
  698. end
  699. end
  700. --显示底牌和底分炸弹情况
  701. if app.room:checkUserIDIsInTable(app.room.roomInfo.nBankerId) and table.nums(app.room.roomInfo.bankerCards) > 0 then
  702. self:setBanderCardsVisible(true, app.room.roomInfo.bankerCards)
  703. end
  704. --是否有人发起解散
  705. self:judgeDissmiss()
  706. end
  707. end
  708. function RoomView_53:setXiaoJuVisible(bVisible, data)
  709. if self.XiaoJuView then
  710. --显示
  711. self.XiaoJuView:setVisible(bVisible)
  712. end
  713. if bVisible then
  714. --显示玩家数据
  715. for _,v in pairs(data.memberList) do
  716. local viewId = app.room:getViewIdByUserId(v.nUserId)
  717. --显示剩余手牌
  718. if v.nUserId ~= app.room:getMyUserId() and v.nUserId ~= data.nWinId then
  719. self:setOutCardsVisible(true, viewId, { cards = v.handCards, maxLen = 10 })
  720. end
  721. --刷新分数
  722. self.PlayerView:updateScore(viewId, v.nTotalScore)
  723. end
  724. --显示小局结算
  725. if not self.XiaoJuView then
  726. function xiaYiJu()
  727. if app.room.roomInfo.isGameOver == 1 then
  728. -- self:goToHall()
  729. self:showDaJu(app.room.roomInfo._GameOverInfo)
  730. else
  731. self.ui:sendMsg(app.room, "callReadyRequest")
  732. end
  733. end
  734. self.XiaoJuView = import("pk_nanchongdoudizhu.luaScript.Views.Room.RoomXiaoJuView_" .. app.gameId):new(xiaYiJu)
  735. self.ui.Items.Layout_XiaoJu:addChild(self.XiaoJuView)
  736. end
  737. --更新界面数据
  738. self.XiaoJuView:updateView(data)
  739. end
  740. end
  741. function RoomView_53:judgeDissmiss()
  742. local roomInfo = app.room.roomInfo
  743. --解散状态
  744. local uid = 0
  745. local isDismiss = false
  746. for k,v in pairs(roomInfo.memberList) do
  747. local viewId = app.room:getViewIdByUserId(k)
  748. --记录玩家解散状态 0:初始状态, 1:发起解散 2: 同意解散 3:不同意解散
  749. app.room.dismissInfo[k] = v.disbandStatus
  750. --有人发起解散时才显示解散界面
  751. if v.disbandStatus == 1 then
  752. isDismiss = true
  753. uid = k
  754. end
  755. end
  756. --有人发起解散时才显示解散界面
  757. if isDismiss then
  758. local memberList = {}
  759. for nUserId,memberInfo in pairs(roomInfo.memberList) do
  760. if app.room:checkUserIDIsInTable(nUserId) then
  761. memberList[nUserId] = memberInfo
  762. memberList[nUserId].nDisbandStatus = memberInfo.disbandStatus
  763. end
  764. end
  765. local view = import("luaScript.Views.Room.RoomDismissView"):new(uid, memberList, roomInfo.nDismissStateTime)
  766. view:setAnchorPoint(cc.p(0.5, 0.5))
  767. app:showWaitDialog(view)
  768. end
  769. end
  770. function RoomView_53:goToHall()
  771. app:gotoView(import("luaScript.Views.Main.MainView"):new(GAME_IDS.NanChongDouDiZhu))
  772. end
  773. function RoomView_53:leaveRoomRequest()
  774. app.room.roomInfo.bQuitRoom = true
  775. self.ui:sendMsg(app.room, "callLeaveRequest")
  776. end
  777. -- 服务器广播玩家数据发生变化
  778. function RoomView_53:onGpsChangeResponse(data)
  779. logD("RoomView_53:onGpsChangeResponse()")
  780. if not data or not data.nUserId then
  781. return
  782. end
  783. local nUserId = data.nUserId
  784. logD("RoomView_53:onGpsChangeResponse()", tostring(nUserId))
  785. self:checkGpsDistance(nUserId)
  786. end
  787. -- 检查服务器记录的我的GPS数据是最新的,如果不是,则请求更新
  788. function RoomView_53:checkMyGpsNeedUpdate()
  789. logD("RoomView_53:checkMyGpsNeedUpdate()")
  790. local nMyUserId = app.user.loginInfo.uid
  791. local myMemberInfo = app.room.roomInfo.memberList[nMyUserId]
  792. if myMemberInfo then
  793. local userInfo = json.decode(myMemberInfo.userInfo)
  794. if userInfo then
  795. local gpsInfo = userInfo.gpsInfo
  796. local isNewest = app.user:isGpsInfoNewest(gpsInfo)
  797. logD("RoomView_53:checkMyGpsNeedUpdate() gpsInfo is isNewest = ", tostring(isNewest))
  798. if not isNewest then
  799. app.room:onGpsChangeRequest()
  800. else
  801. logD("RoomView_53:checkMyGpsNeedUpdate() gpsInfo is newest")
  802. end
  803. else
  804. logD("RoomView_53:checkMyGpsNeedUpdate() userInfo is nil")
  805. end
  806. else
  807. logD("RoomView_53:checkMyGpsNeedUpdate() myMemberInfo is nil")
  808. end
  809. end
  810. -- 更新所有玩家的信息到GPS组件
  811. function RoomView_53:updateAllGpsInfo()
  812. local userInfoList = {}
  813. for nUserId, memberInfo in pairs(app.room.roomInfo.memberList) do
  814. local nSeatId = memberInfo.nSeatId
  815. local userInfo = memberInfo.userInfo
  816. if userInfo then
  817. userInfoList[nUserId] = {nSeatId = nSeatId, userInfo = userInfo}
  818. end
  819. end
  820. if self.gpsComponent then
  821. self.gpsComponent:updateUserInfos(userInfoList)
  822. end
  823. end
  824. -- 检测玩家与其他玩家之间的距离
  825. -- 如果不传参数,则检测所有玩家相互之间的距离
  826. function RoomView_53:checkGpsDistance(curUserId)
  827. if app.room.roomInfo.nGameStartCount > 0 then
  828. return
  829. end
  830. self:updateAllGpsInfo()
  831. if self.gpsComponent then
  832. self.gpsComponent:checkGpsDistance(curUserId)
  833. end
  834. end
  835. -- 显示GPS界面
  836. function RoomView_53:showGpsView()
  837. logD("RoomView_53:showGpsView()")
  838. local isGameStart = app.room.roomInfo.nGameStartCount > 0
  839. local exitRoomCallback = function()
  840. self.ui:sendMsg(app.room, "callLeaveRequest")
  841. end
  842. local dismissCallback = function()
  843. app.room:requestDismissRoom(1)
  844. end
  845. self:updateAllGpsInfo()
  846. if self.gpsComponent then
  847. self.gpsComponent:showGpsView(app.room.roomInfo.nMaxPlayCount, isGameStart, exitRoomCallback, dismissCallback)
  848. end
  849. end
  850. -- 玩家收到解散房间的请求
  851. function RoomView_53:onDismissResponse(event)
  852. logE("onDismissResponse() response = ", event.response)
  853. if not event or not event.response then
  854. return
  855. end
  856. local response = event.response
  857. --当前时间
  858. app.room.roomInfo.nDismissStateTime = response.timeLeft
  859. --总的时间,服务器没发解散总时间来。那么就和一开始收到的解散剩余时间一致
  860. app.room.roomInfo.nDismissToTalTime = response.timeLeft
  861. --显示解散(此标志会影响闹钟时间会冻住)
  862. app.room.roomInfo.nShowDismiss = true
  863. if response.operateType == 1 then
  864. local memberList = {}
  865. for nUserId,memberInfo in pairs(app.room.roomInfo.memberList) do
  866. if app.room:checkUserIDIsInTable(nUserId) then
  867. memberList[nUserId] = memberInfo
  868. end
  869. end
  870. if response.memberList ~= nil then
  871. for k,v in pairs(response.memberList) do
  872. if v.dismissState == 1 then
  873. local view = import("luaScript.Views.Room.RoomDismissView"):new(v.nUserId, memberList, app.room.roomInfo.nDismissStateTime)
  874. view:setAnchorPoint(cc.p(0.5, 0.5))
  875. app:showWaitDialog(view)
  876. return
  877. end
  878. end
  879. else
  880. local view = import("luaScript.Views.Room.RoomDismissView"):new(response.nUserId, memberList, app.room.roomInfo.nDismissStateTime)
  881. view:setAnchorPoint(cc.p(0.5, 0.5))
  882. app:showWaitDialog(view)
  883. end
  884. else
  885. local memberStatus={}
  886. if response.memberList ~= nil then
  887. for k,v in pairs(response.memberList) do
  888. table.insert(memberStatus,{userId = v.nUserId, status = v.dismissState})
  889. end
  890. else
  891. table.insert(memberStatus,{userId = response.nUserId, status = response.operateType})
  892. end
  893. app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_UPDATE_STATUS , memberStatus = memberStatus})
  894. end
  895. end
  896. function RoomView_53:addCallBack(callback)
  897. table.insert(self.callbackQueue, callback)
  898. logE(" #self.callbackQueue:".. #self.callbackQueue)
  899. --高延迟情况下,执行快速播放,15条是没有标准,根据实际调整的
  900. --if #self.callbackQueue >= 15 then
  901. --cc.Director:getInstance():getScheduler():setTimeScale(5.0)
  902. --else
  903. cc.Director:getInstance():getScheduler():setTimeScale(1.0)
  904. --end
  905. local function runFunc()
  906. log("2000000000 - runNextFunc() size = ", #self.callbackQueue )
  907. if #self.callbackQueue <= 0 then
  908. self.callbackRunning = false
  909. return
  910. end
  911. local func = self.callbackQueue[1]
  912. table.remove(self.callbackQueue,1)
  913. self.callbackRunning = true
  914. func(function()
  915. self.callbackRunning = false
  916. runFunc()
  917. end)
  918. end
  919. log("self.callbackRunning:",self.callbackRunning)
  920. if not self.callbackRunning then
  921. runFunc()
  922. end
  923. end
  924. function RoomView_53:onChangeTable(data)
  925. self:setTableImg(data.idx)
  926. end
  927. function RoomView_53:onChangeBgm(data)
  928. local idx = nil
  929. if not data or not data.idx then
  930. idx = tonumber(loadUserInfo("BgmChooseType" .. app.gameId)) or defs.BGM_CHOOSE_TYPE.JING_DIAN
  931. else
  932. idx = data.idx
  933. end
  934. if idx then
  935. Functions.playMusic(idx)
  936. end
  937. end
  938. function RoomView_53:setTableImg(idx)
  939. --桌布
  940. self.ui.Items.ImageView_bg:loadTexture(defs.BG_Img[idx] and defs.BG_Img[idx] or defs.BG_Img[1])
  941. self:initLogo()
  942. end
  943. function RoomView_53:initLogo()
  944. if tolua.isnull(self.ui.Items.ImageView_Logo) then
  945. return
  946. end
  947. if not (type(getSubGameRoomLogo) == 'function') then
  948. self.ui.Items.ImageView_Logo:setVisible(false)
  949. return
  950. end
  951. local roomInfo = app.room.roomInfo
  952. local gameInfo = json.decode(roomInfo.strGameInfo or "")
  953. local gamerule = tonumber(gameInfo.gamerule or 1)
  954. roomInfo.gameId = roomInfo.gameId or app.gameId or 0
  955. local logofile = getSubGameRoomLogo(roomInfo.gameId, gamerule)
  956. if logofile then
  957. self.ui.Items.ImageView_Logo:loadTexture(logofile)
  958. self.ui.Items.ImageView_Logo:setVisible(true);
  959. else
  960. self.ui.Items.ImageView_Logo:setVisible(false);
  961. end
  962. end
  963. function RoomView_53:ontSetPropEnabled(event)
  964. -- if self.messageView then
  965. -- self.messageView:setPropEnabled(event.value == 1)
  966. -- end
  967. self.PlayerView:ontSetPropEnabled()
  968. end
  969. function RoomView_53:onSetVoiceEnabled(event)
  970. -- if self.messageView then
  971. -- self.messageView:setVoiceEnabled(event.value == 1)
  972. -- end
  973. self.PlayerView:onSetVoiceEnabled()
  974. end
  975. function RoomView_53:onNormalChangePoker(data)
  976. if data.idx > 2 and data.idx < 1 then
  977. return
  978. end
  979. local temp = {
  980. "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cards/doudizhu_pokerCards_old.plist",
  981. "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cards/doudizhu_pokerCards.plist",
  982. }
  983. -- 删除缓存重新添加缓存
  984. for i, v in ipairs(temp) do
  985. cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile(v)
  986. end
  987. loadSpriteFrameFile(temp[data.idx])
  988. -- 刷新当前手牌
  989. if self.handCards then
  990. local myHandCardLayout = self.handCards["" .. self:getMeViewId()]
  991. if myHandCardLayout then
  992. for i, v in ipairs(myHandCardLayout) do
  993. if v.refreshCard then
  994. v:refreshCard()
  995. end
  996. end
  997. self:rankHandCards(self:getMeViewId(), false)
  998. end
  999. end
  1000. -- 刷新当前出的牌
  1001. for _, v in pairs(app.room.roomInfo.memberList) do
  1002. local viewId = app.room:getViewIdByUserId(v.nUserId)
  1003. local outCardLayout = self.ui.Items["Layout_Out_" .. viewId]
  1004. if outCardLayout then
  1005. for _, card in ipairs(outCardLayout:getChildren()) do
  1006. if card.refreshCard then
  1007. card:refreshCard()
  1008. end
  1009. end
  1010. end
  1011. end
  1012. end
  1013. --自己的视图ID
  1014. function RoomView_53:getMeViewId()
  1015. return defs.VIEW_ID.MY_VIEW_ID
  1016. end
  1017. function RoomView_53:cmd_0x8104_Resp(data)
  1018. function cmd_0x8104_RespEx(onEnd)
  1019. playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_began.ogg")
  1020. self.PlayerView:setLeftNumVisible(true, -1, 17)
  1021. --更新局数
  1022. self:updateGameNums()
  1023. --更新按钮状态
  1024. self:updateButtons()
  1025. --隐藏所有准备
  1026. self:setAllReadyVisible(false)
  1027. -- 隐藏所有标记
  1028. self.PlayerView:hideAllTip()
  1029. if onEnd then
  1030. onEnd()
  1031. end
  1032. end
  1033. self:addCallBack(cmd_0x8104_RespEx)
  1034. end
  1035. --显隐所有准备
  1036. function RoomView_53:setAllReadyVisible(bVisible)
  1037. for k,v in pairs(app.room.roomInfo.memberList) do
  1038. self.PlayerView:setReadyVisible(bVisible, app.room:getViewIdByUserId(v.nUserId))
  1039. end
  1040. end
  1041. function RoomView_53:cmd_0x8105_Resp(data)
  1042. function cmd_0x8105_RespEx(onEnd)
  1043. --加倍阶段,隐藏叫分相关界面
  1044. if data.response.nStatus == defs.GAME_STATUS.ASK_BEI then
  1045. self:setAskLoardVisible(false)
  1046. for _,v in pairs(app.room.roomInfo.memberList) do
  1047. self.PlayerView:setTipsVisible("tips_jiaofen", false, app.room:getViewIdByUserId(v.nUserId))
  1048. end
  1049. --打牌阶段,隐藏加倍相关界面
  1050. elseif data.response.nStatus == defs.GAME_STATUS.PLAYING then
  1051. self:setAskBeiVisible(false)
  1052. for _,v in pairs(app.room.roomInfo.memberList) do
  1053. self.PlayerView:setTipsVisible("tips_jiabei", false, app.room:getViewIdByUserId(v.nUserId))
  1054. self.PlayerView:setTipsVisible("tips_jiabei_la", false, app.room:getViewIdByUserId(v.nUserId))
  1055. end
  1056. self:showHeadTip()
  1057. end
  1058. if data.response.nStatus == defs.GAME_STATUS.SENDCARDS then
  1059. self.PlayerView:setLeftNumVisible(true, -1, 17)
  1060. end
  1061. if onEnd then
  1062. onEnd()
  1063. end
  1064. end
  1065. self:addCallBack(cmd_0x8105_RespEx)
  1066. end
  1067. function RoomView_53:getCardType(card)
  1068. return self._pokerUtil:getCardType(card)
  1069. end
  1070. function RoomView_53:getCardValue(card)
  1071. return self._pokerUtil:getCardValue(card)
  1072. end
  1073. function RoomView_53:setCardUp(card)
  1074. card.isUp = true
  1075. self.selectCards["" .. card.cardNum] = card
  1076. -- card:setPosition(cc.pAdd(card.tarPos, cc.p(0, 35)))
  1077. -- 抬起动画
  1078. card:stopAllActions()
  1079. local moveTo = cc.MoveTo:create(Card_Move_Up_Down_Time, cc.pAdd(card.tarPos, cc.p(0, 28)))
  1080. card:runAction(moveTo)
  1081. end
  1082. function RoomView_53:setCardDown(card)
  1083. card.isUp = false
  1084. -- card:setPosition(card.tarPos)
  1085. -- 下放动画
  1086. card:stopAllActions()
  1087. local moveTo = cc.MoveTo:create(Card_Move_Up_Down_Time, card.tarPos)
  1088. card:runAction(moveTo)
  1089. end
  1090. function RoomView_53:handCardItemRegisterTouchEvent(handCard)
  1091. local nomalColor = cc.c3b(255,255,255)
  1092. local selectColor = cc.c3b(200,200,200)
  1093. function onTouchBegan(touch, event)
  1094. local target = event:getCurrentTarget()
  1095. local locationInNode = target:convertToNodeSpace(touch:getLocation())
  1096. local s = target:getContentSize()
  1097. local rect = cc.rect(0, 0, s.width, s.height)
  1098. if cc.rectContainsPoint(rect, locationInNode) then
  1099. self.touchBeganPos = touch:getLocation()
  1100. target:setColor(selectColor)
  1101. target.isHit = true
  1102. return true
  1103. else
  1104. return false
  1105. end
  1106. end
  1107. function onTouchMoved(touch, event)
  1108. local touchMovePos = touch:getLocation()
  1109. local direction = touchMovePos.x - self.touchBeganPos.x
  1110. local handCards = self.handCards["" .. self:getMeViewId()]
  1111. --灵敏度
  1112. if math.abs(direction) < 5 then
  1113. return
  1114. end
  1115. if handCards then
  1116. for k,v in ipairs(handCards) do
  1117. local needContain = true
  1118. if v.isHit then
  1119. local locationInWorld = v:getParent():convertToWorldSpace(v:getPosition())
  1120. if direction > 0 then
  1121. if touchMovePos.x > locationInWorld.x - v:getContentSize().width / 2 + (v:getContentSize().width - self.handCardDif) then
  1122. needContain = false
  1123. end
  1124. else
  1125. if touchMovePos.x < locationInWorld.x - v:getContentSize().width / 2 then
  1126. needContain = false
  1127. end
  1128. end
  1129. end
  1130. if needContain then
  1131. local cardSize = v:getContentSize()
  1132. local locationInNode = v:convertToNodeSpace(touch:getLocation())
  1133. local rectEx = cc.rect(0, 0, cardSize.width - self.handCardDif, cardSize.height)
  1134. if cc.rectContainsPoint(rectEx, locationInNode) then
  1135. v:setColor(selectColor)
  1136. v.isHit = true
  1137. else
  1138. v:setColor(nomalColor)
  1139. v.isHit = false
  1140. end
  1141. end
  1142. end
  1143. end
  1144. end
  1145. function onTouchEnded(touch, event)
  1146. local handCards = self.handCards["" .. self:getMeViewId()]
  1147. if handCards then
  1148. -- for k,v in ipairs(handCards) do
  1149. -- if v.isHit then
  1150. -- if v.isUp then
  1151. -- self:setCardDown(v)
  1152. -- else
  1153. -- self:setCardUp(v)
  1154. -- end
  1155. -- end
  1156. -- v:setColor(nomalColor)
  1157. -- v.isHit = false
  1158. -- end
  1159. local isAllNormal = true
  1160. for _,card in pairs(handCards) do
  1161. if card then
  1162. if card.isUp then
  1163. isAllNormal = false
  1164. break
  1165. end
  1166. end
  1167. end
  1168. local selectCards = {}
  1169. for k,card in ipairs(handCards) do
  1170. if card.isHit then
  1171. table.insert(selectCards, card.cardNum)
  1172. end
  1173. end
  1174. -- 过滤选择的牌(主动出牌)
  1175. if isAllNormal then
  1176. if #self.lastData.cards <= 0 then
  1177. if self._pokerUtil and self._pokerUtil.getCardInSelectCard then
  1178. selectCards = self._pokerUtil:getCardInSelectCard(selectCards)
  1179. end
  1180. end
  1181. end
  1182. for i, v in ipairs(selectCards) do
  1183. local node = self:getCardNodeByCardValue(v)
  1184. if node then
  1185. if node.isUp then
  1186. self:setCardDown(node)
  1187. else
  1188. self:setCardUp(node)
  1189. end
  1190. node:setColor(nomalColor)
  1191. node.isHit = false
  1192. end
  1193. end
  1194. for i, card in ipairs(handCards) do
  1195. if card.isHit then
  1196. card:setColor(nomalColor)
  1197. card.isHit = false
  1198. end
  1199. end
  1200. end
  1201. end
  1202. -- 创建一个事件监听器
  1203. local listener = cc.EventListenerTouchOneByOne:create()
  1204. --设置穿透属性
  1205. listener:setSwallowTouches(true)
  1206. --添加事件和回调
  1207. listener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN)
  1208. listener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED)
  1209. listener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED)
  1210. -- 得到事件派发器
  1211. local eventDispatcher = self:getEventDispatcher()
  1212. -- 将监听器注册到派发器中
  1213. eventDispatcher:addEventListenerWithSceneGraphPriority(listener, handCard)
  1214. end
  1215. function RoomView_53:initHandCardItem(card, viewId)
  1216. local switchEx = {}
  1217. local cardType = self:getCardType(card)
  1218. local cardValue = self:getCardValue(card)
  1219. local scaleEx = 0.35
  1220. switchEx["1"] = function()
  1221. -- local card = cc.Sprite:create(string.format("pk/res/ui/zy_fangjian/pk_cards/pk_cards_%d_%d.png", cardType, cardValue)) -- 旧资源
  1222. local card = cc.Sprite:createWithSpriteFrameName(string.format("ddz_cards_%d_%d.png", cardType, cardValue)) -- 新资源
  1223. card:setAnchorPoint(cc.p(1, 1))
  1224. card:setScale(scaleEx)
  1225. return card
  1226. end
  1227. switchEx["2"] = function()
  1228. -- local card = cc.Sprite:create(string.format("pk/res/ui/zy_fangjian/pk_cards/pk_cards_%d_%d.png", cardType, cardValue)) -- 旧资源
  1229. local card = cc.Sprite:createWithSpriteFrameName(string.format("ddz_cards_%d_%d.png", cardType, cardValue)) -- 新资源
  1230. card:setAnchorPoint(cc.p(1, 1))
  1231. card:setScale(scaleEx)
  1232. return card
  1233. end
  1234. switchEx["3"] = function()
  1235. -- local card = cc.Sprite:create(string.format("pk/res/ui/zy_fangjian/pk_cards/pk_cards_%d_%d.png", cardType, cardValue)) -- 旧资源
  1236. local card = cc.Sprite:createWithSpriteFrameName(string.format("ddz_cards_%d_%d.png", cardType, cardValue)) -- 新资源
  1237. card:setAnchorPoint(cc.p(0, 1))
  1238. card:setScale(scaleEx)
  1239. return card
  1240. end
  1241. switchEx["4"] = function()
  1242. -- return cc.Sprite:create(string.format("pk/res/ui/zy_fangjian/pk_cards/pk_cards_%d_%d.png", cardType, cardValue)) -- 旧资源
  1243. return cc.Sprite:createWithSpriteFrameName(string.format("ddz_cards_%d_%d.png", cardType, cardValue)) -- 新资源
  1244. -- local card = cc.Sprite:createWithSpriteFrameName(string.format("ddz_cards_%d_%d.png", cardType, cardValue)) -- 新资源
  1245. -- card:setScale(scaleEx)
  1246. -- return card
  1247. end
  1248. local initFunc = switchEx["" .. viewId]
  1249. if initFunc then
  1250. local imageCard = initFunc()
  1251. if imageCard then
  1252. imageCard.cardValue = cardValue -- 牌具体值1~13
  1253. imageCard.cardType = cardType -- 牌类型
  1254. imageCard.cardNum = card -- 牌的标准值
  1255. imageCard.refreshCard = function() -- 刷新卡牌
  1256. if card > 0 then
  1257. local cardPng = string.format("ddz_cards_%d_%d.png", cardType, cardValue)
  1258. imageCard:setSpriteFrame(cardPng)
  1259. if imageCard.bankerMark then
  1260. local size = imageCard:getContentSize()
  1261. local offsetX, offsetY = self:getBankTagOffset()
  1262. imageCard.bankerMark:setPosition(cc.p(size.width * 0.72 + offsetX, size.height * 0.784 + offsetY))
  1263. end
  1264. end
  1265. end
  1266. if viewId == self:getMeViewId() then
  1267. self:handCardItemRegisterTouchEvent(imageCard)
  1268. end
  1269. -- 设置为庄家牌
  1270. if self:checkIsBankCard(imageCard.cardNum, viewId) then
  1271. imageCard.isBankCard = true
  1272. end
  1273. end
  1274. logE("initHandCardItem viewId " .. viewId .. "imageCard " .. imageCard.cardNum)
  1275. return imageCard
  1276. end
  1277. end
  1278. function RoomView_53:rankHandCards(viewId, ani)
  1279. local childs = self.handCards["" .. viewId]
  1280. if childs then
  1281. local isBanker = app.room.roomInfo.nBankerId and app.room.roomInfo.nBankerId > 0 and app.room:getViewIdByUserId(app.room.roomInfo.nBankerId) == viewId
  1282. local childsNum = table.nums(childs)
  1283. local xDiff = -30 --x轴调整
  1284. local getPokerChoose = tonumber(loadUserInfo("ddz_setting_poker")) or defs.Default_Poker_Choose
  1285. local cardDif = (getPokerChoose == 1) and 96 or 110
  1286. if childsNum > 17 then -- 使得扑克超过17张的话,让扑克牌组挤一点
  1287. self.handCardDif = cardDif + 3 * (childsNum - 17)
  1288. else
  1289. self.handCardDif = cardDif
  1290. end
  1291. for k,v in ipairs(childs) do
  1292. local maxLen = 12
  1293. local kEx = tonumber(k)
  1294. local floor = math.floor(kEx / maxLen)
  1295. local mod = kEx % maxLen + (kEx >= maxLen and 1 or 0)
  1296. local childScale = v:getScale()
  1297. local childSize = v:getContentSize()
  1298. if viewId == defs.VIEW_ID.MY_VIEW_ID then
  1299. v.tarPos = cc.p(xDiff + (kEx - childsNum / 2) * (childSize.width - self.handCardDif) * childScale.x, childSize.height / 2 * childScale.y)
  1300. elseif viewId == defs.VIEW_ID.TOP_VIEW_ID then
  1301. --设置zOder
  1302. v:setLocalZOrder(maxLen * floor - kEx)
  1303. v.tarPos = cc.p((-1) * mod * (childSize.width - self.handCardDif) * childScale.x, (-1) * childSize.height * childScale.y * 0.5 * floor)
  1304. elseif viewId == defs.VIEW_ID.LEFT_VIEW_ID then
  1305. v.tarPos = cc.p(mod * (childSize.width - self.handCardDif) * childScale.x, (-1) * childSize.height * childScale.y * 0.5 * floor)
  1306. elseif viewId == defs.VIEW_ID.RIGHT_VIEW_ID then
  1307. v:setLocalZOrder(maxLen * floor - kEx)
  1308. v.tarPos = cc.p((-1) * mod * (childSize.width - self.handCardDif) * childScale.x, (-1) * childSize.height * childScale.y * 0.5 * floor)
  1309. end
  1310. --庄家标识
  1311. if isBanker then
  1312. if v.isBankCard then
  1313. if v.bankerMark then
  1314. v.bankerMark:setVisible(true)
  1315. else
  1316. v.bankerMark = cc.Sprite:create(string.format("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_bankerCardMark.png"))
  1317. local offsetX, offsetY = self:getBankTagOffset()
  1318. v.bankerMark:setPosition(cc.p(childSize.width * 0.72 + offsetX, childSize.height * 0.784 + offsetY))
  1319. v:addChild(v.bankerMark)
  1320. end
  1321. end
  1322. end
  1323. if ani then
  1324. v:stopAllActions()
  1325. v:runAction(cc.MoveTo:create(0.15, v.tarPos))
  1326. else
  1327. v:setPosition(v.tarPos)
  1328. end
  1329. end
  1330. end
  1331. end
  1332. function RoomView_53:initHandCards(handCards, viewId)
  1333. local handLayout = self.ui.Items["Layout_Hand_" .. viewId]
  1334. --手牌
  1335. self.handCards = self.handCards or {}
  1336. --选中的牌
  1337. self.selectCards = self.selectCards or {}
  1338. if handLayout then
  1339. handLayout:removeAllChildren()
  1340. --排序手牌
  1341. table.sort(handCards.Datas, function(a, b)
  1342. local cardValueA = self:getCardValue(a.card)
  1343. local cardValueB = self:getCardValue(b.card)
  1344. return cardValueA > cardValueB or cardValueA == cardValueB and self:getCardType(a.card) > self:getCardType(b.card)
  1345. end)
  1346. if Functions.getRuleIncludeLzWanFa() then
  1347. local temp = {}
  1348. for i = #handCards.Datas, 1, -1 do
  1349. if self._pokerUtil:isGodCard(handCards.Datas[i].card) then
  1350. table.insert(temp, handCards.Datas[i])
  1351. table.remove(handCards.Datas, i)
  1352. end
  1353. end
  1354. for i, v in ipairs(temp) do
  1355. table.insert(handCards.Datas, 1, v)
  1356. end
  1357. end
  1358. for k,v in ipairs(handCards.Datas) do
  1359. local imageCard = self:initHandCardItem(v.card, viewId)
  1360. if imageCard then
  1361. handLayout:addChild(imageCard)
  1362. end
  1363. end
  1364. self.handCards["" .. viewId] = handLayout:getChildren()
  1365. end
  1366. self:rankHandCards(viewId)
  1367. end
  1368. function RoomView_53:fapaiAni(onEnd)
  1369. self._isCanClickBg = false
  1370. local handCards = self.handCards["" .. self:getMeViewId()]
  1371. if not handCards then
  1372. logE("RoomView_53 fapaiAni error")
  1373. if onEnd then
  1374. onEnd()
  1375. end
  1376. end
  1377. for k,v in ipairs(handCards) do
  1378. v:setPosition(cc.pAdd(v.tarPos, cc.p(1280, 0)))
  1379. v:runAction(
  1380. cc.Sequence:create(
  1381. cc.DelayTime:create(0.03 * tonumber(k)),
  1382. cc.MoveTo:create(0, v.tarPos),
  1383. cc.CallFunc:create(function()
  1384. --playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_fapai.ogg")
  1385. if tonumber(k) == table.nums(handCards) then
  1386. self._isCanClickBg = true
  1387. if onEnd then
  1388. onEnd()
  1389. end
  1390. end
  1391. end)
  1392. )
  1393. )
  1394. end
  1395. end
  1396. function RoomView_53:cmd_0x8106_Resp(data)
  1397. function cmd_0x8106_Resp(onEnd)
  1398. local handCards = app.room.roomInfo.memberList[app.room:getMyUserId()].handCards
  1399. self:initHandCards(handCards, self:getMeViewId())
  1400. local totalCard = self._pokerUtil.Card_Max_Length
  1401. if table.nums(handCards) == totalCard then
  1402. local bankerCards = {}
  1403. for _,v in ipairs(app.room.roomInfo.bankerCards) do
  1404. table.insert(bankerCards, v.card)
  1405. end
  1406. --从手牌中上升地主牌
  1407. self:setHandCardsUp(self:getMeViewId(), bankerCards)
  1408. if onEnd then
  1409. onEnd()
  1410. end
  1411. else
  1412. self:fapaiAni(onEnd)
  1413. end
  1414. end
  1415. self:addCallBack(cmd_0x8106_Resp)
  1416. end
  1417. function RoomView_53:setPiaoVisible(bVisible)
  1418. self.ui.Items.Layout_Piao:setVisible(bVisible)
  1419. end
  1420. function RoomView_53:setMenZhuaVisible(bVisible)
  1421. self.ui.Items.Layout_MenZhua:setVisible(bVisible)
  1422. end
  1423. function RoomView_53:setMenDaoVisible(bVisible)
  1424. self.ui.Items.Layout_MenDao:setVisible(bVisible)
  1425. end
  1426. function RoomView_53:setMenLaVisible(bVisible)
  1427. self.ui.Items.Layout_MenLa:setVisible(bVisible)
  1428. end
  1429. function RoomView_53:setAskLoardVisible(bVisible, biJiao)
  1430. self.ui.Items.Layout_Ask_Loard:setVisible(bVisible)
  1431. if bVisible then
  1432. local curAskLoard = app.room.roomInfo.curAskLoard or 0
  1433. for i = 0, 1 do
  1434. local askLoardBtn = self.ui.Items["Button_Ask_Loard_F_" .. i]
  1435. if askLoardBtn then
  1436. if biJiao then
  1437. askLoardBtn:setEnabled(i == 1)
  1438. else
  1439. askLoardBtn:setEnabled(true)
  1440. end
  1441. end
  1442. end
  1443. self.ui.Items.Layout_Ask_Loard_Buttons:requestDoLayout()
  1444. self.ui.Items.Layout_Ask_Loard_Buttons:doLayout()
  1445. end
  1446. end
  1447. function RoomView_53:setAskBeiVisible(bVisible)
  1448. self.ui.Items.Layout_Ask_Bei:setVisible(bVisible)
  1449. end
  1450. function RoomView_53:setLaVisible(bVisible)
  1451. self.ui.Items.Layout_La:setVisible(bVisible)
  1452. end
  1453. function RoomView_53:setOperationVisible(bVisible, opType)
  1454. self.ui.Items.Layout_Operation:setVisible(bVisible)
  1455. if bVisible then
  1456. -- opType: 0要不起(没有可压牌), 1可要可不要, 2必须出(轮到自己了)
  1457. if opType == 1 then
  1458. -- 这种风格是,全程没有变灰的按钮,直接就隐藏掉
  1459. self.ui.Items.Layout_Operation_BuChu:setVisible(bVisible)
  1460. self.ui.Items.Layout_Operation_TiShi:setVisible(bVisible)
  1461. self.ui.Items.Layout_Operation_ChuPai:setVisible(bVisible)
  1462. self.ui.Items.Layout_Operation_YaoBuQi:setVisible(not bVisible)
  1463. -- 这种风格是,有变灰的按钮,不可点击,下面同理
  1464. --[[
  1465. self.ui.Items.Button_Operation_BuChu:setEnabled(bVisible)
  1466. self.ui.Items.Button_Operation_TiShi:setEnabled(bVisible)
  1467. self.ui.Items.Button_Operation_ChuPai:setEnabled(bVisible)
  1468. self.ui.Items.Layout_Operation_YaoBuQi:setVisible(false)
  1469. ]]
  1470. elseif opType == 2 then
  1471. self:setLastData()
  1472. self.ui.Items.Layout_Operation_BuChu:setVisible(not bVisible)
  1473. self.ui.Items.Layout_Operation_TiShi:setVisible(not bVisible) -- 轮到自己回合,提示按钮隐藏
  1474. self.ui.Items.Layout_Operation_ChuPai:setVisible(bVisible)
  1475. self.ui.Items.Layout_Operation_YaoBuQi:setVisible(not bVisible)
  1476. --[[
  1477. self.ui.Items.Button_Operation_BuChu:setEnabled(not bVisible)
  1478. self.ui.Items.Button_Operation_TiShi:setEnabled(bVisible)
  1479. self.ui.Items.Button_Operation_ChuPai:setEnabled(bVisible)
  1480. self.ui.Items.Layout_Operation_YaoBuQi:setVisible(false)
  1481. ]]
  1482. else
  1483. self.ui.Items.Layout_Operation_BuChu:setVisible(not bVisible)
  1484. self.ui.Items.Layout_Operation_TiShi:setVisible(not bVisible)
  1485. self.ui.Items.Layout_Operation_ChuPai:setVisible(not bVisible)
  1486. self.ui.Items.Layout_Operation_YaoBuQi:setVisible(bVisible)
  1487. --[[
  1488. self.ui.Items.Button_Operation_BuChu:setEnabled(bVisible)
  1489. self.ui.Items.Button_Operation_TiShi:setEnabled(not bVisible)
  1490. self.ui.Items.Button_Operation_ChuPai:setEnabled(not bVisible)
  1491. self.ui.Items.Layout_Operation_YaoBuQi:setVisible(false)
  1492. ]]
  1493. end
  1494. self.ui.Items.Layout_Operation_Buttons:requestDoLayout()
  1495. self.ui.Items.Layout_Operation_Buttons:doLayout()
  1496. --检测提示
  1497. self.tiShiCount = 1
  1498. local handCards = self.handCards["" .. self:getMeViewId()]
  1499. local handCardsValueTable = {} -- 玩家手牌值表
  1500. local lastDataValueTable = {} -- 上个牌数据值表
  1501. for i, v in pairs(handCards) do
  1502. table.insert(handCardsValueTable, v.cardNum)
  1503. end
  1504. for i, v in pairs(self.lastData.cards) do
  1505. table.insert(lastDataValueTable, v.cardNum)
  1506. end
  1507. -- 判断是否可以一手出完牌
  1508. -- if self._pokerUtil:checkIsCanOneOutCard(handCardsValueTable, lastDataValueTable) then
  1509. -- --self:setOperationVisible(false)
  1510. -- self:runAction(
  1511. -- cc.Sequence:create(
  1512. -- cc.DelayTime:create(0.5),
  1513. -- cc.CallFunc:create(function ()
  1514. -- self:setHandCardsUp(self:getMeViewId(), handCardsValueTable)
  1515. -- self:chuPai()
  1516. -- end)
  1517. -- )
  1518. -- )
  1519. -- end
  1520. -- 牌型提示
  1521. if self.ui.Items.Layout_Operation_TiShi:isVisible() then
  1522. self.weaveCardList = self:getTip(handCardsValueTable, lastDataValueTable)
  1523. end
  1524. end
  1525. end
  1526. function RoomView_53:setHandCardsUp(viewId, cards)
  1527. --下降所有牌
  1528. self:setAllHandCardDown(self:getMeViewId())
  1529. --上升指定牌
  1530. if self.handCards and cards then
  1531. local handCards = self.handCards["" .. viewId]
  1532. if handCards then
  1533. for k,v in ipairs(cards) do
  1534. for _,v2 in ipairs(handCards) do
  1535. if v == v2.cardNum then
  1536. self:setCardUp(v2)
  1537. end
  1538. end
  1539. end
  1540. end
  1541. end
  1542. end
  1543. function RoomView_53:setAllHandCardDown(viewId)
  1544. if self.handCards then
  1545. local handCards = self.handCards["" .. viewId]
  1546. if handCards then
  1547. for _,v in ipairs(handCards) do
  1548. self:setCardDown(v)
  1549. end
  1550. end
  1551. end
  1552. end
  1553. function RoomView_53:initGameButtons()
  1554. --桌面
  1555. self.ui.Items.ImageView_bg:registerClick(function()
  1556. --测试
  1557. --self:chuPai()
  1558. --self:tiShi()
  1559. --self:fapaiAni()
  1560. if not self._isCanClickBg then
  1561. return
  1562. end
  1563. --下降所有牌
  1564. self:setAllHandCardDown(self:getMeViewId())
  1565. end)
  1566. -- 漂分
  1567. self.ui.Items.Layout_Piao:setVisible(false)
  1568. for i = 0, 1 do
  1569. local button = self.ui.Items["Button_Piao_" .. i]
  1570. if button then
  1571. button:registerClick(function()
  1572. playBtnEffect()
  1573. app.room:sendPiao(i)
  1574. end)
  1575. end
  1576. end
  1577. -- 闷抓
  1578. self.ui.Items.Layout_MenZhua:setVisible(false)
  1579. for i = 0, 2, 2 do
  1580. local button = self.ui.Items["Button_MenZhua_" .. i]
  1581. if button then
  1582. button:registerClick(function()
  1583. playBtnEffect()
  1584. app.room:sendMenZhuaOrMenDao(i)
  1585. self:setMenZhuaVisible(false)
  1586. -- self.PlayerView:setClockVisibel(false, self.curViewId)
  1587. end)
  1588. end
  1589. end
  1590. -- 闷倒
  1591. self.ui.Items.Layout_MenDao:setVisible(false)
  1592. for i = 3, 5, 2 do
  1593. local button = self.ui.Items["Button_MenDao_" .. i]
  1594. if button then
  1595. button:registerClick(function()
  1596. playBtnEffect()
  1597. app.room:sendMenZhuaOrMenDao(i)
  1598. self:setMenDaoVisible(false)
  1599. -- self.PlayerView:setClockVisibel(false, self.curViewId)
  1600. end)
  1601. end
  1602. end
  1603. -- 闷拉
  1604. self.ui.Items.Layout_MenLa:setVisible(false)
  1605. for i = 0, 2, 2 do
  1606. local button = self.ui.Items["Button_MenLa_" .. i]
  1607. if button then
  1608. button:registerClick(function()
  1609. playBtnEffect()
  1610. app.room:sendMenLa(i)
  1611. self:setMenLaVisible(false)
  1612. -- self.PlayerView:setClockVisibel(false, self.curViewId)
  1613. end)
  1614. end
  1615. end
  1616. --叫分(抓)
  1617. self.ui.Items.Layout_Ask_Loard:setVisible(false)
  1618. for i = 0, 1 do
  1619. local button = self.ui.Items["Button_Ask_Loard_F_" .. i]
  1620. if button then
  1621. button:registerClick(function()
  1622. playBtnEffect()
  1623. app.room:sendAskLoard(i)
  1624. end)
  1625. end
  1626. end
  1627. --加倍(倒)
  1628. self.ui.Items.Layout_Ask_Bei:setVisible(false)
  1629. for i = 0, 2, 2 do
  1630. local button = self.ui.Items["Button_Ask_Bei_" .. i]
  1631. if button then
  1632. button:registerClick(function()
  1633. playBtnEffect()
  1634. app.room:sendAskBeiOrLa(i)
  1635. end)
  1636. end
  1637. end
  1638. -- 拉
  1639. self.ui.Items.Layout_La:setVisible(false)
  1640. for i = 3, 5, 2 do
  1641. local button = self.ui.Items["Button_La_" .. i]
  1642. if button then
  1643. button:registerClick(function()
  1644. playBtnEffect()
  1645. app.room:sendAskBeiOrLa(i)
  1646. end)
  1647. end
  1648. end
  1649. --要不起,不出,提示,出牌
  1650. self.ui.Items.Layout_Operation:setVisible(false)
  1651. self.ui.Items.Button_Operation_YaoBuQi:registerClick(function()
  1652. playBtnEffect()
  1653. app.room:sendOperation({opType = 0, cards = {}, lzCards = {}})
  1654. end)
  1655. self.ui.Items.Button_Operation_BuChu:registerClick(function()
  1656. playBtnEffect()
  1657. app.room:sendOperation({opType = 0, cards = {}, lzCards = {}})
  1658. end)
  1659. self.ui.Items.Button_Operation_TiShi:registerClick(handler(self, self.tiShi))
  1660. self.ui.Items.Button_Operation_ChuPai:registerClick(handler(self, self.chuPai))
  1661. end
  1662. function RoomView_53:getCardsType(cards)
  1663. return self._pokerUtil:getCardsType(cards)
  1664. end
  1665. function RoomView_53:getTip(cards, lastData)
  1666. if cards and cards[1] and type(cards[1]) == 'userdata' then
  1667. logD('亲!现在调用getTip,cards数据是要传牌值,不是card节点啦!!!')
  1668. return
  1669. end
  1670. return self._pokerUtil:getTip(cards, lastData)
  1671. end
  1672. function RoomView_53:tiShi()
  1673. playBtnEffect()
  1674. if self.weaveCardList and table.nums(self.weaveCardList) > 0 then
  1675. function tiShiEx()
  1676. local weaveList = self.weaveCardList[self.tiShiCount]
  1677. if weaveList then
  1678. self:setHandCardsUp(self:getMeViewId(), weaveList)
  1679. self.tiShiCount = self.tiShiCount + 1
  1680. else
  1681. self.tiShiCount = 1
  1682. tiShiEx()
  1683. end
  1684. end
  1685. tiShiEx()
  1686. else
  1687. app.room:sendOperation({opType = 0, cards = {}, lzCards = {}})
  1688. end
  1689. end
  1690. function RoomView_53:chuPai()
  1691. playBtnEffect()
  1692. local handCards = self.handCards["" .. self:getMeViewId()]
  1693. if not handCards then
  1694. logE("RoomView_53 chuPai error handCards is null")
  1695. end
  1696. --获取点中的牌
  1697. local cards = {}
  1698. local cardsEx = {}
  1699. for k,v in ipairs(handCards) do
  1700. if v:isVisible() and v.isUp then
  1701. table.insert(cards, v.cardNum)
  1702. table.insert(cardsEx, v)
  1703. end
  1704. end
  1705. local lzCards = {}
  1706. if not Functions.getRuleIncludeLzWanFa() then
  1707. lzCards = clone(cards)
  1708. else
  1709. local leftLzCards = self._pokerUtil:removeGodCards(clone(cards))
  1710. local lzReplaceCards = self._pokerUtil:getGodCardReplaceCard(cards)
  1711. lzCards = self._pokerUtil:addTableData(leftLzCards, lzReplaceCards or {})
  1712. end
  1713. --local typeEx = self:getCardsType(cardsEx)
  1714. --logE("RoomView_53 chuPai type : " .. table.tostring(cardsEx))
  1715. logE("RoomView_53 chuPai type : " .. table.tostring(cards))
  1716. dump(cards, '出的牌')
  1717. dump(lzCards, '癞子替代牌')
  1718. app.room:sendOperation({opType = 1, cards = cards, lzCards = lzCards})
  1719. end
  1720. function RoomView_53:cmd_0x8108_Resp(data)
  1721. function cmd_0x8108_RespEx(onEnd)
  1722. --当前操作玩家
  1723. self.curViewId = app.room:getViewIdByUserId(data.response.nUserId)
  1724. --显示闹钟
  1725. self.PlayerView:setClockVisibel(true, self.curViewId, data.response.leftTime)
  1726. --显示叫分
  1727. if self.curViewId == self:getMeViewId() then
  1728. self:setAskLoardVisible(true, data.response.mustBanker == 1)
  1729. end
  1730. if onEnd then
  1731. onEnd()
  1732. end
  1733. end
  1734. self:addCallBack(cmd_0x8108_RespEx)
  1735. end
  1736. function RoomView_53:cmd_0x8109_Resp(data)
  1737. function cmd_0x8109_RespEx(onEnd)
  1738. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  1739. --隐藏叫分界面
  1740. self:setAskLoardVisible(false)
  1741. --隐藏闹钟
  1742. self.PlayerView:setClockVisibel(false, viewId)
  1743. -- 闷抓之后不显示抓了
  1744. if app.room.roomInfo.menZhuaUserId ~= data.response.nUserId then
  1745. --显示叫分
  1746. self.PlayerView:setTipsVisible("tips_jiaofen", true, viewId, {askLoard = data.response.askLoard})
  1747. --播放音效
  1748. Functions.playVoice("jiaofen", data.response.askLoard, self.PlayerView:getPlayerData("sex", viewId))
  1749. end
  1750. if onEnd then
  1751. onEnd()
  1752. end
  1753. end
  1754. self:addCallBack(cmd_0x8109_RespEx)
  1755. end
  1756. function RoomView_53:setBankerAskLoard()
  1757. self.ui.Items.Text_AskLoard:setText(app.room.roomInfo.curAskLoard or 0)
  1758. end
  1759. function RoomView_53:setCurZhaDanNum()
  1760. self.ui.Items.Text_ZhaDan:setText(app.room.roomInfo.nBombs or 0)
  1761. end
  1762. function RoomView_53:setBanderCardsVisible(bVisible, bankerCards)
  1763. self.ui.Items.Layout_BankerInfo:setVisible(bVisible)
  1764. if bVisible then
  1765. for k,v in ipairs(bankerCards) do
  1766. local card = self.ui.Items["Image_BankerCard_" .. k]
  1767. if card then
  1768. -- card:loadTexture(string.format("pk/res/ui/zy_fangjian/pk_cards/pk_cards_%d_%d.png", self:getCardType(v.card), self:getCardValue(v.card))) -- 旧资源
  1769. card:loadTexture(string.format("ddz_cards_%d_%d.png", self:getCardType(v.card), self:getCardValue(v.card)), 1) -- 新资源
  1770. end
  1771. end
  1772. self:setCurZhaDanNum()
  1773. self:setBankerAskLoard()
  1774. end
  1775. end
  1776. function RoomView_53:cmd_0x810a_Resp(data)
  1777. function cmd_0x810a_RespEx(onEnd)
  1778. self:runAction(
  1779. cc.Sequence:create(
  1780. cc.DelayTime:create(0.5),
  1781. cc.CallFunc:create(function()
  1782. local viewId = app.room:getViewIdByUserId(data.response.nBankerId)
  1783. --显示剩余手牌
  1784. self.PlayerView:setLeftNumVisible(true, viewId, 17 + table.nums(data.response.bankerCards))
  1785. --显示庄家
  1786. self.PlayerView:setBankerVisible(true, viewId)
  1787. --显示底牌和底分炸弹情况
  1788. self:setBanderCardsVisible(true, data.response.bankerCards)
  1789. -- 底牌显示的时候,即叫分结束,此时把叫分分数隐藏
  1790. self:setAllTipsVisible()
  1791. if onEnd then
  1792. onEnd()
  1793. end
  1794. end)
  1795. )
  1796. )
  1797. end
  1798. self:addCallBack(cmd_0x810a_RespEx)
  1799. end
  1800. function RoomView_53:setAllTipsVisible(bVisible)
  1801. for k,v in pairs(app.room.roomInfo.memberList) do
  1802. self.PlayerView:setTipsVisible("tips_jiaofen", false, app.room:getViewIdByUserId(v.nUserId))
  1803. end
  1804. end
  1805. function RoomView_53:cmd_0x810c_Resp(data)
  1806. function cmd_0x810c_RespEx(onEnd)
  1807. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  1808. --显示加倍(倒or拉)
  1809. if viewId == self:getMeViewId() then
  1810. if data.response.nDaoState == defs.DAO_STATE.DAO_STATE_WAIT then
  1811. self:setAskBeiVisible(true)
  1812. elseif data.response.nLaState == defs.DAO_STATE.LA_STATE_WAIT then
  1813. self:setLaVisible(true)
  1814. end
  1815. end
  1816. self.PlayerView:setClockVisibel(true, viewId, data.response.leftTime)
  1817. if onEnd then
  1818. onEnd()
  1819. end
  1820. end
  1821. self:addCallBack(cmd_0x810c_RespEx)
  1822. end
  1823. -- 加倍(倒or拉)
  1824. function RoomView_53:cmd_0x810d_Resp(data)
  1825. function cmd_0x810d_RespEx(onEnd)
  1826. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  1827. --隐藏加倍操作界面
  1828. if viewId == self:getMeViewId() then
  1829. self:setAskBeiVisible(false)
  1830. self:setLaVisible(false)
  1831. end
  1832. --隐藏闹钟
  1833. self.PlayerView:setClockVisibel(false, viewId)
  1834. --显示加倍状态
  1835. if data.response.askBei <= defs.DAO_STATE.DAO_STATE_YES then
  1836. self.PlayerView:setTipsVisible("tips_jiabei", true, viewId, { askBei = data.response.askBei })
  1837. if data.response.askBei == defs.DAO_STATE.DAO_STATE_YES then
  1838. Functions.playVoice('dao', data.response.askBei, self.PlayerView:getPlayerData("sex", viewId))
  1839. end
  1840. elseif data.response.askBei <= defs.DAO_STATE.LA_STATE_YES then
  1841. self.PlayerView:setTipsVisible("tips_jiabei_la", true, viewId, { askBei = data.response.askBei })
  1842. if data.response.askBei == defs.DAO_STATE.LA_STATE_YES then
  1843. Functions.playVoice('la', data.response.askBei, self.PlayerView:getPlayerData("sex", viewId))
  1844. end
  1845. end
  1846. self:runAction(
  1847. cc.Sequence:create(
  1848. cc.DelayTime:create(0.5),
  1849. cc.CallFunc:create(function()
  1850. if onEnd then
  1851. onEnd()
  1852. end
  1853. end)
  1854. )
  1855. )
  1856. end
  1857. self:addCallBack(cmd_0x810d_RespEx)
  1858. end
  1859. function RoomView_53:hideAllOutCardOperation()
  1860. --隐藏玩家出牌操作信息
  1861. for _,v in pairs(app.room.roomInfo.memberList) do
  1862. local viewId = app.room:getViewIdByUserId(v.nUserId)
  1863. --隐藏玩家的出牌
  1864. self:setOutCardsVisible(false, viewId)
  1865. --隐藏玩家的操作
  1866. self.PlayerView:setTipsVisible("tips_yaobuqi", false, viewId)
  1867. end
  1868. end
  1869. function RoomView_53:cmd_0x810e_Resp(data)
  1870. function cmd_0x810e_RespEx(onEnd)
  1871. --当前操作玩家
  1872. self.curViewId = app.room:getViewIdByUserId(data.response.nUserId)
  1873. local delayTime = 0
  1874. if data.response.opType == 2 then -- 如果是所有玩家都操作不要,即本家必须出牌
  1875. delayTime = 0.4
  1876. end
  1877. self:runAction(cc.Sequence:create(
  1878. cc.DelayTime:create(delayTime),
  1879. cc.CallFunc:create(function()
  1880. --隐藏玩家出牌操作信息
  1881. if data.response.opType == 2 then
  1882. self:hideAllOutCardOperation()
  1883. else
  1884. --隐藏玩家的出牌
  1885. self:setOutCardsVisible(false, self.curViewId)
  1886. --隐藏玩家的操作
  1887. self.PlayerView:setTipsVisible("tips_yaobuqi", false, self.curViewId)
  1888. end
  1889. --显示闹钟
  1890. self.PlayerView:setClockVisibel(true, self.curViewId, self.clockTime)
  1891. --显示操作
  1892. if self.curViewId == self:getMeViewId() then
  1893. self:setOperationVisible(true, data.response.opType)
  1894. end
  1895. if onEnd then
  1896. onEnd()
  1897. end
  1898. end)
  1899. ))
  1900. end
  1901. self:addCallBack(cmd_0x810e_RespEx)
  1902. end
  1903. function RoomView_53:cmd_0x810f_Resp(data)
  1904. function cmd_0x810f_RespEx(onEnd)
  1905. local errorMessage = {
  1906. [1] = "轮次错误",
  1907. [2] = "牌型错误",
  1908. [3] = "出牌错误",
  1909. }
  1910. --下降所有手牌
  1911. self:setAllHandCardDown(self.getMeViewId())
  1912. --显示错误信息
  1913. showTooltip(errorMessage[data.response.errorType] or "出牌错误")
  1914. if onEnd then
  1915. onEnd()
  1916. end
  1917. end
  1918. self:addCallBack(cmd_0x810f_RespEx)
  1919. end
  1920. function RoomView_53:setLastData(viewId, data)
  1921. if viewId and data then
  1922. local cardsEx = {}
  1923. local cardsValueTable = {}
  1924. for k,v in ipairs(data.cards) do
  1925. table.insert(cardsEx, { cardNum = v.card, cardValue = self:getCardValue(v.card), cardType = self:getCardType(v.card) })
  1926. table.insert(cardsValueTable, v.card)
  1927. end
  1928. local lastDataEx = self:getCardsType(cardsValueTable)
  1929. if lastDataEx then
  1930. for k,v in pairs(lastDataEx) do
  1931. self.lastData[k] = v
  1932. end
  1933. end
  1934. self.lastData.cards = cardsEx
  1935. self.lastData.viewId = viewId
  1936. --播放音效
  1937. Functions.playVoice("chupai", self.lastData, self.PlayerView:getPlayerData("sex", viewId))
  1938. else
  1939. self.lastData = {
  1940. min = 0,
  1941. cards = {},
  1942. viewId = 0,
  1943. cardType = 0,
  1944. }
  1945. end
  1946. end
  1947. function RoomView_53:setOutCardsVisible(bVisible, viewId, data)
  1948. logE("RoomView_53 setOutCardsVisible data : ".. table.toString(data))
  1949. local outCardsLayout = self.ui.Items["Layout_Out_" .. viewId]
  1950. if outCardsLayout then
  1951. outCardsLayout:setVisible(bVisible)
  1952. if bVisible then
  1953. outCardsLayout:removeAllChildren()
  1954. if data.opType == 0 then
  1955. self.PlayerView:setTipsVisible("tips_yaobuqi", true, viewId)
  1956. --播放音效
  1957. Functions.playVoice("buyao", 0, self.PlayerView:getPlayerData("sex", viewId))
  1958. else
  1959. if not data.maxLen then
  1960. self:setLastData(viewId, data)
  1961. end
  1962. -- 改变扑克值,将0x5x打头的赖子值,更改为普通的0x0x标准值(注意王牌不是0x0x打头)
  1963. local godCardFlag = {}
  1964. if data and data.cards then
  1965. for i, v in ipairs(data.cards) do
  1966. if self._pokerUtil:isGodCardReplaceCard(v.card) then
  1967. local val = self._pokerUtil:getCardValue(v.card)
  1968. if val ~= 0x0e and val ~= 0x0f then
  1969. v.card = val
  1970. else
  1971. -- 如果是小王,大王,则要改为0x4e和0x4f
  1972. v.card = val + 4 * 16
  1973. end
  1974. godCardFlag[i] = true
  1975. end
  1976. end
  1977. end
  1978. dump(data, 'RoomView_53:setOutCardsVisible 转换后的数据为')
  1979. self:initOutCardItem(outCardsLayout, viewId, data, godCardFlag)
  1980. end
  1981. end
  1982. end
  1983. end
  1984. function RoomView_53:initOutCardItem(outCardsLayout, viewId, data, godCardFlag)
  1985. local cardScale = 0.5
  1986. local cardsLen = table.nums(data.cards)
  1987. local isBanker = app.room.roomInfo.nBankerId > 0 and app.room:getViewIdByUserId(app.room.roomInfo.nBankerId) == viewId
  1988. -- (右家(viewid = 1)是从右到左排序,即从小到大,如果感觉现有不太好,直接逆序即可)
  1989. for k,v in ipairs(data.cards) do
  1990. -- local card = cc.Sprite:create(string.format("pk/res/ui/zy_fangjian/pk_cards/pk_cards_%d_%d.png", self:getCardType(v.card), self:getCardValue(v.card))) -- 旧资源
  1991. local card = cc.Sprite:createWithSpriteFrameName(string.format("ddz_cards_%d_%d.png", self:getCardType(v.card), self:getCardValue(v.card))) -- 新资源
  1992. if card then
  1993. -- 设置为庄家牌
  1994. if self:checkIsBankCard(v.card, viewId) then
  1995. card.isBankCard = true
  1996. end
  1997. local kEx = tonumber(k)
  1998. card:setScale(cardScale)
  1999. outCardsLayout:addChild(card)
  2000. local cardSize = card:getContentSize()
  2001. if viewId == 1 then
  2002. --左对齐
  2003. if data.maxLen then
  2004. local floor = math.floor(kEx / data.maxLen)
  2005. local mod = kEx % data.maxLen + (kEx >= data.maxLen and 1 or 0)
  2006. --设置zOder
  2007. card:setLocalZOrder(data.maxLen * floor - kEx)
  2008. card:setPosition(cc.p((-1) * mod * (cardSize.width - self.handCardDif) * cardScale, (-1) * cardSize.height * cardScale * 0.5 * floor))
  2009. else
  2010. --设置zOder
  2011. card:setLocalZOrder(cardsLen - kEx)
  2012. card:setPosition(cc.p((-1) * kEx * (cardSize.width - self.handCardDif) * cardScale, 0))
  2013. end
  2014. elseif viewId == 3 then
  2015. --右对齐
  2016. if data.maxLen then
  2017. local floor = math.floor(kEx / data.maxLen)
  2018. local mod = kEx % data.maxLen + (kEx >= data.maxLen and 1 or 0)
  2019. card:setPosition(cc.p(mod * (cardSize.width - self.handCardDif) * cardScale, (-1) * cardSize.height * cardScale * 0.5 * floor))
  2020. else
  2021. card:setPosition(cc.p(kEx * (cardSize.width - self.handCardDif) * cardScale, 0))
  2022. end
  2023. else
  2024. --居中
  2025. card:setPosition(cc.p((kEx - cardsLen / 2) * (cardSize.width - self.handCardDif) * cardScale, 0))
  2026. end
  2027. -- 癞子标识
  2028. if godCardFlag[k] then
  2029. local imgPath = 'pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_lzMark.png'
  2030. local imgNode = cc.ImageView:create(imgPath)
  2031. imgNode:setAnchorPoint(cc.p(0, 0))
  2032. local offsetX, offsetY = self:getLzTagOffset()
  2033. imgNode:setPosition(cc.p(5 + offsetX, 5 + offsetY))
  2034. card:addChild(imgNode)
  2035. card.lzMark = imgNode
  2036. end
  2037. --庄家标识
  2038. if isBanker then
  2039. if card.isBankCard then
  2040. if card.bankerMark then
  2041. card.bankerMark:setVisible(true)
  2042. else
  2043. card.bankerMark = cc.Sprite:create(string.format("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_bankerCardMark.png"))
  2044. local offsetX, offsetY = self:getBankTagOffset()
  2045. card.bankerMark:setPosition(cc.p(cardSize.width * 0.72 + offsetX, cardSize.height * 0.785 + offsetY))
  2046. card:addChild(card.bankerMark)
  2047. end
  2048. end
  2049. end
  2050. card:stopAllActions()
  2051. local moveTo = cc.MoveBy:create(Card_Out_Down_Time, cc.p(0, Card_Out_Down_Offset_Y))
  2052. card:runAction(moveTo)
  2053. -- 添加刷新牌的方法
  2054. card.refreshCard = function() -- 刷新卡牌
  2055. if v.card > 0 then
  2056. local cardPng = string.format("ddz_cards_%d_%d.png", self:getCardType(v.card), self:getCardValue(v.card))
  2057. card:setSpriteFrame(cardPng)
  2058. if card.bankerMark then
  2059. local size = card:getContentSize()
  2060. local offsetX, offsetY = self:getBankTagOffset()
  2061. card.bankerMark:setPosition(cc.p(size.width * 0.72 + offsetX, size.height * 0.785 + offsetY))
  2062. end
  2063. if card.lzMark then
  2064. local offsetX, offsetY = self:getLzTagOffset()
  2065. card.lzMark:setPosition(cc.p(5 + offsetX, 5 + offsetY))
  2066. end
  2067. end
  2068. end
  2069. else
  2070. logE("RoomView_53 initOutCardItem error".. table.toString(v))
  2071. end
  2072. end
  2073. --播放动画
  2074. if #self.lastData.cards > 0 then
  2075. local cardsEx = outCardsLayout:getChildren()
  2076. if #cardsEx > 0 then
  2077. local effect = nil
  2078. if self.lastData.cardType == defs.CARD_TYPE.SHUNZI then --顺子
  2079. -- effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_shunzi.plist", "shunzi%d.png", 1, 17, -1)
  2080. effect = DDZ_New_Effect_Helper:getShunziNew()
  2081. elseif self.lastData.cardType == defs.CARD_TYPE.SHUANGSHUN then --连对
  2082. -- effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_liandui.plist", "liandui%d.png", 1, 8, -1)
  2083. effect = DDZ_New_Effect_Helper:getLianduiNew()
  2084. elseif self.lastData.cardType == defs.CARD_TYPE.SANSHUN then --飞机
  2085. -- effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_feiji.plist", "feiji%d.png", 1, 16, -1)
  2086. effect = DDZ_New_Effect_Helper:getPlanNew()
  2087. elseif self.lastData.cardType == defs.CARD_TYPE.AIRPLANE_SINGLE then --飞机
  2088. -- effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_feiji.plist", "feiji%d.png", 1, 16, -1)
  2089. effect = DDZ_New_Effect_Helper:getPlanNew()
  2090. elseif self.lastData.cardType == defs.CARD_TYPE.AIRPLANE_DUAD then --飞机
  2091. -- effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_feiji.plist", "feiji%d.png", 1, 16, -1)
  2092. effect = DDZ_New_Effect_Helper:getPlanNew()
  2093. elseif self.lastData.cardType == defs.CARD_TYPE.BOMB or (self.lastData.cardType == defs.CARD_TYPE.BOMB_LAIZI and cardsLen == 4) then --炸弹
  2094. -- effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_zhadan.plist", "zhadan%d.png", 1, 17, -1)
  2095. effect = DDZ_New_Effect_Helper:getBombNew()
  2096. elseif self.lastData.cardType == defs.CARD_TYPE.BOMB_KING or (self.lastData.cardType == defs.CARD_TYPE.BOMB_LAIZI and cardsLen == 2) then --王炸
  2097. -- effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_zhadan.plist", "zhadan%d.png", 1, 17, -1)
  2098. effect = DDZ_New_Effect_Helper:getKingBombNew()
  2099. end
  2100. if effect then
  2101. effect:setScale(0.7)
  2102. effect:setPosition(cardsEx[toint(#cardsEx / 2)]:getPosition())
  2103. outCardsLayout:addChild(effect, 100)
  2104. if effect.onEnter and type(effect.onEnter)=='function' then
  2105. effect:onEnter()
  2106. end
  2107. end
  2108. end
  2109. end
  2110. end
  2111. function RoomView_53:deleteHandCards(viewId, cards, doAni)
  2112. local handCards = self.handCards["" .. viewId]
  2113. if handCards then
  2114. for k,v in ipairs(cards) do
  2115. logE("handCards v.card " .. v.card)
  2116. for k2,v2 in ipairs(handCards) do
  2117. logE("handCards v2.cardNum " .. v2.cardNum)
  2118. if v2.cardNum == v.card then
  2119. v2:removeFromParent()
  2120. table.remove(handCards, k2)
  2121. break
  2122. end
  2123. -- 癞子牌(手牌中是以癞子牌值保留,只有出的牌才会幻化,所以判断赖子值即可)
  2124. if Functions.getRuleIncludeLzWanFa() then
  2125. if self._pokerUtil:isGodCardReplaceCard(v.card) and self._pokerUtil:isGodCard(v2.cardNum) then
  2126. v2:removeFromParent()
  2127. table.remove(handCards, k2)
  2128. break
  2129. end
  2130. end
  2131. end
  2132. end
  2133. self:rankHandCards(viewId, doAni)
  2134. end
  2135. end
  2136. -- 根据牌的标准值获取手牌节点
  2137. function RoomView_53:getCardNodeByCardValue(cardValue)
  2138. if self.handCards and cardValue then
  2139. local handCards = self.handCards["" .. self:getMeViewId()]
  2140. if handCards then
  2141. for _,cardNode in ipairs(handCards) do
  2142. if cardValue == cardNode.cardNum then
  2143. return cardNode
  2144. end
  2145. end
  2146. end
  2147. end
  2148. end
  2149. -- 判断是否是庄家牌
  2150. function RoomView_53:checkIsBankCard(card, viewId)
  2151. if not app.room.roomInfo.bankerCards then
  2152. return false
  2153. end
  2154. -- 只要是庄家,庄家的牌都显示为地主
  2155. local isBanker = app.room.roomInfo.nBankerId and app.room.roomInfo.nBankerId > 0 and app.room:getViewIdByUserId(app.room.roomInfo.nBankerId) == viewId
  2156. return isBanker
  2157. -- 只有3张底牌显示
  2158. -- local temp = {}
  2159. -- for _,v in ipairs(app.room.roomInfo.bankerCards) do
  2160. -- table.insert(temp, v.card)
  2161. -- end
  2162. -- for i, v in ipairs(temp) do
  2163. -- if card == v then
  2164. -- return true
  2165. -- end
  2166. -- end
  2167. -- return false
  2168. end
  2169. -- 获得庄家标记偏移值
  2170. function RoomView_53:getBankTagOffset()
  2171. local getPokerChoose = tonumber(loadUserInfo("ddz_setting_poker")) or defs.Default_Poker_Choose
  2172. local offsetX = (getPokerChoose == 1) and 0 or 3
  2173. local offsetY = (getPokerChoose == 1) and 0 or -3
  2174. return offsetX, offsetY
  2175. end
  2176. -- 获得癞子标记偏移值
  2177. function RoomView_53:getLzTagOffset()
  2178. local getPokerChoose = tonumber(loadUserInfo("ddz_setting_poker")) or defs.Default_Poker_Choose
  2179. local offsetX = (getPokerChoose == 1) and 0 or 3
  2180. local offsetY = (getPokerChoose == 1) and 1 or -1
  2181. return offsetX, offsetY
  2182. end
  2183. -- 显示头像标记 如果有传showType,则只显示该相关的字段
  2184. function RoomView_53:showHeadTip(showType)
  2185. local temp = {
  2186. piao = false,
  2187. daoOrLa = false,
  2188. }
  2189. if not showType then
  2190. for i, v in pairs(temp) do
  2191. temp[i] = true
  2192. end
  2193. else
  2194. temp[showType] = true
  2195. end
  2196. -- 玩家选择漂或者倒拉
  2197. for k,v in pairs(app.room.roomInfo.memberList) do
  2198. if Functions.getRuleIncludeDingPiaoWanFa() then
  2199. self.PlayerView:setPiaoVisible(app.room:getViewIdByUserId(v.nUserId), true)
  2200. else
  2201. if temp.piao then
  2202. if v.nPiaoState == defs.PIAO_STATE.PIAO_STATE_YES then
  2203. self.PlayerView:setPiaoVisible(app.room:getViewIdByUserId(v.nUserId), true)
  2204. end
  2205. end
  2206. end
  2207. if temp.daoOrLa then
  2208. if v.nDaoState == defs.DAO_STATE.DAO_STATE_YES or v.nMenZhuaState == defs.MEN_STATE.MEN_STATE_DAO then
  2209. self.PlayerView:setDaoOrLaVisible(app.room:getViewIdByUserId(v.nUserId), true, 'dao')
  2210. elseif v.nLaState == defs.DAO_STATE.LA_STATE_YES or v.nMenLaState == defs.MEN_LA_STATE.MEN_STATE_LA_ZHUAI then
  2211. self.PlayerView:setDaoOrLaVisible(app.room:getViewIdByUserId(v.nUserId), true, 'la')
  2212. end
  2213. end
  2214. end
  2215. end
  2216. function RoomView_53:cmd_0x8110_Resp(data)
  2217. function cmd_0x8110_RespEx(onEnd)
  2218. --隐藏玩家信息
  2219. if data.response.opType == 1 then
  2220. self:hideAllOutCardOperation()
  2221. end
  2222. --操作位置
  2223. local opViewId = app.room:getViewIdByUserId(data.response.nUserId)
  2224. --显示剩余手牌
  2225. self.PlayerView:setLeftNumVisible(true, opViewId, data.response.leftNum)
  2226. --隐藏操作
  2227. self:setOperationVisible(false)
  2228. --隐藏闹钟
  2229. self.PlayerView:setClockVisibel(false, opViewId)
  2230. -- 分析牌数据,让牌分解
  2231. local cards = {}
  2232. for i, v in ipairs(data.response.cards) do
  2233. table.insert(cards, {card = v.card})
  2234. end
  2235. --显示出牌
  2236. self:setOutCardsVisible(true, opViewId, {cards = clone(cards), opType = data.response.opType})
  2237. --删除手牌
  2238. if opViewId == self:getMeViewId() then
  2239. self:deleteHandCards(opViewId, clone(cards), true)
  2240. end
  2241. if onEnd then
  2242. onEnd()
  2243. end
  2244. end
  2245. self:addCallBack(cmd_0x8110_RespEx)
  2246. end
  2247. function RoomView_53:cmd_0x8111_Resp(data)
  2248. function cmd_0x8111_RespEx(onEnd)
  2249. --设置底分
  2250. self:setBankerAskLoard()
  2251. --设置炸弹数
  2252. self:setCurZhaDanNum()
  2253. if onEnd then
  2254. onEnd()
  2255. end
  2256. end
  2257. self:addCallBack(cmd_0x8111_RespEx)
  2258. end
  2259. function RoomView_53:cmd_0x8112_Resp(data)
  2260. function cmd_0x8112_RespEx(onEnd)
  2261. --显示春天动画
  2262. -- 去除春天动画
  2263. -- if data.response.nSpring == 1 then
  2264. -- local effect = createAnimationByPlist("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_cardsAni/doudizhu_spring.plist", "spring%d.png", 1, 22, -1)
  2265. -- if effect then
  2266. -- playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_spring.ogg")
  2267. -- effect:setPosition(cc.p(640, 360))
  2268. -- self:addChild(effect)
  2269. -- end
  2270. -- end
  2271. self:runAction(
  2272. cc.Sequence:create(
  2273. -- cc.DelayTime:create(1.0),
  2274. cc.DelayTime:create(1.3),
  2275. cc.CallFunc:create(function()
  2276. --隐藏界面
  2277. local winViewId = app.room:getViewIdByUserId(data.response.nWinId)
  2278. for _,v in pairs(app.room.roomInfo.memberList) do
  2279. local viewId = app.room:getViewIdByUserId(v.nUserId)
  2280. if viewId ~= winViewId then
  2281. --出牌界面
  2282. self:setOutCardsVisible(false, viewId)
  2283. end
  2284. --闹钟界面
  2285. self.PlayerView:setClockVisibel(false, viewId)
  2286. end
  2287. --显示小局结算
  2288. self:setXiaoJuVisible(true, data.response)
  2289. if onEnd then
  2290. onEnd()
  2291. end
  2292. end)
  2293. )
  2294. )
  2295. end
  2296. self:addCallBack(cmd_0x8112_RespEx)
  2297. end
  2298. function RoomView_53:showDaJu(data)
  2299. if not self.daJuView then
  2300. self.daJuView = import("pk_nanchongdoudizhu.luaScript.Views.Room.RoomDaJuView_53"):new(data.memberList)
  2301. -- self.ui.Items.Layout_DaJu:addChild(self.daJuView)
  2302. self.daJuView:setAnchorPoint(cc.p(0.5, 0.5))
  2303. app:showWaitDialog(self.daJuView);
  2304. end
  2305. --更新界面
  2306. self.daJuView:updateView(data)
  2307. end
  2308. function RoomView_53:cmd_0x8113_Resp(data)
  2309. function cmd_0x8113_RespEx(onEnd)
  2310. local isShow_XiaoJu = (self.XiaoJuView and self.XiaoJuView:isVisible()) or false
  2311. -- 如果之前没显示过小结算,或者是解散导致的结束,直接显示大结算
  2312. if not isShow_XiaoJu or app.room.roomInfo._stopFlag == 9 then
  2313. --隐藏小局结算
  2314. self:setXiaoJuVisible(false)
  2315. --显示总结算
  2316. self:showDaJu(data.response)
  2317. end
  2318. --关闭结算界面
  2319. app.room:dispatchEvent({ name = GAME_EVENT.DISSMISS_CLOSE })
  2320. if onEnd then
  2321. onEnd()
  2322. end
  2323. end
  2324. self:addCallBack(cmd_0x8113_RespEx)
  2325. end
  2326. function RoomView_53:cmd_0x8114_Resp(data)
  2327. function cmd_0x8114_RespEx(onEnd)
  2328. --重置桌面
  2329. self:defaultState()
  2330. if onEnd then
  2331. onEnd()
  2332. end
  2333. end
  2334. self:addCallBack(cmd_0x8114_RespEx)
  2335. end
  2336. -- 通知漂
  2337. function RoomView_53:cmd_0x8115_Resp(data)
  2338. function cmd_0x8115_RespEx(onEnd)
  2339. --当前操作玩家
  2340. self.curViewId = app.room:getViewIdByUserId(data.response.nUserId)
  2341. --显示闹钟
  2342. -- self.PlayerView:setClockVisibel(true, self.curViewId, data.response.nChoosePiaoTimeout)
  2343. -- 显示定飘中
  2344. self.PlayerView:setChoosePiaoVisible(true, self.curViewId)
  2345. -- 显示漂界面
  2346. if self.curViewId == self:getMeViewId() then
  2347. self:setPiaoVisible(true)
  2348. end
  2349. -- 显示之前的标记(之前有漂过的玩家,就不会在通知到了)
  2350. self:showHeadTip('piao')
  2351. -- 更新局数
  2352. self:updateGameNums()
  2353. --隐藏所有准备
  2354. self:setAllReadyVisible(false)
  2355. -- 打开解散按钮
  2356. self:updateButtonInPiao()
  2357. if onEnd then
  2358. onEnd()
  2359. end
  2360. end
  2361. self:addCallBack(cmd_0x8115_RespEx)
  2362. end
  2363. -- 通知漂结果
  2364. function RoomView_53:cmd_0x8116_Resp(data)
  2365. -- todo playerHead show piao and table show piao tag
  2366. function cmd_0x8116_RespEx(onEnd)
  2367. --隐藏叫分界面
  2368. if data.response.nUserId == app.room:getMyUserId() then
  2369. self:setPiaoVisible(false)
  2370. end
  2371. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  2372. --隐藏闹钟
  2373. self.PlayerView:setClockVisibel(false, viewId)
  2374. --显示漂
  2375. self.PlayerView:setTipsVisible("tips_piao", true, viewId, {piaoState = data.response.nPiaoState})
  2376. --播放音效
  2377. local str = (data.response.nPiaoState == defs.PIAO_STATE.PIAO_STATE_YES) and 'piao' or 'bupiao'
  2378. Functions.playVoice(str, data.response.nPiaoState, self.PlayerView:getPlayerData("sex", viewId))
  2379. -- 隐藏定飘中
  2380. self.PlayerView:setChoosePiaoVisible(false, viewId)
  2381. if onEnd then
  2382. onEnd()
  2383. end
  2384. end
  2385. self:addCallBack(cmd_0x8116_RespEx)
  2386. end
  2387. -- 翻牌信息
  2388. function RoomView_53:cmd_0x8117_Resp(data)
  2389. function cmd_0x8117_RespEx(onEnd)
  2390. local winSize = cc.Director:getInstance():getWinSize()
  2391. local node = DDZ_New_Effect_Helper:fanPaiAni(data.response.nTurnCard, onEnd)
  2392. node:setPosition(cc.p(winSize.width/2, winSize.height/2 + 80))
  2393. self.ui.Items.Layout_Game:addChild(node)
  2394. --隐藏所有准备
  2395. self:setAllReadyVisible(false)
  2396. -- 隐藏标记
  2397. self.PlayerView:hideAllTip()
  2398. --更新局数
  2399. self:updateGameNums()
  2400. -- 显示头标记
  2401. self:showHeadTip('piao')
  2402. --更新按钮状态
  2403. self:updateButtons()
  2404. end
  2405. self:addCallBack(cmd_0x8117_RespEx)
  2406. end
  2407. -- 通知玩家是否选择闷抓or闷倒
  2408. function RoomView_53:cmd_0x8118_Resp(data)
  2409. function cmd_0x8117_RespEx(onEnd)
  2410. --当前操作玩家
  2411. self.curViewId = app.room:getViewIdByUserId(data.response.nUserId)
  2412. self.PlayerView:setClockVisibel(true, self.curViewId, data.response.leftTime)
  2413. -- 显示闷抓or闷倒
  2414. if self.curViewId == self:getMeViewId() then
  2415. if data.response.nMenZhuaState == defs.MEN_STATE.MEN_STATE_WAIT then
  2416. self:setMenZhuaVisible(true)
  2417. elseif data.response.nMenZhuaState == defs.MEN_STATE.MEN_STATE_DAO_WAIT then
  2418. self:setMenDaoVisible(true)
  2419. end
  2420. end
  2421. if onEnd then
  2422. onEnd()
  2423. end
  2424. end
  2425. self:addCallBack(cmd_0x8117_RespEx)
  2426. end
  2427. -- 广播玩家闷抓or闷倒结果
  2428. function RoomView_53:cmd_0x8119_Resp(data)
  2429. function cmd_0x8119_RespEx(onEnd)
  2430. if data.response.nUserId == app.room:getMyUserId() then
  2431. self:setMenZhuaVisible(false)
  2432. self:setMenDaoVisible(false)
  2433. end
  2434. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  2435. self.PlayerView:setClockVisibel(false, viewId)
  2436. --显示玩家闷抓or闷倒
  2437. local voiceStr = 'menzhua'
  2438. if data.response.nMenZhuaState <= defs.MEN_STATE.MEN_STATE_ZHUAI then
  2439. self.PlayerView:setTipsVisible("tips_menzhua", true, viewId, {menzhua = data.response.nMenZhuaState})
  2440. voiceStr = 'menzhua'
  2441. elseif data.response.nMenZhuaState <= defs.MEN_STATE.MEN_STATE_DAO then
  2442. self.PlayerView:setTipsVisible("tips_mendao", true, viewId, {mendao = data.response.nMenZhuaState})
  2443. voiceStr = 'mendao'
  2444. end
  2445. --播放音效 jxtd
  2446. -- Functions.playVoice(voiceStr, data.response.nMenZhuaState, self.PlayerView:getPlayerData("sex", viewId))
  2447. if onEnd then
  2448. onEnd()
  2449. end
  2450. end
  2451. self:addCallBack(cmd_0x8119_RespEx)
  2452. end
  2453. -- 通知玩家是否选择闷拉
  2454. function RoomView_53:cmd_0x811b_Resp(data)
  2455. function cmd_0x811b_RespEx(onEnd)
  2456. --当前操作玩家
  2457. self.curViewId = app.room:getViewIdByUserId(data.response.nUserId)
  2458. -- 隐藏闷抓tip
  2459. self.PlayerView:setTipsVisible("tips_menzhua", false, self.curViewId)
  2460. self.PlayerView:setClockVisibel(true, self.curViewId, data.response.leftTime)
  2461. -- 显示闷拉
  2462. if self.curViewId == self:getMeViewId() then
  2463. if data.response.nMenLaState == defs.MEN_LA_STATE.MEN_STATE_LA_WAIT then
  2464. self:setMenLaVisible(true)
  2465. end
  2466. end
  2467. if onEnd then
  2468. onEnd()
  2469. end
  2470. end
  2471. self:addCallBack(cmd_0x811b_RespEx)
  2472. end
  2473. -- 广播玩家闷拉结果
  2474. function RoomView_53:cmd_0x811c_Resp(data)
  2475. function cmd_0x811c_RespEx(onEnd)
  2476. if data.response.nUserId == app.room:getMyUserId() then
  2477. self:setMenLaVisible(false)
  2478. end
  2479. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  2480. self.PlayerView:setClockVisibel(false, viewId)
  2481. self.PlayerView:setTipsVisible("tips_menzhua", false, viewId)
  2482. self.PlayerView:setTipsVisible("tips_menla", true, viewId, {menla = data.response.nMenLaState})
  2483. --播放音效 jxtd
  2484. -- Functions.playVoice("tips_menla", data.response.nMenLaState, self.PlayerView:getPlayerData("sex", viewId))
  2485. if onEnd then
  2486. onEnd()
  2487. end
  2488. end
  2489. self:addCallBack(cmd_0x811c_RespEx)
  2490. end
  2491. --游戏消息
  2492. function RoomView_53:bindGameMessage()
  2493. self:bindEvent(app.room , "cmd_0x8104_Resp", handler(self , self.cmd_0x8104_Resp))
  2494. self:bindEvent(app.room , "cmd_0x8105_Resp", handler(self , self.cmd_0x8105_Resp))
  2495. self:bindEvent(app.room , "cmd_0x8106_Resp", handler(self , self.cmd_0x8106_Resp))
  2496. self:bindEvent(app.room , "cmd_0x8108_Resp", handler(self , self.cmd_0x8108_Resp)) -- 抓(叫地主)
  2497. self:bindEvent(app.room , "cmd_0x8109_Resp", handler(self , self.cmd_0x8109_Resp)) -- 抓结果(叫地主)
  2498. self:bindEvent(app.room , "cmd_0x810a_Resp", handler(self , self.cmd_0x810a_Resp))
  2499. self:bindEvent(app.room , "cmd_0x810c_Resp", handler(self , self.cmd_0x810c_Resp)) -- 倒or拉(加倍)
  2500. self:bindEvent(app.room , "cmd_0x810d_Resp", handler(self , self.cmd_0x810d_Resp)) -- 倒or拉结果(加倍)
  2501. self:bindEvent(app.room , "cmd_0x810e_Resp", handler(self , self.cmd_0x810e_Resp))
  2502. self:bindEvent(app.room , "cmd_0x810f_Resp", handler(self , self.cmd_0x810f_Resp))
  2503. self:bindEvent(app.room , "cmd_0x8110_Resp", handler(self , self.cmd_0x8110_Resp))
  2504. self:bindEvent(app.room , "cmd_0x8111_Resp", handler(self , self.cmd_0x8111_Resp))
  2505. self:bindEvent(app.room , "cmd_0x8112_Resp", handler(self , self.cmd_0x8112_Resp))
  2506. self:bindEvent(app.room , "cmd_0x8113_Resp", handler(self , self.cmd_0x8113_Resp))
  2507. self:bindEvent(app.room , "cmd_0x8114_Resp", handler(self , self.cmd_0x8114_Resp))
  2508. self:bindEvent(app.room , "cmd_0x8115_Resp", handler(self , self.cmd_0x8115_Resp)) -- 通知漂
  2509. self:bindEvent(app.room , "cmd_0x8116_Resp", handler(self , self.cmd_0x8116_Resp)) -- 通知漂结果
  2510. self:bindEvent(app.room , "cmd_0x8117_Resp", handler(self , self.cmd_0x8117_Resp)) -- 翻牌信息
  2511. self:bindEvent(app.room , "cmd_0x8118_Resp", handler(self , self.cmd_0x8118_Resp)) -- 通知玩家是否选择闷抓or闷倒
  2512. self:bindEvent(app.room , "cmd_0x8119_Resp", handler(self , self.cmd_0x8119_Resp)) -- 广播玩家闷抓or闷倒结果
  2513. self:bindEvent(app.room , "cmd_0x811b_Resp", handler(self , self.cmd_0x811b_Resp)) -- 通知玩家是否选择闷拉
  2514. self:bindEvent(app.room , "cmd_0x811c_Resp", handler(self , self.cmd_0x811c_Resp)) -- 广播玩家闷拉结果
  2515. end
  2516. return RoomView_53