You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

811 lines
23 KiB

  1. local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
  2. local ZPMessage = ZPFramework.ZPImport("zp_base.luaScript.Protocol.ZPMessage")
  3. local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
  4. local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
  5. local ZPRoomPlayerView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomPlayerView")
  6. local xichongRoomPlayerView = class("xichongRoomPlayerView", ZPRoomPlayerView)
  7. function xichongRoomPlayerView:ctor( ... )
  8. xichongRoomPlayerView.super.ctor(self)
  9. end
  10. function xichongRoomPlayerView:loadUI()
  11. local ui = loadUI("zp_xichong/res/ui/ui_fangjian/xichong_ui_PlayerView.ui");
  12. self.ui = ui;
  13. self:addChild(ui);
  14. ---经典模式下头像的位置
  15. self.jDPlayerPos = {}
  16. --现代模式下头像的位置
  17. self.xDPlayerPos = {}
  18. ---经典模式下闹钟的位置
  19. self.jDClockPos = {}
  20. --现代模式下闹钟的位置
  21. self.xDClockPos = {}
  22. ---经典模式下特效的位置
  23. self.jDEffectPos = {}
  24. --现代模式下特效的位置
  25. self.xDEffectPos = {}
  26. end
  27. function xichongRoomPlayerView:onEnter()
  28. xichongRoomPlayerView.super.onEnter(self)
  29. self:bindEvent(app, 'EVENT_CHANGE_CHAT_ENABLED', handler(self, self.onEventChatChangeEnable));
  30. self:resetTuoGuanShow()
  31. end
  32. -- 托管显示
  33. function xichongRoomPlayerView:resetTuoGuanShow()
  34. for i=1,4 do
  35. self.ui.Items["ImageView_tuoguan_"..i]:setVisible(false)
  36. end
  37. end
  38. -- 显示指定玩家头像托管标识
  39. function xichongRoomPlayerView:showTuoGuanByViewId(viewId,bVisible)
  40. self.ui.Items["ImageView_tuoguan_"..viewId]:setVisible(bVisible)
  41. end
  42. function xichongRoomPlayerView:initPlayerNodes()
  43. -- 玩家节点名称模板
  44. local names =
  45. {
  46. player = "Layout_player_%d", -- 头像绿圈根节点
  47. tempplayer = "Layout_player_Temp_%d",
  48. head = "ImageView_head_%d", -- 头像
  49. headBoarder = "ImageView_head_border_%d", --头像边
  50. score = "Text_Score_%d", -- 总分数
  51. banker = "ImageView_banker_%d", -- 庄家
  52. readyState = "ImageView_ready_%d", -- 准备
  53. headInfo = "Layout_headInfo_%d", --个人信息点击触发框
  54. offLine = "ImageView_offLine_%d", --离线标志
  55. --其他节点
  56. tip = "ImageView_tip_%d", --提示操作图
  57. clock = "ImageView_clock_%d", --闹钟
  58. txtClocl = "TextBMFont_clock_%d", --闹钟时间
  59. offLineTime = "Text_offLineTime_%d", --离线时间
  60. offLineTimeBg = "ImageView_txkYY_%d", --离线时间背景
  61. toujia = "ImageView_toujia_icon_%d", --头家角标
  62. xiaojia = "ImageView_xiao_icon_%d", --小家家角标
  63. tuoShu = "Text_tuoshuNum_%d", --坨数
  64. piao = "ImageView_Piao_%d", --漂
  65. dingpiao = "ImageView_piaoing_%d", --漂
  66. paiXing = "Layout_Paixing_%d", --牌型
  67. paiXingType = "ImageView_leixing_%d", --牌型名字
  68. dang = "ImageView_dang_icon_%d", --当
  69. baoType = "Layout_BaoType_%d", --玩家点击报播放的类型
  70. cloneClock = "ImageView_temp_clock_%d", --切换版式后闹钟位置
  71. cloneEffect = "ImageView_tip_clone_%d", --切换版式后特效的位置
  72. huCardBg = "ImageView_HuCard_BG_%d",
  73. huCard = "ImageView_HuCard_%d",
  74. }
  75. self.allNodes = {}
  76. self.headSize = {}
  77. for i = 1,ZPDef.GameMaxPlayer do
  78. local nodes = {}
  79. --玩家根节点
  80. local namePlayer = string.format(names.player,i)
  81. local nodePlayer = self.ui.Items[namePlayer]
  82. nodes.player = nodePlayer
  83. --头像
  84. local nameHead = string.format(names.head,i)
  85. local nodeHead = self.ui.Items[nameHead]
  86. nodes.head = nodeHead
  87. nodeHead:setTouchEnabled(true)
  88. nodeHead:registerClick(function()
  89. self:onClickHead(i)
  90. end)
  91. local headBoarder = string.format(names.headBoarder,i)
  92. local nodeheadBoarder = self.ui.Items[headBoarder]
  93. nodes.headBoarder = nodeheadBoarder
  94. -- 需要记录头像的原始尺寸
  95. if not self.headSize.width then
  96. self.headSize.width = nodeHead:getContentSize().width
  97. self.headSize.height = nodeHead:getContentSize().height
  98. end
  99. --总分
  100. local nickScore = string.format(names.score,i)
  101. local nodeScore = self.ui.Items[nickScore]
  102. nodes.score = nodeScore
  103. --坨数
  104. local nicktuoShu = string.format(names.tuoShu,i)
  105. local nodetuoShu = self.ui.Items[nicktuoShu]
  106. nodes.tuoShu = nodetuoShu
  107. --庄家
  108. local nameBanker = string.format(names.banker,i)
  109. local nodeBanker = self.ui.Items[nameBanker]
  110. nodes.banker = nodeBanker
  111. nodes.banker.pos = nodeBanker:getPosition()
  112. --准备
  113. local nameReadyState = string.format(names.readyState,i)
  114. local nodeReadyState = self.ui.Items[nameReadyState]
  115. nodes.readyState = nodeReadyState
  116. --头像信息
  117. local headInfo = string.format(names.headInfo,i)
  118. local nodeheadInfo = self.ui.Items[headInfo]
  119. nodes.headInfo = nodeheadInfo
  120. --离线信息
  121. local offLine = string.format(names.offLine,i)
  122. local nodeoffLine = self.ui.Items[offLine]
  123. nodes.offLine = nodeoffLine
  124. --tip
  125. local nameTip = string.format(names.tip,i)
  126. local nodeTip = self.ui.Items[nameTip]
  127. nodes.tip = nodeTip
  128. self.xDEffectPos[i] = self.ui.Items[nameTip]:getPosition()
  129. local nameCloneEffect = string.format(names.cloneEffect,i)
  130. self.jDEffectPos[i] = self.ui.Items[nameCloneEffect]:getPosition()
  131. --闹钟
  132. local nameClock = string.format(names.clock,i)
  133. local nodeClock = self.ui.Items[nameClock]
  134. nodes.clock = nodeClock
  135. self.xDClockPos[i] = self.ui.Items[nameClock]:getPosition()
  136. local nameCloneClock = string.format(names.cloneClock,i)
  137. self.jDClockPos[i] = self.ui.Items[nameCloneClock]:getPosition()
  138. --闹钟时间
  139. local nametxtClock = string.format(names.txtClocl,i)
  140. local nodetxtClock = self.ui.Items[nametxtClock]
  141. nodes.txtclock = nodetxtClock
  142. --离线时间
  143. local nameoffLineTime = string.format(names.offLineTime,i)
  144. local nodeoffLineTime = self.ui.Items[nameoffLineTime]
  145. nodes.offLineTime = nodeoffLineTime
  146. --离线时间背景
  147. local nameoffLineTimeBg = string.format(names.offLineTimeBg,i)
  148. local nodeoffLineTimeBg = self.ui.Items[nameoffLineTimeBg]
  149. nodes.offLineTimeBg = nodeoffLineTimeBg
  150. nodes.offLineTimeBg:setVisible(false)
  151. --头家
  152. local toujia = string.format(names.toujia,i)
  153. local nodetoujia = self.ui.Items[toujia]
  154. nodes.toujia = nodetoujia
  155. --小家
  156. local xiaojia = string.format(names.xiaojia,i)
  157. local nodexiaojia = self.ui.Items[xiaojia]
  158. nodes.xiaojia = nodexiaojia
  159. --漂
  160. local piao = string.format(names.piao,i)
  161. local nodepiao = self.ui.Items[piao]
  162. nodes.piao = nodepiao
  163. --定漂中
  164. local dingpiao = string.format(names.dingpiao,i)
  165. local nodedingpiao = self.ui.Items[dingpiao]
  166. nodes.dingpiao = nodedingpiao
  167. --牌型
  168. local paiXing = string.format(names.paiXing,i)
  169. local nodePaiXing = self.ui.Items[paiXing]
  170. nodes.paiXing = nodePaiXing
  171. --牌型
  172. local paiXingType = string.format(names.paiXingType,i)
  173. local nodepaiXingType = self.ui.Items[paiXingType]
  174. nodes.paiXingType = nodepaiXingType
  175. --当
  176. local dang = string.format(names.dang,i)
  177. local nodedang = self.ui.Items[dang]
  178. nodes.dang = nodedang
  179. --报类型
  180. local baoType = string.format(names.baoType,i)
  181. local nodebaoType = self.ui.Items[baoType]
  182. nodes.baoType = nodebaoType
  183. local huCardBg = string.format(names.huCardBg, i)
  184. local nodeHuCardBg = self.ui.Items[huCardBg]
  185. nodeHuCardBg:setVisible(false)
  186. nodes.huCardBg = nodeHuCardBg
  187. local huCard = string.format(names.huCard, i)
  188. local nodeHuCard = self.ui.Items[huCard]
  189. nodes.huCard = nodeHuCard
  190. self.allNodes[i] = nodes
  191. self.xDPlayerPos[i] = self.ui.Items[namePlayer]:getPosition()
  192. local tempPlayer = string.format(names.tempplayer,i)
  193. self.ui.Items[tempPlayer]:setVisible(false)
  194. self.jDPlayerPos[i] = self.ui.Items[tempPlayer]:getPosition()
  195. end
  196. self:initChatComponent()
  197. self:setAllClockVisible(false)
  198. self:setOwnerVisible()
  199. self:stopAndHideBaoAnim()
  200. self:setXiaoJiaFlagVis(false)
  201. self:hideTouJia()
  202. self:hideXiaoJia()
  203. self:hidePiao()
  204. self:hideDang()
  205. self:hideBaoType()
  206. end
  207. function xichongRoomPlayerView:updatePlayerInfo(index)
  208. logE("ZPRoomView:updatePlayerInfo() index = ", index)
  209. local nodes = self.allNodes[index]
  210. if not nodes then return end
  211. local nUserId = app.room.seatShowList[index]
  212. local roomInfo = app.room.roomInfo
  213. local memberInfo = app.room.roomInfo.memberList[nUserId]
  214. if nUserId and app.room:checkUserIDIsInTable(nUserId) then--memberInfo and memberInfo.userInfo then
  215. nodes.player:setVisible(true)
  216. local userInfo = json.decode(memberInfo.userInfo)
  217. if not userInfo then
  218. return
  219. end
  220. -- 玩家名字
  221. local nickname = userInfo.nickname
  222. nickname = getSubStringNickname(nickname)
  223. --nodes.name:setText(tostring(nickname))
  224. nodes.score:setText(tostring(memberInfo.nTotalMoney))
  225. -- 玩家头像
  226. local nodeHead = nodes.head;
  227. --先设置默认头像
  228. local width = nodeHead:getContentSize().width
  229. setPlayerHeadImage(nUserId, userInfo.headimgurl, nodeHead)
  230. if app.room.offLineUid[tonumber(nUserId)] or (memberInfo.nOnlineStatus and memberInfo.nOnlineStatus~=1) then
  231. self:setPlayerOffLine(true,index)
  232. else
  233. self:setPlayerOffLine(false,index)
  234. end
  235. else
  236. nodes.player:setVisible(false)
  237. end
  238. end
  239. --隐藏牌型
  240. function xichongRoomPlayerView:hideBaoType()
  241. for i = 1,ZPDef.GameMaxPlayer do
  242. self.allNodes[i].baoType:setVisible(false)
  243. end
  244. end
  245. --隐藏牌型
  246. function xichongRoomPlayerView:hidePaiXing()
  247. for i = 1,ZPDef.GameMaxPlayer do
  248. self.allNodes[i].paiXing:setVisible(false)
  249. end
  250. end
  251. --设置某个玩家的报的类型
  252. function xichongRoomPlayerView:playBaoTypeAni(viewId,baoTypeList,card)
  253. local cardImage = string.format("ImageView_BaoCard_%d",viewId)
  254. local ImageCard = self.ui.Items[cardImage]
  255. local fileName = ZPFuc.getZPCardImgByValue(card,ZPDef.CardType.CARD_TYPE_HAND)
  256. ImageCard:loadTextureFromPlist(fileName)
  257. local paiXingNode = self.allNodes[viewId].baoType
  258. --先全部隐藏
  259. for i = 1, 3 do
  260. if i == 3 then
  261. i = i+1
  262. end
  263. local baoType = string.format("Layout_BaoType%d_%d",i,viewId)
  264. self.ui.Items[baoType]:setVisible(false)
  265. end
  266. --按发过来的类型显示
  267. for k,v in pairs(baoTypeList or {}) do
  268. local baoImage = string.format("Layout_BaoType%d_%d",v,viewId)
  269. local baoImageNode = self.ui.Items[baoImage]
  270. baoImageNode:setVisible(true)
  271. end
  272. paiXingNode:requestDoLayout()
  273. paiXingNode:doLayout()
  274. paiXingNode:setVisible(true)
  275. local seq = cc.Sequence:create(cc.DelayTime:create(3.0),cc.CallFunc:create(function ()
  276. paiXingNode:setVisible(false)
  277. end))
  278. paiXingNode:runAction(seq)
  279. return false
  280. end
  281. ---
  282. -- 获取牌型图片
  283. -- @param paiXing
  284. -- @return
  285. --
  286. function xichongRoomPlayerView:getPaiXingImage(paiXing)
  287. local img = ""
  288. if paiXing == ZPDef.BaoOpCode.BAO_ZHAO_CHI then
  289. img = ZPDef.PaiXingFile.ZHAOCHI
  290. elseif paiXing == ZPDef.BaoOpCode.BAO_TUI then
  291. img = ZPDef.PaiXingFile.BAOTUI
  292. elseif paiXing == ZPDef.BaoOpCode.BAO_HOU_DUI then
  293. img = ZPDef.PaiXingFile.HOUDUI
  294. elseif paiXing == ZPDef.BaoOpCode.BAO_PO_DUI then
  295. img = ZPDef.PaiXingFile.PODUI
  296. elseif paiXing == ZPDef.BaoOpCode.BAO_CHENG_KAN then
  297. img = ZPDef.PaiXingFile.CHENGKAN
  298. elseif paiXing == ZPDef.BaoOpCode.BAO_SI_ZHANG then
  299. img = ZPDef.PaiXingFile.SIZHANG
  300. elseif paiXing == ZPDef.BaoOpCode.DIAO_CHENG_KAN then
  301. img = ZPDef.PaiXingFile.DIAOKAN
  302. elseif paiXing == ZPDef.BaoOpCode.DIAO_CHENG_SIZHANG then
  303. img = ZPDef.PaiXingFile.DIAOSIZHANG
  304. elseif paiXing == ZPDef.CustomOpCode.CHI_CHENG_SI_GEN then
  305. img = ZPDef.PaiXingFile.CHICEHNGSIZHANG
  306. elseif paiXing == ZPDef.CustomOpCode.HU_CHENG_SI_GEN then
  307. img = ZPDef.PaiXingFile.HUCEHNGSIZHANG
  308. elseif paiXing == ZPDef.CustomOpCode.CHI_CHENG_KAN then
  309. img = ZPDef.PaiXingFile.CHICEHNGKAN
  310. elseif paiXing == ZPDef.CustomOpCode.HU_CHENG_KAN then
  311. img = ZPDef.PaiXingFile.HUCEHNGKAN
  312. end
  313. return img
  314. end
  315. ---
  316. -- 设置某个玩家的牌型
  317. -- @param viewId
  318. -- @param paiXingList
  319. -- @param card
  320. -- @param callback
  321. -- @return
  322. --
  323. function xichongRoomPlayerView:playPaiXingAniList(viewId, paiXingList, card, callback)
  324. local layoutPaiXing = self.ui.Items["Layout_Paixing_" .. viewId]
  325. layoutPaiXing:removeAllChildren()
  326. local cardTemplate = self.ui.Items.Layout_Leixing_Card_Template;
  327. cardTemplate:setVisible(false)
  328. local paiXingTemplate = self.ui.Items.Layout_Leixing_Template;
  329. paiXingTemplate:setVisible(false)
  330. local cardItem = cardTemplate:getCopied()
  331. local cardImage = cardItem:getChildByName("ImageView_Card")
  332. local fileName = ZPFuc.getZPCardImgByValue(card,ZPDef.CardType.CARD_TYPE_HAND)
  333. cardImage:loadTextureFromPlist(fileName)
  334. if viewId > 2 then
  335. layoutPaiXing:addChild(cardItem)
  336. end
  337. local x = 0
  338. for k, v in pairs(paiXingList or {}) do
  339. local path = self:getPaiXingImage(v)
  340. local item = paiXingTemplate:getCopied()
  341. local img = item:getChildByName("ImageView_PaiXing")
  342. img:loadTexture(path)
  343. local w = img:getContentSize().width
  344. local size = item:getSize()
  345. size.width = (w + 20) * 1.2
  346. item:setSize(size)
  347. layoutPaiXing:addChild(item)
  348. end
  349. if viewId <= 2 then
  350. layoutPaiXing:addChild(cardItem)
  351. end
  352. logD("xichongRoomPlayerView playPaiXingAniList", paiXingList)
  353. layoutPaiXing:setVisible(true)
  354. local seq = cc.Sequence:create(cc.DelayTime:create(3.0),cc.CallFunc:create(function ()
  355. layoutPaiXing:setVisible(false)
  356. if type(callback) == "function" then
  357. callback()
  358. end
  359. end))
  360. layoutPaiXing:runAction(seq)
  361. end
  362. ---
  363. -- 设置某个玩家的牌型
  364. -- @param viewId
  365. -- @param paixing
  366. -- @param card
  367. -- @param callback
  368. -- @return
  369. --
  370. function xichongRoomPlayerView:playPaiXingAni(viewId,paixing,card,callback)
  371. return self:playPaiXingAniList(viewId, {paiXing}, card, callback)
  372. end
  373. --设置某个玩家的吃成砍
  374. function xichongRoomPlayerView:playChiChengKan(viewId,card,ishu)
  375. local paiXing = nil
  376. if ishu == 1 then
  377. paiXing = ZPDef.CustomOpCode.HU_CHENG_KAN
  378. else
  379. paiXing = ZPDef.CustomOpCode.CHI_CHENG_KAN
  380. end
  381. local paiXingNode = self.allNodes[viewId].paiXing
  382. --先要播吃动画 再播报动画
  383. local seq = cc.Sequence:create(cc.DelayTime:create(0.6),cc.CallFunc:create(function()
  384. local nUserID = app.room:getUserIdByViewId(viewId)
  385. local userInfo=app.room:getUserInfo(nUserID)
  386. if userInfo then
  387. ZPSound.PlayOperateSound(userInfo.sex,-55)
  388. end
  389. self:playPaiXingAniList(viewId, {paiXing}, card, function ()
  390. end)
  391. end))
  392. paiXingNode:runAction(seq)
  393. return false
  394. end
  395. --设置某个玩家的吃成四根
  396. function xichongRoomPlayerView:playChiChengSiZhang(viewId,card,ishu)
  397. local paiXingNode = self.allNodes[viewId].paiXing
  398. local paiXing = nil
  399. if ishu == 1 then
  400. paiXing = ZPDef.CustomOpCode.HU_CHENG_SI_GEN
  401. else
  402. paiXing = ZPDef.CustomOpCode.CHI_CHENG_SI_GEN
  403. end
  404. local seq = cc.Sequence:create(cc.DelayTime:create(0.6),cc.CallFunc:create(function()
  405. local nUserID = app.room:getUserIdByViewId(viewId)
  406. local userInfo=app.room:getUserInfo(nUserID)
  407. if userInfo then
  408. ZPSound.PlayOperateSound(userInfo.sex,-55)
  409. end
  410. self:playPaiXingAniList(viewId, {paiXing}, card, function ()
  411. end)
  412. end))
  413. paiXingNode:runAction(seq)
  414. return false
  415. end
  416. --隐藏头家
  417. function xichongRoomPlayerView:hideTouJia()
  418. for i = 1,ZPDef.GameMaxPlayer do
  419. self.allNodes[i].toujia:setVisible(false)
  420. end
  421. end
  422. --设置某个玩家为头家
  423. function xichongRoomPlayerView:setPlayerTouJiaVisible(viewId,bVisible)
  424. if self.allNodes[viewId] then
  425. self.allNodes[viewId].toujia:setVisible(bVisible)
  426. return true
  427. end
  428. return false
  429. end
  430. --隐藏当
  431. function xichongRoomPlayerView:hideDang()
  432. for i = 1,ZPDef.GameMaxPlayer do
  433. self.allNodes[i].dang:setVisible(false)
  434. end
  435. end
  436. --设置某个玩家当
  437. function xichongRoomPlayerView:setPlayerDangVisible(viewId,bVisible)
  438. if self.allNodes[viewId] then
  439. self.allNodes[viewId].dang:setVisible(bVisible)
  440. return true
  441. end
  442. return false
  443. end
  444. --隐藏小家
  445. function xichongRoomPlayerView:hideXiaoJia()
  446. for i = 1,ZPDef.GameMaxPlayer do
  447. self.allNodes[i].xiaojia:setVisible(false)
  448. end
  449. end
  450. --设置某个玩家为小家
  451. function xichongRoomPlayerView:setPlayerXiaoJiaVisible(viewId,bVisible)
  452. if self.allNodes[viewId] then
  453. self.allNodes[viewId].xiaojia:setVisible(bVisible)
  454. return true
  455. end
  456. return false
  457. end
  458. --隐藏漂
  459. function xichongRoomPlayerView:hidePiao()
  460. for i = 1,ZPDef.GameMaxPlayer do
  461. self.allNodes[i].piao:setVisible(false)
  462. end
  463. end
  464. --设置某个玩家漂
  465. function xichongRoomPlayerView:setPlayerPiaoVisible(viewId,bVisible)
  466. if self.allNodes[viewId] then
  467. self.allNodes[viewId].piao:setVisible(bVisible)
  468. return true
  469. end
  470. return false
  471. end
  472. --隐藏定漂中
  473. function xichongRoomPlayerView:hideDingPiao()
  474. for i = 1,ZPDef.GameMaxPlayer do
  475. if self.allNodes[i].dingpiao then
  476. self.allNodes[i].dingpiao:setVisible(false)
  477. end
  478. end
  479. end
  480. --设置某个玩家定漂中
  481. function xichongRoomPlayerView:setPlayerDingPiaoVisible(viewId,bVisible)
  482. if self.allNodes[viewId] then
  483. if self.allNodes[viewId].dingpiao then
  484. self.allNodes[viewId].dingpiao:setVisible(bVisible)
  485. end
  486. return true
  487. end
  488. return false
  489. end
  490. --隐藏房主
  491. function xichongRoomPlayerView:setOwnerVisible()
  492. end
  493. --设置某个房主Visible
  494. function xichongRoomPlayerView:setPlayerOwnerVisible(viewId,bVisible)
  495. return false
  496. end
  497. --设置胡息归0
  498. function xichongRoomPlayerView:setHuXizero()
  499. end
  500. --设置某个玩家胡息
  501. function xichongRoomPlayerView:setPlayerHuXi(viewId,huxi)
  502. end
  503. function xichongRoomPlayerView:stopAndHideBaoAnim()
  504. end
  505. function xichongRoomPlayerView:playBaoAnim(view)
  506. end
  507. --设置小家标志显示
  508. function xichongRoomPlayerView:setXiaoJiaFlagVis(vis)
  509. end
  510. --设置某个庄家Visible
  511. function xichongRoomPlayerView:setPlayerBankerVisible(viewId,bVisible)
  512. return false
  513. end
  514. --用户行为提示
  515. function xichongRoomPlayerView:showOperatorTip(viewId,mType)
  516. local tip = self.allNodes[viewId].tip
  517. local time = 0.5
  518. tip:setVisible(true)
  519. local count = 0
  520. if mType == ZPDef.OpType.OP_TYPE_CANCEL then
  521. tip:loadTextureFromPlist(ZPDef.TipFile.GUO)
  522. elseif mType == ZPDef.OpType.OP_TYPE_CHI then
  523. tip:loadTexture(ZPDef.TipFile.CHI)
  524. elseif mType == ZPDef.OpType.OP_TYPE_PENG then
  525. tip:loadTexture(ZPDef.TipFile.PENG)
  526. elseif mType == ZPDef.OpType.OP_TYPE_ANSIZHANG then
  527. tip:loadTexture(ZPDef.TipFile.BA)
  528. elseif mType == ZPDef.OpType.OP_TYPE_ANSANZHANG then
  529. tip:loadTexture(ZPDef.TipFile.TOU)
  530. elseif mType == ZPDef.OpType.OP_TYPE_HU then
  531. time = 2.0
  532. if app.room.roomInfo.huType and app.room.roomInfo.huType >= 0 then
  533. local name = string.format(ZPDef.TipFile.HU,app.room.roomInfo.huType)
  534. tip:loadTextureFromPlist(name)
  535. end
  536. elseif mType == -55 then--单独处理爆牌动画
  537. tip:loadTexture(ZPDef.TipFile.BAOJIAO)
  538. elseif mType == -56 then
  539. tip:loadTexture(ZPDef.TipFile.BAOPEI)
  540. elseif mType == ZPDef.OpType.OP_TYPE_JIAOPAI then --叫牌
  541. tip:loadTexture(ZPDef.TipFile.JIAOPAI)
  542. elseif mType == ZPDef.OpType.OP_TYPE_ZUOZHUANG then --做壮
  543. tip:loadTexture(ZPDef.TipFile.ZUOZHUANG)
  544. elseif mType == ZPDef.OpType.OP_TYPE_DANG then --当
  545. tip:loadTexture(ZPDef.TipFile.DANG)
  546. elseif mType == ZPDef.OpType.OP_TYPE_PIAO then
  547. tip:loadTexture(ZPDef.TipFile.PIAO)
  548. elseif mType == ZPDef.OpType.OP_TYPE_KUA then
  549. tip:loadTexture(ZPDef.TipFile.KUA)
  550. elseif mType == ZPDef.OpType.OP_TYPE_WEIGUI then
  551. tip:loadTexture(ZPDef.TipFile.WEIGUI)
  552. end
  553. --音效
  554. local nUserId = app.room:getUserIdByViewId(viewId)
  555. local userInfo=app.room:getUserInfo(nUserId)
  556. if userInfo then
  557. ZPSound.PlayOperateSound(userInfo.sex,mType)
  558. end
  559. tip:setScale(1.0)
  560. local seq = cc.Sequence:create(cc.ScaleTo:create(0.2,2.0),cc.DelayTime:create(0.1),cc.ScaleTo:create(0.2,1.0),cc.CallFunc:create(function ()
  561. tip:setVisible(false)
  562. end))
  563. tip:runAction(seq)
  564. end
  565. --设置某个玩家坨数
  566. function xichongRoomPlayerView:setPlayerTuoShu(viewId,strTuoShu)
  567. if self.allNodes[viewId] and self.allNodes[viewId].tuoShu then
  568. self.allNodes[viewId].tuoShu:setText(tostring(strTuoShu))
  569. end
  570. end
  571. --切换桌面的时候设置头像的位置
  572. function xichongRoomPlayerView:setPlayerPosByChangeTable(deskTableType)
  573. -- playBtnEffect()
  574. local playerList = {
  575. [1] = self.allNodes[1].player,
  576. [2] = self.allNodes[2].player,
  577. [3] = self.allNodes[3].player,
  578. [4] = self.allNodes[4].player,
  579. }
  580. local clockList = {
  581. [1] = self.allNodes[1].clock,
  582. [2] = self.allNodes[2].clock,
  583. [3] = self.allNodes[3].clock,
  584. [4] = self.allNodes[4].clock,
  585. }
  586. local tipList = {
  587. [1] = self.allNodes[1].tip,
  588. [2] = self.allNodes[2].tip,
  589. [3] = self.allNodes[3].tip,
  590. [4] = self.allNodes[4].tip,
  591. }
  592. if deskTableType == ZPDef.GameStyleType.JINGDIAN then
  593. for i = 1,ZPDef.GameMaxPlayer do
  594. playerList[i]:setPosition(self.jDPlayerPos[i])
  595. clockList[i]:setPosition(self.jDClockPos[i])
  596. tipList[i]:setPosition(self.jDEffectPos[i])
  597. end
  598. else
  599. for i = 1,ZPDef.GameMaxPlayer do
  600. playerList[i]:setPosition(self.xDPlayerPos[i])
  601. clockList[i]:setPosition(self.xDClockPos[i])
  602. tipList[i]:setPosition(self.xDEffectPos[i])
  603. end
  604. end
  605. end
  606. function xichongRoomPlayerView:initChatComponent()
  607. if not self._chatComponentView then
  608. local heads = {
  609. [1] = self.allNodes[1].head,
  610. [2] = self.allNodes[2].head,
  611. [3] = self.allNodes[3].head,
  612. [4] = self.allNodes[4].head,
  613. }
  614. self._chatComponentView=import("luaScript.Views.Room.RoomChatComponentView"):new(heads,ZPDef.XICHONG_GAME_CHAT_TXT)
  615. self:addChild(self._chatComponentView)
  616. end
  617. local propEnable = loadUserInfo('propEnable') or 1
  618. propEnable = propEnable == "" and 1 or propEnable
  619. self._chatComponentView:setPropEnabled(tonumber(propEnable) == 1)
  620. local voiceEnable = loadUserInfo('voiceEnable') or 1
  621. voiceEnable = voiceEnable == "" and 1 or voiceEnable
  622. self._chatComponentView:setVoiceEnabled(tonumber(voiceEnable) == 1)
  623. end
  624. function xichongRoomPlayerView:onClickHead(index)
  625. playBtnEffect()
  626. local nUserId = app.room.seatShowList[index]
  627. local memberInfo = app.room.roomInfo.memberList[nUserId]
  628. if memberInfo then
  629. local view = import("luaScript.Views.Room.RoomPlayerInfoViewNew"):new(nUserId, memberInfo.userInfo)
  630. view:setAnchorPoint(cc.p(0.5, 0.5))
  631. app:showWaitDialog(view, 0, true)
  632. end
  633. end
  634. ---
  635. -- 显示胡牌
  636. -- @param viewId
  637. -- @param isVisible
  638. -- @param huCard
  639. -- @return
  640. --
  641. function xichongRoomPlayerView:setHuCardVisible(viewId, isVisible, huCard)
  642. if not (self.allNodes and self.allNodes[viewId]) then
  643. return
  644. end
  645. if app.room.roomInfo.isZiMoHu ~= 1 then
  646. self.allNodes[viewId].huCardBg:setVisible(false)
  647. return
  648. end
  649. if not isVisible then
  650. self.allNodes[viewId].huCardBg:setVisible(false)
  651. return
  652. end
  653. if not huCard then
  654. self.allNodes[viewId].huCardBg:setVisible(false)
  655. return
  656. end
  657. self.allNodes[viewId].huCardBg:setVisible(true)
  658. local filename = ZPFuc.getZPCardImgByValue(huCard, ZPDef.CardType.CARD_TYPE_HAND, ZPDef.GameStyleType.JINGDIAN)
  659. self.allNodes[viewId].huCard:loadTextureFromPlist(filename)
  660. self:runDelay(3.0, function ()
  661. self.allNodes[viewId].huCardBg:setVisible(false)
  662. end)
  663. end
  664. ---
  665. -- 互动道具、语音开关变化处理
  666. -- @return
  667. --
  668. function xichongRoomPlayerView:onEventChatChangeEnable()
  669. self:initChatComponent()
  670. end
  671. return xichongRoomPlayerView