From 8b0a3dd24a2954bb87866102a591d15a5da6b6e1 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Tue, 6 Jun 2023 10:16:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/global/global_const.lua | 1 + lua/app/ui/shop/cell/beginner_sell_cell.lua | 2 +- lua/app/ui/shop/cell/chapter_cell.lua | 2 +- lua/app/ui/shop/cell/coin_sell_cell.lua | 2 +- lua/app/ui/shop/cell/gift_reward_cell.lua | 48 +++++++++++++++++++ .../ui/shop/cell/gift_reward_cell.lua.meta | 10 ++++ lua/app/ui/shop/cell/grow_cell.lua | 2 +- lua/app/ui/shop/cell/level_cell.lua | 2 +- 8 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 lua/app/ui/shop/cell/gift_reward_cell.lua create mode 100644 lua/app/ui/shop/cell/gift_reward_cell.lua.meta diff --git a/lua/app/global/global_const.lua b/lua/app/global/global_const.lua index 2dd53259..0039d624 100644 --- a/lua/app/global/global_const.lua +++ b/lua/app/global/global_const.lua @@ -173,6 +173,7 @@ GConst.TYPEOF_LUA_CLASS = { LARGE_HERO_CELL = "app/ui/common/cell/large_hero_cell", POP_HERO_CELL = "app/ui/shop/cell/pop_hero_cell", POP_REWARD_CELL = "app/ui/shop/cell/pop_reward_cell", + GIFT_REWARD_CELL = "app/ui/shop/cell/gift_reward_cell", } GConst.ATLAS_PATH = { diff --git a/lua/app/ui/shop/cell/beginner_sell_cell.lua b/lua/app/ui/shop/cell/beginner_sell_cell.lua index 0c1c9754..aaca1ea4 100644 --- a/lua/app/ui/shop/cell/beginner_sell_cell.lua +++ b/lua/app/ui/shop/cell/beginner_sell_cell.lua @@ -22,7 +22,7 @@ function BeginnerSellCell:init() if not self.rewardCellList then self.rewardCellList = {} for i = 1, MAX_REWARD_COUNT do - self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL) + self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.GIFT_REWARD_CELL) end end diff --git a/lua/app/ui/shop/cell/chapter_cell.lua b/lua/app/ui/shop/cell/chapter_cell.lua index 88671895..c6e7976f 100644 --- a/lua/app/ui/shop/cell/chapter_cell.lua +++ b/lua/app/ui/shop/cell/chapter_cell.lua @@ -23,7 +23,7 @@ function ChapterCell:init() if not self.rewardCellList then self.rewardCellList = {} for i = 1, MAX_REWARD_COUNT do - self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL) + self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.GIFT_REWARD_CELL) end end diff --git a/lua/app/ui/shop/cell/coin_sell_cell.lua b/lua/app/ui/shop/cell/coin_sell_cell.lua index 9719e7b2..a73ec723 100644 --- a/lua/app/ui/shop/cell/coin_sell_cell.lua +++ b/lua/app/ui/shop/cell/coin_sell_cell.lua @@ -22,7 +22,7 @@ function CoinSellCell:init() if not self.rewardCellList then self.rewardCellList = {} for i = 1, MAX_REWARD_COUNT do - self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL) + self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.GIFT_REWARD_CELL) end end self.priceText = uiMap["gift_cell.bg.price"] diff --git a/lua/app/ui/shop/cell/gift_reward_cell.lua b/lua/app/ui/shop/cell/gift_reward_cell.lua new file mode 100644 index 00000000..10533c18 --- /dev/null +++ b/lua/app/ui/shop/cell/gift_reward_cell.lua @@ -0,0 +1,48 @@ +local GiftRewardCell = class("GiftRewardCell", BaseCell) + +function GiftRewardCell:init() + local uiMap = self.baseObject:genAllChildren() + self.bg = uiMap["gift_reward_cell.bg"] + self.icon = uiMap["gift_reward_cell.icon"] + self.fragmenImg = uiMap["gift_reward_cell.fragment"] + self.numTx = uiMap["gift_reward_cell.num"] + + self.baseObject:addClickListener(function() + if self.clickCallback then + self.clickCallback() + end + end) +end + +function GiftRewardCell:refreshByConfig(reward) + + Logger.logHighlight("refreshByConfig") + Logger.printTable(reward) + + local id = reward.id + local num = reward.num + local heroCfgInfo = ConfigManager:getConfig("hero")[id] + if heroCfgInfo then + local qlt = heroCfgInfo.qlt + self.bg:setSprite(GConst.ATLAS_PATH.SHOP, "shop_gift_bg_" .. qlt) + self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, tostring(heroCfgInfo.icon)) + self.fragmenImg:setVisible(true) + self.numTx:setText("X" .. tostring(num)) + else + local itemCfgInfo = ConfigManager:getConfig("item")[id] + self.bg:setSprite(GConst.ATLAS_PATH.SHOP, "shop_gift_bg") + self.icon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, tostring(itemCfgInfo.icon)) + self.fragmenImg:setVisible(false) + self.numTx:setText(num) + end +end + +function GiftRewardCell:addClickListener(callback) + self.clickCallback = callback +end + +function GiftRewardCell:setVisible(visible, scale) + self.baseObject:setVisible(visible, scale) +end + +return GiftRewardCell diff --git a/lua/app/ui/shop/cell/gift_reward_cell.lua.meta b/lua/app/ui/shop/cell/gift_reward_cell.lua.meta new file mode 100644 index 00000000..e9864d51 --- /dev/null +++ b/lua/app/ui/shop/cell/gift_reward_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 88089f781c49b0c4d8a41180459d2f3e +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/shop/cell/grow_cell.lua b/lua/app/ui/shop/cell/grow_cell.lua index 7581608c..f5daad70 100644 --- a/lua/app/ui/shop/cell/grow_cell.lua +++ b/lua/app/ui/shop/cell/grow_cell.lua @@ -21,7 +21,7 @@ function GrowCell:init() if not self.rewardCellList then self.rewardCellList = {} for i = 1, MAX_REWARD_COUNT do - self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL) + self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.GIFT_REWARD_CELL) end end diff --git a/lua/app/ui/shop/cell/level_cell.lua b/lua/app/ui/shop/cell/level_cell.lua index fe10f539..75f5d2b3 100644 --- a/lua/app/ui/shop/cell/level_cell.lua +++ b/lua/app/ui/shop/cell/level_cell.lua @@ -21,7 +21,7 @@ function LevelCell:init() if not self.rewardCellList then self.rewardCellList = {} for i = 1, MAX_REWARD_COUNT do - self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL) + self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.GIFT_REWARD_CELL) end end