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.

257 lines
6.9 KiB

  1. local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
  2. local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
  3. local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
  4. local ZPRoomCard=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCard")
  5. local ZPRoomXiaoJuChaPaiView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomXiaoJuChaPaiView")
  6. local doushisiRoomXiaoJuChaPaiView = class("doushisiRoomXiaoJuChaPaiView", ZPRoomXiaoJuChaPaiView)
  7. function doushisiRoomXiaoJuChaPaiView:ctor()
  8. doushisiRoomXiaoJuChaPaiView.super.ctor(self)
  9. end
  10. function doushisiRoomXiaoJuChaPaiView:onEnter()
  11. doushisiRoomXiaoJuChaPaiView.super.onEnter(self)
  12. end
  13. function doushisiRoomXiaoJuChaPaiView:loadUI()
  14. local ui = loadUI("zp_doushisi/res/ui/ui_fangjian/doushisi_ui_xiaoju_chapai.ui");
  15. self.ui = ui;
  16. self:addChild(ui);
  17. end
  18. function doushisiRoomXiaoJuChaPaiView:liangShouPai(isRecontect)
  19. --胡牌类型
  20. local huType = ZPDef.ReconnectHuType.NO_HU
  21. --房间信息
  22. local roomInfo = app.room.roomInfo
  23. --正常结束取值
  24. local tt = roomInfo.playList
  25. --重连取值
  26. if isRecontect then
  27. tt = roomInfo.arrayTableInfo
  28. end
  29. local enterCardHu = roomInfo.isEnterCardHu
  30. if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL then
  31. --胡的牌
  32. local huCard = roomInfo.huCard
  33. --出牌者ID或者点炮的ID,自摸这个是nil,有人点炮这个是有值的
  34. local showViewId = nil
  35. local dianPaoViewId = app.room:getViewIdByUserId(roomInfo.dianPaoUserId)
  36. --重连
  37. if isRecontect then
  38. showViewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
  39. else
  40. --小局结算
  41. showViewId = dianPaoViewId
  42. end
  43. for k,v in pairs(roomInfo.hupaiInfo) do
  44. local nUserId = v.huPaiUid
  45. local viewId = app.room:getViewIdByUserId(nUserId)
  46. if isRecontect and roomInfo.isZiMoHu and roomInfo.isZiMoHu ~= 1 and roomInfo.isQiangBaHu and roomInfo.isQiangBaHu ~= 1 then
  47. if self.showHuCardCallBack then
  48. self.showHuCardCallBack(showViewId,huCard)
  49. end
  50. end
  51. --赢家手牌
  52. local cardList = roomInfo.memberList[nUserId].cardList
  53. if roomInfo.isZiMoHu and roomInfo.isZiMoHu ~= 1 then
  54. local isFind = false
  55. local lens = table.nums(cardList)
  56. local huCard = roomInfo.huCard
  57. if table.nums(cardList) > 0 then
  58. for i = 1,lens do
  59. if cardList[i] == huCard then
  60. table.remove(cardList,i)
  61. isFind = true
  62. break
  63. end
  64. if isFind then
  65. break
  66. end
  67. end
  68. end
  69. end
  70. end
  71. end
  72. for k,v in pairsByKeys(tt) do
  73. local myUserID = app.room:getMyUserId()
  74. local nUserId = v.nUserId
  75. if myUserID ~= nUserId then
  76. local cardList = roomInfo.memberList[nUserId].cardList
  77. logE("cardList:"..table.tostring(cardList))
  78. self:createHandCard(nUserId)
  79. end
  80. end
  81. app.room.roomInfo.huCardType = huType
  82. return huType
  83. end
  84. function doushisiRoomXiaoJuChaPaiView:showDiPai()
  85. end
  86. --初始化小局查牌界面亮手牌的位置
  87. function doushisiRoomXiaoJuChaPaiView:initLiangPaiPos()
  88. self.boxPosList1 = {}
  89. local weaveCardPos1 = self.ui.Items.Layout_LiangPai_1:getPosition()
  90. local tempY = 28
  91. local tempX = 34
  92. for i = 1, 16 do
  93. --矩形3
  94. local indexX = i
  95. local indexY = 1
  96. if i >= 7 and i < 13 then
  97. indexY = 2
  98. indexX = i - 6
  99. elseif i >= 13 then
  100. indexY = 3
  101. indexX = i - 12
  102. end
  103. self.boxPosList1[i] = cc.p(weaveCardPos1.x - tempX * (indexX - 1),weaveCardPos1.y - tempY * (indexY- 1))
  104. end
  105. self.boxPosList2 = {}
  106. local weaveCardPos2 = self.ui.Items.Layout_LiangPai_2:getPosition()
  107. for i = 1, 16 do
  108. --矩形3
  109. local indexX = i
  110. local indexY = 1
  111. if i >= 7 and i < 13 then
  112. indexY = 2
  113. indexX = i - 6
  114. elseif i >= 13 then
  115. indexY = 3
  116. indexX = i - 12
  117. end
  118. self.boxPosList2[i] = cc.p(weaveCardPos2.x - tempX * (indexX - 1),weaveCardPos2.y - tempY * (indexY- 1))
  119. end
  120. self.boxPosList3 = {}
  121. local weaveCardPos3 = self.ui.Items.Layout_LiangPai_3:getPosition()
  122. for i = 1, 16 do
  123. --矩形3
  124. local indexX = i
  125. local indexY = 1
  126. if i >= 7 and i < 13 then
  127. indexY = 2
  128. indexX = i - 6
  129. elseif i >= 13 then
  130. indexY = 3
  131. indexX = i - 12
  132. end
  133. self.boxPosList3[i] = cc.p(weaveCardPos3.x + tempX * (indexX - 1),weaveCardPos3.y - tempY * (indexY- 1))
  134. end
  135. end
  136. function doushisiRoomXiaoJuChaPaiView:createHandCard(nUserId)
  137. logE("====================changpaiRoomXiaoJuChaPaiView:createHandCard()===================");
  138. --[[ local cardList = app.room.roomInfo.memberList[nUserId].cardList
  139. --过滤手牌为空的情况
  140. if not cardList or table.nums(cardList) <= 0 then
  141. return
  142. end
  143. local viewId = app.room:getViewIdByUserId(nUserId)
  144. local handcardlist = {}
  145. for i = 1,self.lieShuMax do
  146. local value = cardList[i] or {}
  147. for k,v in pairs(value) do
  148. table.insert(handcardlist,v)
  149. end
  150. end
  151. --不管有无数据,默认创建10列数据
  152. if viewId == 1 then
  153. for k,v in pairs(handcardlist) do
  154. local changpai = ChangpaiCard:new(v,ZPDef.CardType.CARD_TYPE_QUIT,viewId,self.colorType)
  155. if self.colorType == ZPDef.ColorType.White then
  156. changpai:setScale(0.9)
  157. else
  158. changpai:setScale(0.7)
  159. end
  160. local pos = self.boxPosList1[k]
  161. changpai:setPosition(pos)
  162. self.ui.Items.Layout_HandCard:addChild(changpai,1)
  163. end
  164. elseif viewId == 2 then
  165. for k,v in pairs(handcardlist) do
  166. local changpai = ChangpaiCard:new(v,ZPDef.CardType.CARD_TYPE_QUIT,viewId,self.colorType)
  167. if self.colorType == ZPDef.ColorType.White then
  168. changpai:setScale(0.9)
  169. else
  170. changpai:setScale(0.7)
  171. end
  172. local pos = self.boxPosList2[k]
  173. changpai:setPosition(pos)
  174. self.ui.Items.Layout_HandCard:addChild(changpai,1)
  175. end
  176. elseif viewId == 3 then
  177. for k,v in pairs(handcardlist) do
  178. local changpai = ChangpaiCard:new(v,ZPDef.CardType.CARD_TYPE_QUIT,viewId,self.colorType)
  179. if self.colorType == ZPDef.ColorType.White then
  180. changpai:setScale(0.9)
  181. else
  182. changpai:setScale(0.7)
  183. end
  184. local pos = self.boxPosList3[k]
  185. changpai:setPosition(pos)
  186. self.ui.Items.Layout_HandCard:addChild(changpai,1)
  187. end
  188. end--]]
  189. end
  190. --判断列数是否是砍牌
  191. function doushisiRoomXiaoJuChaPaiView:getCurrentColIsKan(list)
  192. local isKan = false
  193. return isKan
  194. end
  195. function doushisiRoomXiaoJuChaPaiView:PlayHuangZhuangAni(bShowAni)
  196. local nodeDipai = self.ui.Items.Layout_XiaoJu_LiangPai
  197. --黄庄不显示结算,增加黄庄动画
  198. local tip = cc.ImageView:createNode();
  199. tip:setAnchorPoint(cc.p(0.5,0.5));
  200. tip:loadTextureFromPlist("zp_room_chapai_huangzhuang.png");
  201. tip:setPosition(cc.p(nodeDipai:getContentSize().width / 2,nodeDipai:getContentSize().height / 2+70))
  202. tip:setTag(1000)
  203. nodeDipai:addChild(tip);
  204. if bShowAni then
  205. tip:setScale(5.0)
  206. local seq = cc.Sequence:create(cc.ScaleTo:create(0.2,0.8),cc.ScaleTo:create(0.15,1.2),cc.ScaleTo:create(0.1,1))
  207. tip:runAction(seq)
  208. end
  209. end
  210. function doushisiRoomXiaoJuChaPaiView:clearView()
  211. self.ui.Items.Layout_HandCard:removeAllChildren()
  212. --移除黄庄
  213. self.ui.Items.Layout_XiaoJu_LiangPai:removeChildByTag(1000)
  214. end
  215. return doushisiRoomXiaoJuChaPaiView