This commit is contained in:
xiekaidong 2023-05-31 09:49:37 +08:00
commit 02832f21f3
9 changed files with 181 additions and 47 deletions

View File

@ -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", -- 新手礼包
MAIL = "mail_open", -- 邮件
}

View File

@ -171,6 +171,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 = {

View File

@ -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_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"]
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

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 996bfe193d1cbf048921a6dc5f669192
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -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

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c92892aa158345a47967c8b83f8fc181
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -21,17 +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.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"]
self.descText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_35)) -- 充值购买任意商品,即可获得如下奖励,仅此一次!
@ -61,18 +55,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个分支

View File

@ -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()

View File

@ -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