From 3baef020b0f8bb189c9a635b4e1b2f3978050bd7 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Tue, 30 May 2023 19:34:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E9=A6=96=E5=85=85?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/module_manager.lua | 2 + lua/app/global/global_const.lua | 2 + lua/app/ui/shop/cell/pop_hero_cell.lua | 65 +++++++++++++++++++ lua/app/ui/shop/cell/pop_hero_cell.lua.meta | 10 +++ lua/app/ui/shop/cell/pop_reward_cell.lua | 50 ++++++++++++++ lua/app/ui/shop/cell/pop_reward_cell.lua.meta | 10 +++ lua/app/ui/shop/first_recharge_pop_ui.lua | 31 +++------ lua/app/userdata/shop/shop_data.lua | 23 ++++++- 8 files changed, 169 insertions(+), 24 deletions(-) create mode 100644 lua/app/ui/shop/cell/pop_hero_cell.lua create mode 100644 lua/app/ui/shop/cell/pop_hero_cell.lua.meta create mode 100644 lua/app/ui/shop/cell/pop_reward_cell.lua create mode 100644 lua/app/ui/shop/cell/pop_reward_cell.lua.meta diff --git a/lua/app/common/module_manager.lua b/lua/app/common/module_manager.lua index a85a2788..5e590921 100644 --- a/lua/app/common/module_manager.lua +++ b/lua/app/common/module_manager.lua @@ -65,6 +65,8 @@ ModuleManager.MODULE_KEY = { DAILY_CHALLENGE = "daily_challenge", -- 每日挑战 FUND = "act_level_gift", -- 成长基金 ACT_GIFT_SHOW_OPEN = "act_gift_show_open", -- 弹窗礼包通用开启条件 + FIRST_RECHARGE = "first_charge", -- 首充礼包 + BEGINNER_GIFT = "new_player_gift", -- 新手礼包 } local _moduleMgrs = {} diff --git a/lua/app/global/global_const.lua b/lua/app/global/global_const.lua index b25e8a54..ae61e007 100644 --- a/lua/app/global/global_const.lua +++ b/lua/app/global/global_const.lua @@ -170,6 +170,8 @@ GConst.TYPEOF_LUA_CLASS = { HERO_CELL = "app/ui/common/cell/hero_cell", REWARD_CELL = "app/ui/common/cell/reward_cell", 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", } GConst.ATLAS_PATH = { diff --git a/lua/app/ui/shop/cell/pop_hero_cell.lua b/lua/app/ui/shop/cell/pop_hero_cell.lua new file mode 100644 index 00000000..db91b4e0 --- /dev/null +++ b/lua/app/ui/shop/cell/pop_hero_cell.lua @@ -0,0 +1,65 @@ +local PopHeroCell = class("PopHeroCell", BaseCell) + +function PopHeroCell:init() + local uiMap = self.baseObject:genAllChildren() + self.bg = uiMap["pop_hero_cell.bg"] + self.icon = uiMap["pop_hero_cell.icon"] + self.matchImg = uiMap["pop_hero_cell.match_img"] + self.progressBg = uiMap["pop_hero_cell.progress_bg"] + self.progress = uiMap["pop_hero_cell.progress"] + self.progressTx = uiMap["pop_hero_cell.progress_tx"] + self.lvUpArrow = uiMap["pop_hero_cell.effect_node.ui_spine_obj"] + self.fragmenImg = uiMap["pop_hero_cell.progress_bg.fragment_img"] + self.sImg = uiMap["pop_hero_cell.s"] + self.newBg = uiMap["pop_hero_cell.new_bg"] + self.newTx = uiMap["pop_hero_cell.new_bg.text"] + self.numTx = uiMap["pop_hero_cell.num_tx"] + + self.baseObject:addClickListener(function() + if self.clickCallback then + self.clickCallback() + end + end) +end + +function PopHeroCell:refreshWithCfgId(id, num) + local heroInfo = ConfigManager:getConfig("hero")[id] + self:_refresh(heroInfo) + local lv = heroInfo.begin_lv + local lvInfo = ConfigManager:getConfig("hero_level")[lv] + local materials = lvInfo["cost_" .. heroInfo.qlt] + local fragmentCount = DataManager.BagData.ItemData:getItemNumById(heroInfo.item_id) + if fragmentCount > 0 then -- 已拥有,则不是NEW了 + local needFragmentCount = materials[1] or 1 + self.progressTx:setText(fragmentCount .. "/" .. needFragmentCount) + self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount + self.progressBg:setVisible(true) + + self.newBg:setVisible(false) + else + self.progressBg:setVisible(false) + + self.newBg:setVisible(true) + self.newTx:setText("New") + end + self.lvUpArrow:setVisible(false) + self.fragmenImg:setVisible(true) + self.numTx:setText("X" .. tostring(num)) +end + +function PopHeroCell:_refresh(heroInfo) + self.bg:setSprite(GConst.ATLAS_PATH.ICON_ITEM, GConst.FRAME_QLT[heroInfo.qlt]) + self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, tostring(heroInfo.icon)) + self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position]) + self.sImg:setVisible(heroInfo.qlt >= 4) +end + +function PopHeroCell:addClickListener(callback) + self.clickCallback = callback +end + +function PopHeroCell:setVisible(visible, scale) + self.baseObject:setVisible(visible, scale) +end + +return PopHeroCell diff --git a/lua/app/ui/shop/cell/pop_hero_cell.lua.meta b/lua/app/ui/shop/cell/pop_hero_cell.lua.meta new file mode 100644 index 00000000..cbcaf361 --- /dev/null +++ b/lua/app/ui/shop/cell/pop_hero_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 996bfe193d1cbf048921a6dc5f669192 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/shop/cell/pop_reward_cell.lua b/lua/app/ui/shop/cell/pop_reward_cell.lua new file mode 100644 index 00000000..86149f16 --- /dev/null +++ b/lua/app/ui/shop/cell/pop_reward_cell.lua @@ -0,0 +1,50 @@ +local PopRewardCell = class("PopRewardCell", BaseCell) + +function PopRewardCell:init() + local uiMap = self.baseObject:genAllChildren() + self.bg = uiMap["pop_reward_cell.bg"] + if not self.itemCell then + self.itemCell = CellManager:addCellComp(uiMap["pop_reward_cell.item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL) + end + if not self.popHeroCell then + self.popHeroCell = CellManager:addCellComp(uiMap["pop_reward_cell.pop_hero_cell"], GConst.TYPEOF_LUA_CLASS.POP_HERO_CELL) + end + self.descTx = uiMap["pop_reward_cell.desc_text"] +end + +function PopRewardCell:refresh(id, num, showBg) + local cfgInfo = ConfigManager:getConfig("item")[id] + if cfgInfo then + self.bg:setVisible(showBg) + if cfgInfo.type == GConst.ItemConst.ITEM_TYPE.HERO_FRAGMENT then -- 英雄展示 + self.itemCell:getBaseObject():setVisible(false) + self.popHeroCell:setVisible(true) + + self.popHeroCell:refreshWithCfgId(id, num) + self.popHeroCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(id, self.popHeroCell:getBaseObject()) + end) + self.descTx:setText(ModuleManager.HeroManager:getHeroName(id)) + else -- 通用道具 + self.itemCell:getBaseObject():setVisible(true) + self.popHeroCell:setVisible(false) + + self.itemCell:refreshByCfg(id, 0) + self.itemCell:setNum("") + self.itemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(id, self.itemCell:getBaseObject()) + end) + self.descTx:setText(num) + end + end +end + +function PopRewardCell:addClickListener(callback) + self.clickCallback = callback +end + +function PopRewardCell:setVisible(visible, scale) + self.baseObject:setVisible(visible, scale) +end + +return PopRewardCell diff --git a/lua/app/ui/shop/cell/pop_reward_cell.lua.meta b/lua/app/ui/shop/cell/pop_reward_cell.lua.meta new file mode 100644 index 00000000..0bbd47fd --- /dev/null +++ b/lua/app/ui/shop/cell/pop_reward_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c92892aa158345a47967c8b83f8fc181 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/shop/first_recharge_pop_ui.lua b/lua/app/ui/shop/first_recharge_pop_ui.lua index b952631d..322d4483 100644 --- a/lua/app/ui/shop/first_recharge_pop_ui.lua +++ b/lua/app/ui/shop/first_recharge_pop_ui.lua @@ -21,15 +21,10 @@ function FirstRechargePopUI:onLoadRootComplete() self.titleTx = self.uiMap["first_recharge_pop_ui.bg.title_bg.title"] self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_34)) -- 首充豪礼 - self.itemNodeList = {} - self.itemCellList = {} - self.itemTextList = {} - self.itemHelpList = {} - for i = 1, MAX_ITEM_NUM do - table.insert(self.itemNodeList, self.uiMap["first_recharge_pop_ui.bg.item_" .. i]) - table.insert(self.itemCellList, CellManager:addCellComp(self.uiMap["first_recharge_pop_ui.bg.item_".. i .. ".item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL)) - table.insert(self.itemTextList, self.uiMap["first_recharge_pop_ui.bg.item_".. i .. ".num"]) - table.insert(self.itemHelpList, self.uiMap["first_recharge_pop_ui.bg.item_" .. i .. ".help"]) + -- 新版 + self.rewardCellList = {} + for i = 1, MAX_ITEM_NUM do + table.insert(self.rewardCellList, CellManager:addCellComp(self.uiMap["first_recharge_pop_ui.bg.pop_reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.POP_REWARD_CELL)) end self.descText = self.uiMap["first_recharge_pop_ui.bg.desc_text"] @@ -61,18 +56,12 @@ function FirstRechargePopUI:refresh() local cfgInfo = PayManager:getGiftConfigInfo(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.FIRST_RECHARGE_ID) local rewards = cfgInfo.reward or {} for i = 1, MAX_ITEM_NUM do - if i <= #rewards then - self.itemNodeList[i]:setVisible(true) - self.itemCellList[i]:refreshByCfg(rewards[i].id, 0) - self.itemCellList[i]:setNum("") - self.itemTextList[i]:setText(rewards[i].num) - self.itemCellList[i]:addClickListener(function() - ModuleManager.TipsManager:showItemTips(rewards[i].id, self.itemCellList[i]:getBaseObject()) - end) - self.itemHelpList[i]:setVisible(false) - else - self.itemNodeList[i]:setVisible(false) - end + if i <= #rewards then + self.rewardCellList[i]:setVisible(true, 0.8) + self.rewardCellList[i]:refresh(rewards[i].id, rewards[i].num, false) + else + self.rewardCellList[i]:setVisible(false) + end end -- 对于首充礼包,有跳转商店和领取2个分支 diff --git a/lua/app/userdata/shop/shop_data.lua b/lua/app/userdata/shop/shop_data.lua index 6fd68b37..2c6d54d6 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -405,6 +405,11 @@ end -- 章节礼包结束 ---------------------------------------------------------------------------------------------- -- 新手礼包 ********************************************************************************************** + +function ShopData:getIsBeginnerGiftOpen() + return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.BEGINNER_GIFT, true) +end + function ShopData:markPopUpGiftForBeginnerGift() self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.BEGINNER_GIFT_ID) end @@ -422,9 +427,9 @@ function ShopData:getBeginnerGiftSideBarDurationTime() return 3 * 24 * 3600 -- 目前无配置表 end --- 未购买且在开服的3天内 +-- 已开启 未购买 且 在开服的3天内 function ShopData:getBeginnerGiftShowSideBar() - return not self:getBeginnerGiftHasBuy() and self:getBeginnerGiftSideBarRemainTime() > 0 + return self:getIsBeginnerGiftOpen() and not self:getBeginnerGiftHasBuy() and self:getBeginnerGiftSideBarRemainTime() > 0 end -- 展示在侧边栏的剩余时间 @@ -716,6 +721,10 @@ end -- 首充 ********************************************************************************************** +function ShopData:getIsFirstRechargeOpen() + return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FIRST_RECHARGE, true) +end + -- 用于标记是否弹窗 要求等级不低于2 未领取该奖励 function ShopData:initFirstRecharge() local lv = DataManager.PlayerData:getLv() @@ -741,8 +750,12 @@ function ShopData:getHasGotFirstRechargeReward() return boughtNum > 0 end --- 侧边栏是否展示 要求等级不低于2 未领取该奖励 +-- 侧边栏是否展示 要求功能开启 等级不低于2 未领取该奖励 function ShopData:getShowFirstRechargeSideBar() + if not self:getIsFirstRechargeOpen() then + return false + end + local lv = DataManager.PlayerData:getLv() if lv > 1 and not self:getHasGotFirstRechargeReward() then return true @@ -753,6 +766,10 @@ end -- 侧边栏红点 function ShopData:showFirstRechargeRp() + if not self:getIsFirstRechargeOpen() then + return false + end + return self:getHasFirstRechargeReward() end From ff2fc67a4204dd96b2522273aaccf3bfb98f9351 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Wed, 31 May 2023 09:45:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A4=BC=E5=8C=85=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/shop/cell/pop_hero_cell.lua | 4 +-- lua/app/ui/shop/first_recharge_pop_ui.lua | 3 +- lua/app/ui/shop/gift_pop_ui.lua | 34 ++++++++--------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/lua/app/ui/shop/cell/pop_hero_cell.lua b/lua/app/ui/shop/cell/pop_hero_cell.lua index db91b4e0..c2d44c5c 100644 --- a/lua/app/ui/shop/cell/pop_hero_cell.lua +++ b/lua/app/ui/shop/cell/pop_hero_cell.lua @@ -6,8 +6,8 @@ function PopHeroCell:init() self.icon = uiMap["pop_hero_cell.icon"] self.matchImg = uiMap["pop_hero_cell.match_img"] self.progressBg = uiMap["pop_hero_cell.progress_bg"] - self.progress = uiMap["pop_hero_cell.progress"] - self.progressTx = uiMap["pop_hero_cell.progress_tx"] + self.progress = uiMap["pop_hero_cell.progress_bg.progress"] + self.progressTx = uiMap["pop_hero_cell.progress_bg.progress_tx"] self.lvUpArrow = uiMap["pop_hero_cell.effect_node.ui_spine_obj"] self.fragmenImg = uiMap["pop_hero_cell.progress_bg.fragment_img"] self.sImg = uiMap["pop_hero_cell.s"] diff --git a/lua/app/ui/shop/first_recharge_pop_ui.lua b/lua/app/ui/shop/first_recharge_pop_ui.lua index 322d4483..dd526f01 100644 --- a/lua/app/ui/shop/first_recharge_pop_ui.lua +++ b/lua/app/ui/shop/first_recharge_pop_ui.lua @@ -21,12 +21,11 @@ function FirstRechargePopUI:onLoadRootComplete() self.titleTx = self.uiMap["first_recharge_pop_ui.bg.title_bg.title"] self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_34)) -- 首充豪礼 - -- 新版 self.rewardCellList = {} for i = 1, MAX_ITEM_NUM do table.insert(self.rewardCellList, CellManager:addCellComp(self.uiMap["first_recharge_pop_ui.bg.pop_reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.POP_REWARD_CELL)) end - + self.descText = self.uiMap["first_recharge_pop_ui.bg.desc_text"] self.descText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_35)) -- 充值购买任意商品,即可获得如下奖励,仅此一次! diff --git a/lua/app/ui/shop/gift_pop_ui.lua b/lua/app/ui/shop/gift_pop_ui.lua index c839be2c..f5661562 100644 --- a/lua/app/ui/shop/gift_pop_ui.lua +++ b/lua/app/ui/shop/gift_pop_ui.lua @@ -60,17 +60,11 @@ function GiftPopUI:onLoadRootComplete() self.offNode = self.uiMap["gift_pop_ui.bg.off_img"] self.offText = self.uiMap["gift_pop_ui.bg.off_img.text"] - self.itemNodeLayout = self.uiMap["gift_pop_ui.bg.item_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) - self.itemNodeList = {} - self.itemCellList = {} - self.itemTextList = {} - self.itemHelpList = {} - for i = 1, MAX_ITEM_NUM do - table.insert(self.itemNodeList, self.uiMap["gift_pop_ui.bg.item_" .. i]) - table.insert(self.itemCellList, CellManager:addCellComp(self.uiMap["gift_pop_ui.bg.item_".. i .. ".item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL)) - table.insert(self.itemTextList, self.uiMap["gift_pop_ui.bg.item_".. i .. ".num"]) - table.insert(self.itemHelpList, self.uiMap["gift_pop_ui.bg.item_" .. i .. ".help"]) + self.rewardCellList = {} + for i = 1, MAX_ITEM_NUM do + table.insert(self.rewardCellList, CellManager:addCellComp(self.uiMap["gift_pop_ui.bg.item_node.pop_reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.POP_REWARD_CELL)) end + self.itemNodeLayout = self.uiMap["gift_pop_ui.bg.item_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) self.timeNode = self.uiMap["gift_pop_ui.bg.time_node"] self.timeText = self.uiMap["gift_pop_ui.bg.time_node.text"] @@ -130,18 +124,14 @@ function GiftPopUI:refresh(needCheck) local rewards = cfgInfo.reward or {} for i = 1, MAX_ITEM_NUM do - if i <= #rewards then - self.itemNodeList[i]:setVisible(true) - self.itemCellList[i]:refreshByCfg(rewards[i].id, 0) - self.itemCellList[i]:setNum("") - self.itemTextList[i]:setText(rewards[i].num) - self.itemCellList[i]:addClickListener(function() - ModuleManager.TipsManager:showItemTips(rewards[i].id, self.itemCellList[i]:getBaseObject()) - end) - self.itemHelpList[i]:setVisible(false) - else - self.itemNodeList[i]:setVisible(false) - end + for i = 1, MAX_ITEM_NUM do + if i <= #rewards then + self.rewardCellList[i]:setVisible(true, 0.8) + self.rewardCellList[i]:refresh(rewards[i].id, rewards[i].num, true) + else + self.rewardCellList[i]:setVisible(false) + end + end end self.itemNodeLayout:RefreshLayout()