KLShapeShiftCardItem.lua 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. ---@class KLShapeShiftCardItem:UIKmlLuaPanelBase
  2. ---@field view KLShapeShiftCardItemView
  3. local KLShapeShiftCardItem = class(UIKmlLuaPanelBase)
  4. local this = KLShapeShiftCardItem
  5. ---创建时调用一次
  6. function this:Init()
  7. if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis then
  8. GUI:setVisible(self.view.btn_card_func, true)
  9. GUI:Button_setTitleText(self.view.btn_card_func, "合成")
  10. elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak then
  11. GUI:setVisible(self.view.btn_card_func, true)
  12. GUI:Button_setTitleText(self.view.btn_card_func, "突破")
  13. else
  14. GUI:setVisible(self.view.btn_card_func, false)
  15. end
  16. end
  17. ---注册UI事件和服务器消息
  18. function this:RegistEvents()
  19. GUI:AddOnClickEvent(self.view.img_empty_bg, self, self.ClickSelf)
  20. GUI:AddOnClickEvent(self.view.img_card_bg, self, self.ClickSelf)
  21. GUI:AddOnClickEvent(self.view.btn_card_func, self, self.ClickUpgradeFunc)
  22. end
  23. ---界面显示时调用一次
  24. function this:Show()
  25. end
  26. ---创建或者刷新界面数据时调用
  27. function this:Refresh()
  28. --GUI:setContentSize(self.view.KLShapeShiftCardItem, 164, 255)
  29. end
  30. ---在镶嵌-上
  31. ---@param data EquipPartCardInfo
  32. function this:RefreshUnInlayItem(data, index, part, partInfo)
  33. if data.unlock then
  34. ---解锁
  35. if data.card and data.card.cfgid > 0 then
  36. ---有卡
  37. GUI:setVisible(self.view.panel_empty, false)
  38. GUI:setVisible(self.view.panel_card, true)
  39. self:RefreshCardInfo(data.card.cfgid)
  40. GUI:setVisible(self.view.item_equip_redPoint, false)
  41. else
  42. ---无卡
  43. GUI:setVisible(self.view.panel_card, false)
  44. GUI:setVisible(self.view.panel_empty, true)
  45. GUI:setVisible(self.view.img_empty_lock, false)
  46. GUI:setVisible(self.view.img_empty_add, true)
  47. GUI:setVisible(self.view.item_equip_redPoint, InfoManager.shapeShiftCardInfo:GetPartHaveCardCheck(part))
  48. end
  49. else
  50. ---未解锁
  51. GUI:setVisible(self.view.panel_empty, true)
  52. GUI:setVisible(self.view.panel_card, false)
  53. GUI:setVisible(self.view.img_empty_lock, true)
  54. GUI:setVisible(self.view.img_empty_add, false)
  55. ---@type cfg_card_inlay_column
  56. local tbl = SL:GetConfig("cfg_card_inlay", part)
  57. local rank = InfoManager.shapeShiftCardInfo:GetEquipRankByPart(part)
  58. for _, v in ipairs(tbl.unlockParameter) do
  59. if index == v[1] then
  60. GUI:setVisible(self.view.item_equip_redPoint, rank >= v[2])
  61. end
  62. end
  63. --for i, v in pairs(tbl.unlockNormal) do
  64. -- if v[1] == index then
  65. -- if SL:GetBagItemCount(v[2]) >= v[3] then
  66. -- GUI:setVisible(self.view.item_equip_redPoint, true)
  67. -- else
  68. -- GUI:setVisible(self.view.item_equip_redPoint, false)
  69. -- end
  70. -- end
  71. --end
  72. end
  73. GUI:setPosition(self.view.item_equip_redPoint, 5, 5)
  74. self.partInfo = partInfo
  75. self.cardInfo = data
  76. self.index = index
  77. self.part = part
  78. end
  79. ---在(镶嵌-下)牌库
  80. function this:RefreshBagItem(card, cardTblIndex)
  81. GUI:setVisible(self.view.panel_empty, false)
  82. GUI:setVisible(self.view.panel_card, true)
  83. self:RefreshCardInfo(card.cfgid)
  84. self.isSelect = card.select
  85. GUI:setVisible(self.view.img_select, self.isSelect)
  86. self.cardTblIndex = cardTblIndex
  87. GUI:setVisible(self.view.item_equip_redPoint, false)
  88. self.cardInfo = card
  89. end
  90. function this:RefreshAwardItem(card)
  91. GUI:setVisible(self.view.panel_empty, false)
  92. GUI:setVisible(self.view.panel_card, true)
  93. self:RefreshCardInfo(card.cfgid)
  94. self.cardInfo = card
  95. end
  96. ---在合成
  97. function this:RefreshSynthesis(card)
  98. GUI:setVisible(self.view.panel_empty, false)
  99. GUI:setVisible(self.view.panel_card, true)
  100. if self.args.type == E_ShapeShiftCardFuncType.Synthesis then
  101. self.isSelect = card.select
  102. GUI:setVisible(self.view.img_select, self.isSelect)
  103. self:RefreshCardInfo(card.cfgid)
  104. elseif self.args.type == E_ShapeShiftCardFuncType.ExSynthesis then
  105. self:RefreshCardInfo(card.cfgid, #card.count)
  106. elseif self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then
  107. if not card then
  108. GUI:setVisible(self.view.panel_card, false)
  109. GUI:setVisible(self.view.panel_empty, true)
  110. GUI:setVisible(self.view.img_empty_lock, false)
  111. GUI:setVisible(self.view.img_empty_add, false)
  112. else
  113. self:RefreshCardInfo(card.cfgid)
  114. end
  115. end
  116. self.cardInfo = card
  117. end
  118. ---在突破
  119. function this:RefreshBreak(card)
  120. GUI:setVisible(self.view.panel_empty, false)
  121. GUI:setVisible(self.view.panel_card, true)
  122. if self.args.type == E_ShapeShiftCardFuncType.Break then
  123. self.isSelect = card.select
  124. GUI:setVisible(self.view.img_select, self.isSelect)
  125. self:RefreshCardInfo(card.cfgid)
  126. elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak then
  127. self:RefreshCardInfo(card.cfgid, #card.count)
  128. elseif self.args.type == E_ShapeShiftCardFuncType.UnBreak then
  129. if not card then
  130. GUI:setVisible(self.view.panel_card, false)
  131. GUI:setVisible(self.view.panel_empty, true)
  132. GUI:setVisible(self.view.img_empty_lock, false)
  133. GUI:setVisible(self.view.img_empty_add, false)
  134. else
  135. self:RefreshCardInfo(card.cfgid)
  136. end
  137. end
  138. self.cardInfo = card
  139. end
  140. function this:RefreshCardInfo(id, count)
  141. ---@type cfg_card_shapeshift_column
  142. local tbl = SL:GetConfig("cfg_card_shapeshift", id)
  143. ---@type cfg_item_column
  144. local item_tbl = SL:GetConfig("cfg_item", id)
  145. GUI:Image_loadTexture(self.view.img_card_bg, "card_quality_" .. tbl.quality, "Atlas/KLShapeShiftCard.spriteatlas")
  146. GUI:Image_loadTexture(self.view.img_card_icon, tbl.img, "Atlas/KLShapeShiftCard.spriteatlas")
  147. if #tbl.position > 0 then
  148. GUI:setPosition(self.view.img_card_icon, tbl.position[1], tbl.position[2])
  149. else
  150. GUI:setPosition(self.view.img_card_icon, 0, 0)
  151. end
  152. if tbl.scale ~= 0 then
  153. GUI:setScale(self.view.img_card_icon, tbl.scale)
  154. else
  155. GUI:setScale(self.view.img_card_icon, 1)
  156. end
  157. GUI:Image_loadTexture(self.view.img_card_level, "num_quality_" .. tbl.quality .. "_" .. tbl.level, "Atlas/KLShapeShiftCard.spriteatlas")
  158. GUI:Text_setString(self.view.text_card_name, item_tbl.name)
  159. GUI:Text_setTextColor(self.view.text_card_name, tostring(item_tbl.color))
  160. GUI:setVisible(self.view.text_card_count, false)
  161. GUI:setPosition(self.view.item_equip_redPoint, 5, 5)
  162. local upgradeCount
  163. if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis or self.args.type == E_ShapeShiftCardFuncType.Synthesis or self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then
  164. upgradeCount = tbl.upAmount
  165. elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak or self.args.type == E_ShapeShiftCardFuncType.Break or self.args.type == E_ShapeShiftCardFuncType.UnBreak then
  166. ---@type cfg_card_breakthrough_column
  167. local break_tbl = SL:GetConfig("cfg_card_breakthrough", id)
  168. upgradeCount = break_tbl.expend
  169. end
  170. if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis or self.args.type == E_ShapeShiftCardFuncType.ExBreak then
  171. if count then
  172. self.canUpgrade = false
  173. if upgradeCount > 0 then
  174. if count >= upgradeCount then
  175. self.canUpgrade = true
  176. GUI:Text_setString(self.view.text_card_count, "<color=#1ADD1F>" .. count .. "</color>/" .. upgradeCount)
  177. GUI:setVisible(self.view.item_equip_redPoint, true)
  178. GUI:setPosition(self.view.item_equip_redPoint, 0, -182)
  179. else
  180. GUI:Text_setString(self.view.text_card_count, "<color=#FF2323>" .. count .. "</color>/" .. upgradeCount)
  181. GUI:setVisible(self.view.item_equip_redPoint, false)
  182. end
  183. GUI:setVisible(self.view.text_card_count, true)
  184. end
  185. end
  186. end
  187. if self.args.type == E_ShapeShiftCardFuncType.Synthesis or self.args.type == E_ShapeShiftCardFuncType.Break then
  188. local cardCount = InfoManager.shapeShiftCardInfo:GetBagCardCountByCfgId(id)
  189. if cardCount >= upgradeCount then
  190. GUI:setVisible(self.view.item_equip_redPoint, true)
  191. else
  192. GUI:setVisible(self.view.item_equip_redPoint, false)
  193. end
  194. end
  195. self.cardId = id
  196. end
  197. function this:ClickSelf()
  198. if not self.cardInfo then
  199. return
  200. end
  201. ---@type KLShapeShiftCardInlayPanel
  202. local ui = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardInlay/KLShapeShiftCardInlayPanel")
  203. if self.args.type == E_ShapeShiftCardFuncType.UnInlay then
  204. if self.cardInfo.unlock then
  205. ---解锁
  206. if self.cardInfo.card and self.cardInfo.card.cfgid > 0 then
  207. ---打开卡牌tips,卸下卡牌
  208. GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardTips/KLShapeShiftCardTipsPanel", nil, nil, { cardInfo = self.cardInfo.card, part = self.part, index = self.index, type = self.args.type })
  209. if ui then
  210. ui:RefreshSelectIndex(self.index)
  211. end
  212. else
  213. ---打开牌库
  214. if ui then
  215. ui:OpenCardHouse(self.index)
  216. return
  217. end
  218. end
  219. else
  220. local _, isNone = InfoManager.shapeShiftCardInfo:GetEquipRankByPart(self.part)
  221. if not self.partInfo[self.index - 1] or self.partInfo[self.index - 1].unlock and not isNone then
  222. GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardUnLock/KLShapeShiftCardUnLockPanel", nil, nil, { index = self.index, part = self.part, info = self.cardInfo })
  223. else
  224. SL:TipMessage(SL:GetConfig('cfg_string', 20001).text, 1, NoticeType.NoticeMid)
  225. end
  226. end
  227. if ui then
  228. ui:CloseCardHouse()
  229. end
  230. else
  231. if self.args.type == E_ShapeShiftCardFuncType.House then
  232. ---@type KLShapeShiftCardHousePanel
  233. local houseUI = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardHouse/KLShapeShiftCardHousePanel")
  234. if houseUI then
  235. if houseUI.recoveryIsShow then
  236. self.isSelect = not self.isSelect
  237. houseUI:SetRecoveryInfo(self.cardInfo, self.isSelect, self.cardTblIndex)
  238. GUI:setVisible(self.view.img_select, self.isSelect)
  239. return
  240. end
  241. end
  242. end
  243. --if self.args.type == E_ShapeShiftCardFuncType.Synthesis then
  244. -- ---@type KLShapeShiftCardSynthesisPanel
  245. -- local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardSynthesis/KLShapeShiftCardSynthesisPanel")
  246. -- if panel then
  247. -- if panel.synthesisIsShow then
  248. -- if not self.isSelect then
  249. -- local result = panel:SetSynthesisInfo(self.cardInfo, true)
  250. -- if result then
  251. -- SL:TipMessage( SL:GetConfig('cfg_string',20007).text, 1, NoticeType.NoticeMid ) --"卡牌数量不足"
  252. -- end
  253. -- else
  254. -- panel:SetSynthesisInfo(self.cardInfo, false)
  255. -- end
  256. -- return
  257. -- end
  258. -- end
  259. --end
  260. --if self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then
  261. -- if self.cardInfo then
  262. -- ---@type KLShapeShiftCardSynthesisPanel
  263. -- local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardSynthesis/KLShapeShiftCardSynthesisPanel")
  264. -- if panel then
  265. -- if panel.synthesisIsShow then
  266. -- panel:SetSynthesisInfo(self.cardInfo, false)
  267. -- return
  268. -- end
  269. -- end
  270. -- else
  271. -- return
  272. -- end
  273. --end
  274. local partValue, indexValue
  275. if ui then
  276. partValue = ui.part
  277. indexValue = ui.selectIndex
  278. end
  279. GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardTips/KLShapeShiftCardTipsPanel", _, _, { cardInfo = self.cardInfo, type = self.args.type, index = indexValue, part = partValue, select = self.isSelect })
  280. end
  281. end
  282. function this:ClickUpgradeFunc()
  283. local stringId, msgId
  284. if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis or self.args.type == E_ShapeShiftCardFuncType.ExBreak then
  285. local upgradeCount
  286. if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis then
  287. upgradeCount = self.cardInfo.tbl.upAmount
  288. stringId = 20006
  289. msgId = LuaMessageIdToSever.REQ_TRANSFER_CARD_SYNTHESIS
  290. elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak then
  291. upgradeCount = self.cardInfo.breakTbl.expend
  292. stringId = 20008
  293. msgId = LuaMessageIdToSever.REQ_BREAKTHROUGH_CARD
  294. end
  295. if self.canUpgrade then
  296. SL:CommonTipsMessage({ stringTblID = stringId, ui = self, callback = function()
  297. local card = {}
  298. local mainCard = self.cardInfo.count[1]
  299. for i = 2, upgradeCount do
  300. card[i - 1] = self.cardInfo.count[i]
  301. end
  302. SL:SendLuaNetMsg(msgId, { mainCard, card })
  303. end })
  304. else
  305. SL:TipMessage(SL:GetConfig('cfg_string', 20004).text, 1, NoticeType.NoticeMid) --"卡牌数量不足"
  306. end
  307. end
  308. end
  309. function this:ShowSelectShow(id, isShow)
  310. if self.cardInfo and id == self.cardInfo.id then
  311. GUI:setVisible(self.view.img_select, isShow)
  312. self.isSelect = isShow
  313. return true
  314. end
  315. return false
  316. end
  317. function this:Close()
  318. end
  319. return this