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.

166 lines
7.7 KiB

  1. local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
  2. local LayerTeamRule = class("LayerTeamRule", BaseLayer)
  3. function LayerTeamRule.createWithData(__node, __zorder)
  4. local layer = LayerTeamRule.new()
  5. layer.m_parent = __node
  6. __node:addChild(layer, __zorder)
  7. return layer
  8. end
  9. function LayerTeamRule:myShow()
  10. -- self:addListener(true)
  11. self:initUI()
  12. end
  13. function LayerTeamRule:myClose()
  14. end
  15. function LayerTeamRule:initUI()
  16. self.imgPath = {
  17. "res/ModuleEapSdk/eapsdk_public_back_bg1.png",
  18. "res/ModuleEapSdk/eapsdk_public_back_bg2.png",
  19. "res/ModuleEapSdk/eapsdk_public_back_bg3.png",
  20. "res/ModuleEapSdk/eapsdk_bt_xb_sp.png",
  21. "res/ModuleEapSdk/eapsdk_wj_icon_decor.png",
  22. "res/ModuleEapSdk/eapsdk_wj_btn_back.png",
  23. "res/ModuleEapSdk/eapsdk_button_dx.png",
  24. "res/ModuleEapSdk/eapsdk_bg_bj_sp1.png",
  25. "res/ModuleEapSdk/eapsdk_btn_rule1.png",
  26. "res/ModuleEapSdk/eapsdk_btn_rule2.png",
  27. "res/ModuleEapSdk/eapsdk_btn_award1.png",
  28. "res/ModuleEapSdk/eapsdk_btn_award2.png",
  29. }
  30. local fix_x = display.width
  31. local fix_y = display.cy
  32. local imgBack2 = G_EapAbbreviation.createImageView(self.imgPath[2], self, cc.p(fix_x-10, fix_y+40), true, 2, 4101, cc.p(1, 0.5))
  33. imgBack2:setSize(cc.size(530, 500))
  34. self.imgBack2 = imgBack2
  35. local imgArrow1 = G_EapAbbreviation.createImageView(self.imgPath[5], imgBack2, cc.p(132, 468), false)
  36. local imgArrow2 = G_EapAbbreviation.createImageView(self.imgPath[4], imgBack2, cc.p(398, 468), false)
  37. imgArrow1:setScale(0.585)
  38. imgArrow2:setScale(0.585)
  39. local title = "规则和奖励"
  40. G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(265, 468), title, 28, cc.c3b(0xc8, 0xa8, 0x88), true)
  41. self.btnBack = ccui.Button:create(self.imgPath[6])
  42. self.btnBack:setPosition(cc.p(30, 470))
  43. imgBack2:addChild(self.btnBack)
  44. addButtonListener(self.btnBack, function()
  45. print("LayerTeamRule btnBack clicked === ")
  46. if G_EapSdkMgr.m_isMatching then
  47. self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM)
  48. else
  49. self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM_END)
  50. end
  51. end)
  52. self.node_rule = cc.Node:create()
  53. self.node_award = cc.Node:create()
  54. self.node_rule:setPosition(cc.p(265, 400))
  55. self.node_award:setPosition(cc.p(265, 400))
  56. imgBack2:addChild(self.node_award)
  57. imgBack2:addChild(self.node_rule)
  58. local btnMenus = G_EapAbbreviation.createMenu(imgBack2, 1, 1200, cc.p(265, 428))
  59. local params1 = {self.imgPath[9], self.imgPath[10]}
  60. self.btnRule = G_EapAbbreviation.createItemAll(params1, btnMenus, cc.p(-137.5, 0), function()
  61. print("self.btnRule clicked ========= ")
  62. self.btnRule:setEnabled(false)
  63. self.btnAward:setEnabled(true)
  64. self:showNode(1)
  65. end)
  66. local params2 = {self.imgPath[11], self.imgPath[12]}
  67. self.btnAward = G_EapAbbreviation.createItemAll(params2, btnMenus, cc.p(137.5, 0), function()
  68. print("self.btnAward clicked ========= ")
  69. self.btnRule:setEnabled(true)
  70. self.btnAward:setEnabled(false)
  71. self:showNode(2)
  72. end)
  73. self.btnRule:setEnabled(false)
  74. self.btnAward:setEnabled(true)
  75. self:showNode(1)
  76. self:refreshRuleInfo()
  77. end
  78. function LayerTeamRule:showNode(__index)
  79. if __index == 1 then
  80. self.node_rule:setVisible(true)
  81. self.node_award:setVisible(false)
  82. elseif __index == 2 then
  83. self.node_rule:setVisible(false)
  84. self.node_award:setVisible(true)
  85. end
  86. end
  87. function LayerTeamRule:refreshRuleInfo(__datas)
  88. __datas = __datas or {["result"]={
  89. ["prizeRegulars"]={
  90. {["top"]="1",["prizeList"]={"SCORE","SPORT"},["prizeMap"]={["regular"]="10积分+5竞技分"},["startNo"]="1",["topName"]="第一名",["endNo"]="1"},
  91. {["top"]="2",["prizeList"]={"SCORE"},["prizeMap"]={["regular"]="5积分"},["startNo"]="2",["topName"]="第二名",["endNo"]="3"},
  92. {["top"]="3",["prizeList"]={"SCORE"},["prizeMap"]={["regular"]="1积分"},["startNo"]="4",["topName"]="第三名",["endNo"]="5"},
  93. },
  94. -- ["desc"]="<p style=\"white-space: normal;\"><span style=\"color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Arial; text-indent: 32px; background-color: rgb(255, 255, 255);\">2021 CEST四川麻将赛季锦标赛,分为积分赛、海选赛、决赛三个阶段。积分赛规则如下:</span></p><p style=\"white-space: normal;\"><span style=\"color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Arial; text-indent: 32px; background-color: rgb(255, 255, 255);\">1.积分赛采用线上赛形式,玩家只需对局指定游戏即算参赛;</span></p><p style=\"white-space: normal;\"><span style=\"color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Arial; text-indent: 32px; background-color: rgb(255, 255, 255);\">2.每局小局结算分均会按照CEST专业算法进行换算得出对应排名积分;</span></p><p style=\"white-space: normal;\"><span style=\"color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Arial; text-indent: 32px; background-color: rgb(255, 255, 255);\">3.排名积分每3小时更新1次。</span></p><p><br/></p>"},
  95. ["desc"]={"1.凡在《第一电竞app》内创建的战队均可参与到战队选拔赛中;",
  96. "2.比赛期间内对局的xx麻将均统计进赛事积分中;",
  97. "3.统计规则为:每小局结算分均会按照CEST专业算法进行换算得出对应排名积分。",
  98. "4.排名积分每3小时更新一次。"},
  99. ["retcode"]=0,
  100. ["success"]=true}
  101. }
  102. --规则
  103. local resStr = ""
  104. for i=1, #__datas.result.desc do
  105. resStr = resStr..__datas.result.desc[i].."\n\n"
  106. end
  107. local sysFont = G_EapAbbreviation.getSystemFont()
  108. local tmpLabel = cc.Label:createWithSystemFont(resStr, sysFont, 22)
  109. tmpLabel:setColor(cc.c3b(0x1e, 0x23, 0x36))
  110. tmpLabel:setWidth(470)
  111. tmpLabel:setLineBreakWithoutSpace(true) --自动换行
  112. tmpLabel:updateContent()
  113. tmpLabel:setAnchorPoint(cc.p(0.5, 1))
  114. tmpLabel:setPosition(cc.p(0, 0))
  115. self.node_rule:addChild(tmpLabel)
  116. --奖励
  117. local imgBack_y = 0
  118. self.imgBack3 = G_EapAbbreviation.createImageView(self.imgPath[8], self.node_award, cc.p(0, imgBack_y), true, 2, 2102, cc.p(0.5, 1))
  119. self.imgBack3:setSize(cc.size(500, 50))
  120. local imgLine = G_EapAbbreviation.createImageView(self.imgPath[3], self.imgBack3, cc.p(166.7, 25))
  121. imgLine:setScaleX(0.04)
  122. -- imgLine:setScaleY(0.5)
  123. local title1 = "名次"
  124. G_EapAbbreviation.createSystemLabel(self.imgBack3, cc.p(83.3, 25), title1, 25, nil, true)
  125. local title2 = "奖励"
  126. G_EapAbbreviation.createSystemLabel(self.imgBack3, cc.p(2*166.7, 25), title2, 25, nil, true)
  127. local list_y = imgBack_y - 50
  128. local awardsDes = __datas.result.prizeRegulars
  129. for i=1, #awardsDes do
  130. local itemNode = ccui.Layout:create()
  131. itemNode:setAnchorPoint(cc.p(0.5, 1))
  132. itemNode:setSize(cc.size(530, 50))
  133. itemNode:setPosition(cc.p(0, list_y-(i-1)*50))
  134. self.node_award:addChild(itemNode)
  135. local title1 = "第"..awardsDes[i].startNo.."名"
  136. if awardsDes[i].startNo ~= awardsDes[i].endNo then
  137. title1 = "第"..awardsDes[i].startNo.."-"..awardsDes[i].endNo.."名"
  138. end
  139. G_EapAbbreviation.createSystemLabel(itemNode, cc.p(83.3+20, 25), title1, 25, cc.c3b(0x1e, 0x23, 0x36))
  140. local title2 = awardsDes[i].prizeMap.regular
  141. G_EapAbbreviation.createSystemLabel(itemNode, cc.p(2*166.7+20, 25), title2, 25, cc.c3b(0x1e, 0x23, 0x36))
  142. end
  143. end
  144. return LayerTeamRule