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.

136 lines
4.2 KiB

  1. local PKDef = PKFramework.PKImport("pk_base.luaScript.PKDef")
  2. local PKFuc = PKFramework.PKImport("pk_base.luaScript.PKFunctions")
  3. local PKAnimationCompnent=PKFramework.PKImport("pk_base.luaScript.Views.Component.PKAnimationCompnent")
  4. local PKSound = PKFramework.PKImport("pk_base.luaScript.PKSound")
  5. local PKRoomView = PKFramework.PKFrameworkClassImprot("pk_base.luaScript.Views.Room.PKRoomView")
  6. local bzpRoomView = class("bzpRoomView", PKRoomView)
  7. function bzpRoomView:ctor()
  8. bzpRoomView.super.ctor(self)
  9. end
  10. function bzpRoomView:onEnter()
  11. bzpRoomView.super.onEnter(self)
  12. end
  13. function bzpRoomView:onExit()
  14. bzpRoomView.super.onExit(self)
  15. self:cleanCache() -- jxtd 记得验证是否要删除
  16. end
  17. -- 清理缓存,用于测试
  18. function bzpRoomView:cleanCache()
  19. local preload = package.loaded
  20. for k, v in pairs(package.loaded or {}) do
  21. local res1 = string.find( k, "pk_banzipao.luaScript") or 0
  22. if res1 > 0 then
  23. package.loaded[k] = nil
  24. end
  25. end
  26. end
  27. function bzpRoomView:initBaseNode()
  28. bzpRoomView.super.initBaseNode(self)
  29. if PKFuc.getIsForbidChat() then
  30. if self.toolView.chatView then
  31. self.toolView.chatView:setBtnFaceVisible(false)
  32. end
  33. end
  34. end
  35. function bzpRoomView:loadTextureCache()
  36. bzpRoomView.super.loadTextureCache(self)
  37. --
  38. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_Bzp.plist")
  39. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_GL.plist")
  40. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_GT.plist")
  41. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_QD.plist")
  42. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_SZ.plist")
  43. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_TP.plist")
  44. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_ZD.plist")
  45. loadSpriteFrameFile("pk_base/res/ui/zy_fangjian/ani/pkAni_BJ.plist")
  46. end
  47. function bzpRoomView:initGameButton()
  48. self.ui.Items.Layout_Touch:registerClick(function ()
  49. if not self.toolView.ui.Items.Button_Menu:isBright() then
  50. self.toolView:onClickMenu()
  51. end
  52. self:BanlanceAllCard()
  53. if app.room.roomInfo.nStatus == PKDef.ReconnectState.GAME_STATUS_PLAYING then
  54. if self.operationView:ChoiceViewIsVisible() then
  55. self.operationView:setOperatorPanelView(true,self.outCardOpType)
  56. end
  57. self.operationView:setChoiceCardView(false)
  58. end
  59. end)
  60. end
  61. -- 重写发牌动画
  62. function bzpRoomView:showGetCardAni(onEnd)
  63. local screenWidth = getWinSize().width;
  64. local max = table.nums(self.handCardItem)
  65. local function secondAction(idx)
  66. local index2 = 0;
  67. local idx = idx
  68. local j = idx
  69. -- for j = max,1,-1 do
  70. local card = self.handCardItem[j];
  71. local seq2 = cc.Sequence:create(cc.DelayTime:create(0.04),
  72. cc.CallFunc:create(function ()
  73. PKFuc.logCard(card.value);
  74. local fileName = PKFuc.getPKCardImgByValue(card.value);
  75. card:loadTextureFromPlist(fileName);
  76. end),
  77. cc.CallFunc:create(function ()
  78. index2 = index2 + 1;
  79. if idx == max then
  80. logD("only do once!")
  81. --注册点击
  82. self:registerCardTouch();
  83. --排序
  84. self:RankCard();
  85. if app.room.roomInfo.playerList then
  86. for k,v in pairs(app.room.roomInfo.playerList) do
  87. local nUserID = v.nUserId
  88. local viewId = app.room:getViewIdByUserId(nUserID)
  89. --显示剩余牌
  90. self.PlayerView:setLeftCardNum(viewId,true,self.leftCardNum[viewId])
  91. end
  92. end
  93. if onEnd then
  94. onEnd();
  95. end
  96. end
  97. end)
  98. )
  99. card:getParent():runAction(seq2);
  100. -- end
  101. end
  102. local index = 0;
  103. for i = 1, max do
  104. local card = self.handCardItem[i];
  105. card:getParent():setOpacity(0);
  106. local srcPos = card:getParent():getPosition();
  107. local fileName = PKFuc.getPKCardImgByValue(0xff);
  108. card:loadTextureFromPlist(fileName);
  109. card:getParent():setPositionX(screenWidth + 300);
  110. local spawn = cc.Spawn:create(cc.FadeIn:create(0.13), cc.MoveTo:create(0.07, srcPos));
  111. local seq = cc.Sequence:create(cc.DelayTime:create(0.025 * i), cc.CallFunc:create(function ()
  112. PKSound.PlayGetCard()
  113. end),spawn,cc.CallFunc:create(function ()
  114. index = index + 1
  115. -- if index == max then
  116. logD("first action only do once!")
  117. secondAction(i);
  118. -- end
  119. end));
  120. card:getParent():runAction(seq);
  121. end
  122. end
  123. return bzpRoomView