This commit is contained in:
puxuan 2025-09-08 17:35:56 +08:00
parent 26df427916
commit 196c03b48b
22 changed files with 499 additions and 33 deletions

View File

@ -89,6 +89,7 @@ local MODULE_PATHS = {
ActPvpManager = "app/module/activity/act_pvp/act_pvp_manager", ActPvpManager = "app/module/activity/act_pvp/act_pvp_manager",
-- 天赋 -- 天赋
TalentManager = "app/module/talent/talent_manager", TalentManager = "app/module/talent/talent_manager",
BagManager = "app/module/bag/bag_manager",
} }
-- 这里的key对应func_open里的id -- 这里的key对应func_open里的id

View File

@ -680,6 +680,7 @@ local LocalizationGlobalConst =
HERO_DESC_21 = "HERO_DESC_21", HERO_DESC_21 = "HERO_DESC_21",
HERO_DESC_22 = "HERO_DESC_22", HERO_DESC_22 = "HERO_DESC_22",
HERO_DESC_23 = "HERO_DESC_23", HERO_DESC_23 = "HERO_DESC_23",
BAG_DESC_1 = "BAG_DESC_1",
} }
return LocalizationGlobalConst return LocalizationGlobalConst

View File

@ -680,6 +680,7 @@ local localization_global =
["HERO_DESC_21"] = "等级达到{0}可升星", ["HERO_DESC_21"] = "等级达到{0}可升星",
["HERO_DESC_22"] = "去升星", ["HERO_DESC_22"] = "去升星",
["HERO_DESC_23"] = "技能等级:{0}", ["HERO_DESC_23"] = "技能等级:{0}",
["BAG_DESC_1"] = "背包",
} }
return localization_global return localization_global

View File

@ -2043,4 +2043,8 @@ function GFunc.getAttrNameCfg()
return AttrNameCfg return AttrNameCfg
end end
function GFunc.showCommonBoxUI(id, showTips)
ModuleManager.CommonManager:showCommonBoxUI(id, showTips)
end
return GFunc return GFunc

8
lua/app/module/bag.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d8aab66b72295428584f98745cd4316e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
local BagManager = class("BagManager", BaseModule)
function BagManager:showBagMainUI()
UIManager:showUI("app/ui/bag/bag_main_ui")
end
return BagManager

View File

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

View File

@ -34,4 +34,12 @@ function CommonManager:showExchangeUI(defaultNum, remainNum, reward, cost, callb
UIManager:showUI("app/ui/common/common_exchange_ui", params) UIManager:showUI("app/ui/common/common_exchange_ui", params)
end end
function CommonManager:showCommonBoxUI(id, showTips)
local params = {
id = id,
showTips = showTips,
}
UIManager:showUI("app/ui/common/common_box_ui", params)
end
return CommonManager return CommonManager

View File

@ -36,8 +36,8 @@ ItemConst.ITEM_TYPE = {
FIXED_BOX_ITEM = 8, FIXED_BOX_ITEM = 8,
AVATAR = 9, AVATAR = 9,
FRAME = 10, FRAME = 10,
EPIC_HERO_FRAMENT = 11, -- EPIC_HERO_FRAMENT = 11,
SKIN = 12 -- SKIN = 12
} }
return ItemConst return ItemConst

View File

@ -33,11 +33,14 @@ function TipsManager:showRewardTips(rewardId, rewardType, tarPrefabObj, alignTyp
local info = ConfigManager:getConfig("item")[rewardId] local info = ConfigManager:getConfig("item")[rewardId]
if info then if info then
if info.type == GConst.ItemConst.ITEM_TYPE.RANDOM_FRAGMENT if info.type == GConst.ItemConst.ITEM_TYPE.RANDOM_FRAGMENT
or info.type == GConst.ItemConst.ITEM_TYPE.WEIGHT_FRAGMENT
or info.type == GConst.ItemConst.ITEM_TYPE.EPIC_HERO_FRAMENT then or info.type == GConst.ItemConst.ITEM_TYPE.EPIC_HERO_FRAMENT then
-- 随机碎片 or 权重随机碎片 or 史诗英雄碎片 -- 随机碎片 or 权重随机碎片 or 史诗英雄碎片
self:showHeroFragmentTips(rewardId) self:showHeroFragmentTips(rewardId)
return return
elseif info.type == GConst.ItemConst.ITEM_TYPE.WEIGHT_FRAGMENT then
-- 宝箱
self:showWeightBoxTips(rewardId)
return
elseif info.type == GConst.ItemConst.ITEM_TYPE.BOX then elseif info.type == GConst.ItemConst.ITEM_TYPE.BOX then
-- 宝箱 -- 宝箱
self:showBoxTips(rewardId) self:showBoxTips(rewardId)
@ -153,6 +156,13 @@ function TipsManager:showBoxTips(itemId)
UIManager:showUI("app/ui/tips/box_tips", params) UIManager:showUI("app/ui/tips/box_tips", params)
end end
function TipsManager:showWeightBoxTips(itemId)
local params = {
itemId = itemId
}
UIManager:showUI("app/ui/tips/weight_box_tips", params)
end
function TipsManager:getRewardDesc(rewardId, rewardType) function TipsManager:getRewardDesc(rewardId, rewardType)
if rewardType == GConst.REWARD_TYPE.ITEM then if rewardType == GConst.REWARD_TYPE.ITEM then
local item18NInfo = I18N:getConfig("item")[rewardId] local item18NInfo = I18N:getConfig("item")[rewardId]

8
lua/app/ui/bag.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d759ce286cc84722bb74dbc806f3a9b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,91 @@
local BagMainUI = class("BagMainUI", BaseUI)
function BagMainUI:isFullScreen()
return false
end
function BagMainUI:getPrefabPath()
return "assets/prefabs/ui/bag/bag_main_ui.prefab"
end
function BagMainUI:onPressBackspace()
self:closeUI()
end
function BagMainUI:ctor(parmas)
end
function BagMainUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
uiMap["bag_main_ui.bg.close_btn"]:addClickListener(function()
self:closeUI()
end)
self.titleTx = uiMap["bag_main_ui.bg.title_tx"]
self.btnTxs = {I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4), I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_16)}
self.pageBtns = {}
self.pageBtnTxs = {}
self.pageBtnLocks = {}
self.pageRedImgs = {}
for i = 1, 2 do
self.pageBtns[i] = uiMap["bag_main_ui.bg.btns.page_btn_" .. i]
self.pageBtnTxs[i] = uiMap["bag_main_ui.bg.btns.page_btn_" .. i .. ".text"]
self.pageBtnLocks[i] = uiMap["bag_main_ui.bg.btns.page_btn_" .. i .. ".lock_img"]
self.pageRedImgs[i] = uiMap["bag_main_ui.red_node.red_img_" .. i]
-- if self.pageBtnLocks[i] then
-- self.pageBtnLocks[i]:setActive(not self:getIsOpen(i))
-- end
self.pageBtns[i] :addClickListener(function()
if not self:getIsOpen(i) or self.page == i then
return
end
self.page = i
self:onRefresh()
end)
end
self.scrollrect = uiMap["bag_main_ui.bg.scrollrect"]
self.scrollRectComp = uiMap["bag_main_ui.bg.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRectComp:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end)
self.scrollRectComp:addRefreshCallback(function(index, cell)
cell:refreshByEntity(self.list[index])
end)
self.scrollRectComp:clearCells()
end
function BagMainUI:onRefresh()
self:initList()
self:refreshPageBtn()
self:refreshScrollrect()
self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.BAG_DESC_1))
end
function BagMainUI:initList()
self.list = DataManager.BagData:getItemList()
end
-- 刷新标签红点
function BagMainUI:refreshPageBtn()
for i = 1, 2 do
self.pageBtns[i]:setActive(false)
if self.page == i then
self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_tab_1")
self.pageBtnTxs[i]:setText(self.btnTxs[i])
else
self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_tab_2")
self.pageBtnTxs[i]:setText("<color=#72778C>" .. self.btnTxs[i] .. "</color>")
end
-- self.pageRedImgs[i]:setActive(self.heroEntity:showRedPoint(i))
self.pageRedImgs[i]:setActive(false)
end
end
function BagMainUI:refreshScrollrect()
self.scrollRectComp:refillCells(#self.list)
end
return BagMainUI

View File

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

View File

@ -149,6 +149,24 @@ function RewardCell:_refreshItem(info, count)
self:showLight(false) self:showLight(false)
end end
function RewardCell:refreshByEntity(entity)
local type = entity:getType()
local id = entity:getId()
if type == GConst.REWARD_TYPE.ITEM then
local info = ConfigManager:getConfig("item")[id]
if info == nil then
return
end
self.rewardId = id
self.rewardType = type
self:_refreshItem(info, entity:getNum())
else
self.rewardId = nil
end
self:showMask(false, false)
self:showFirstPass(false)
end
function RewardCell:setIconSprite(atlas, res) function RewardCell:setIconSprite(atlas, res)
self.icon:setSprite(atlas, res) self.icon:setSprite(atlas, res)
end end

View File

@ -0,0 +1,177 @@
local CommonBoxUI = class("CommonBoxUI", BaseUI)
function CommonBoxUI:isFullScreen()
return false
end
function CommonBoxUI:showCommonBG()
return false
end
function CommonBoxUI:getPrefabPath()
return "assets/prefabs/ui/common/common_box_ui.prefab"
end
function CommonBoxUI:onPressBackspace()
self:closeUI()
end
function CommonBoxUI:onClose()
end
function CommonBoxUI:ctor(params)
self.id = params.id
self.showTips = params.showTips
self.maxCount = DataManager.BagData.ItemData:getItemNumById(self.id)
self.itemType = ModuleManager.ItemManager:getItemType(self.id)
local cfg = ConfigManager:getConfig("item")[self.id]
if self.itemType == GConst.ItemConst.ITEM_TYPE.BOX_RANDOM then
-- 随机宝箱
self.curCount = self.maxCount
self.rewards = cfg and cfg.box_drop
elseif self.itemType == GConst.ItemConst.ITEM_TYPE.BOX_SELECT then
-- 自选宝箱
self.curCount = 1
self.rewards = cfg and cfg.box_select
else
self.curCount = 1
self.rewards = cfg and cfg.box_drop
end
if self.rewards == nil then
self:closeUI()
end
end
function CommonBoxUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.mask = uiMap["common_box_ui.mask"]
self.contentNode = uiMap["common_box_ui.content"]
self.btnClose = uiMap["common_box_ui.content.btn_close"]
self.rewardCell = uiMap["common_box_ui.content.info_node.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
self.txName = uiMap["common_box_ui.content.info_node.tx_name"]
self.txType = uiMap["common_box_ui.content.info_node.tx_type"]
self.txCount = uiMap["common_box_ui.content.info_node.tx_count"]
self.txDesc = uiMap["common_box_ui.content.desc.tx_desc"]
self.scrollrect = uiMap["common_box_ui.content.scrollrect"]
self.selectNode = uiMap["common_box_ui.content.select"]
self.txSelect = uiMap["common_box_ui.content.select.tx_select"]
self.btnSub = uiMap["common_box_ui.content.select.btn_sub"]
self.btnAdd = uiMap["common_box_ui.content.select.btn_add"]
self.btnMax = uiMap["common_box_ui.content.select.btn_max"]
self.txMax = uiMap["common_box_ui.content.select.btn_max.tx_max"]
self.btnUse = uiMap["common_box_ui.content.btn_use"]
self.txUse = uiMap["common_box_ui.content.btn_use.tx_desc"]
self.txMax:setText(I18N:getGlobalText(I18N.GlobalConst.ITEM_DESC_2))
self.txUse:setText(I18N:getGlobalText(I18N.GlobalConst.USING_DESC))
self.btnSub:addClickListener(function()
if self.curCount <= 1 then
return
end
self.curCount = self.curCount - 1
self:onRefresh()
end)
self.btnAdd:addClickListener(function()
if self.curCount >= self.maxCount then
return
end
self.curCount = self.curCount + 1
self:onRefresh()
end)
self.btnMax:addClickListener(function()
if self.curCount >= self.maxCount then
return
end
self.curCount = self.maxCount
self:onRefresh()
end)
self.btnUse:addClickListener(function()
if self.itemType == GConst.ItemConst.ITEM_TYPE.BOX_SELECT and (self.curIndex == nil or self.curIndex <= 0) then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ITEM_DESC_3))
return
end
ModuleManager.ItemManager:reqOpenBoxReward(self.id, self.curCount, self.curIndex)
self:closeUI()
end)
self.mask:addClickListener(function()
self:closeUI()
end)
self.btnClose:addClickListener(function()
self:closeUI()
end)
end
function CommonBoxUI:onRefresh()
self.rewardCell:refreshById(self.id)
self.txName:setText(ModuleManager.ItemManager:getItemName(self.id))
self.txType:setText(I18N:getGlobalText(I18N.GlobalConst["ITEM_TYPE_" .. ModuleManager.ItemManager:getItemType(self.id)]))
self.txCount:setText(I18N:getGlobalText(I18N.GlobalConst.ITEM_DESC_1, self.maxCount))
self.txDesc:setText(ModuleManager.ItemManager:getItemDesc(self.id))
self.txSelect:setText(self.curCount)
if self.rewards then
if self.scrollRect == nil then
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRect:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end)
self.scrollRect:addRefreshCallback(function(index, cell)
cell:refreshByConfig(self.rewards[index])
cell:setShowSelect(index == self.curIndex)
cell:setShowProbTag(self.itemType == GConst.ItemConst.ITEM_TYPE.BOX_RANDOM, self:getRewardProb(index))
if index ~= self.curIndex and self.itemType == GConst.ItemConst.ITEM_TYPE.BOX_SELECT then
cell:addClickListener(function()
self:onClickReward(index)
end)
else
cell:setClickShowTips()
end
end)
end
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
self.scrollRect:refillCells(#self.rewards)
elseif self.scrollRect:getTotalCount() ~= #self.rewards then
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.rewards)
else
self.scrollRect:updateAllCell()
end
end
if self.showTips then
-- 展示宝箱tips
self.selectNode:setActive(false)
self.btnUse:setActive(false)
self.contentNode:setSizeDeltaY(500)
else
-- 展示宝箱开奖励
self.selectNode:setActive(true)
self.btnUse:setActive(true)
self.contentNode:setSizeDeltaY(648)
end
end
function CommonBoxUI:onClickReward(index)
self.curIndex = index
self:onRefresh()
end
function CommonBoxUI:getRewardProb(index)
if self.itemType ~= GConst.ItemConst.ITEM_TYPE.BOX_RANDOM then
return
end
local total = 0
local weight = self.rewards[index].weight or 0
for i, reward in ipairs(self.rewards) do
total = total + (reward.weight or 0)
end
return math.floor((weight / total) * 1000) / 10
end
return CommonBoxUI

View File

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

View File

@ -67,7 +67,7 @@ function SelectOtherBtnUI:onLoadRootComplete()
self.uiMap["select_other_btn_ui.bg.mail_btn"]:setVisible(false) self.uiMap["select_other_btn_ui.bg.mail_btn"]:setVisible(false)
end end
if true then if DataManager.BagData:getIsOpen() then
cellCount = cellCount + 1 cellCount = cellCount + 1
y = y - BTN_INTERVAL y = y - BTN_INTERVAL
local bagBtn = self.uiMap["select_other_btn_ui.bg.bag_btn"] local bagBtn = self.uiMap["select_other_btn_ui.bg.bag_btn"]
@ -79,9 +79,9 @@ function SelectOtherBtnUI:onLoadRootComplete()
bagBtn:setAnchoredPositionY(y) bagBtn:setAnchoredPositionY(y)
bagBtn:addClickListener(function() bagBtn:addClickListener(function()
self:closeUI() self:closeUI()
ModuleManager.GameSettingManager:showSettingUI() ModuleManager.BagManager:showBagMainUI()
end) end)
self.uiMap["select_other_btn_ui.bg.bag_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.SETTING_DESC)) self.uiMap["select_other_btn_ui.bg.bag_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.BAG_DESC_1))
end end
if Platform:getIsDevChannel() then if Platform:getIsDevChannel() then

View File

@ -0,0 +1,71 @@
local WeightBoxTips = class("WeightBoxTips", BaseUI)
function WeightBoxTips:ctor(params)
self.itemId = params.itemId
end
function WeightBoxTips:onPressBackspace()
self:closeUI()
end
function WeightBoxTips:getPrefabPath()
return "assets/prefabs/ui/tips/weight_box_tips.prefab"
end
function WeightBoxTips:isFullScreen()
return false
end
function WeightBoxTips:onLoadRootComplete()
local cfg = ConfigManager:getConfig("item")[self.itemId]
if cfg == nil then
return self:closeUI()
end
self.dropIds = {}
if cfg.hero_drop then
self.dropIds = cfg.hero_drop
elseif cfg.box_drop then
for _, item in ipairs(cfg.box_drop) do
table.insert(self.dropIds, item.id)
end
end
local uiMap = self.root:genAllChildren()
self.uiMap = uiMap
local itemQlt = cfg.qlt
if itemQlt < 1 then
itemQlt = 1
elseif itemQlt > 4 then
itemQlt = 4
end
local bgQlt = uiMap["weight_box_tips.title_bg_img.bg_qlt"]
bgQlt:setVisible(false)
bgQlt:setTexture("assets/arts/textures/background/shop/shop_card_bg_" .. itemQlt .. ".png", function()
bgQlt:setVisible(true)
end)
uiMap["weight_box_tips.title_bg_img.card"]:setSprite(GConst.ATLAS_PATH.ICON_ITEM, cfg.icon)
uiMap["weight_box_tips.title_bg_img.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_CARD_TIPS_DESC))
uiMap["weight_box_tips.title_bg_img.title_text"]:setText(I18N:getText("item", self.itemId, "name"))
uiMap["weight_box_tips.title_bg_img.close_btn"]:addClickListener(function()
self:closeUI()
end)
if cfg.type == GConst.ItemConst.ITEM_TYPE.EPIC_HERO_FRAMENT then
uiMap["weight_box_tips.title_bg_img.desc"]:setText(I18N:getText("item", self.itemId, "desc"))
end
self:initScrollRect()
end
function WeightBoxTips:initScrollRect()
local scrollRectComp = self.uiMap["weight_box_tips.title_bg_img.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
scrollRectComp:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end)
scrollRectComp:addRefreshCallback(function(index, cell)
cell:refreshItemById(self.dropIds[index], 0)
end)
scrollRectComp:clearCells()
scrollRectComp:refillCells(#self.dropIds)
end
return WeightBoxTips

View File

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

View File

@ -27,4 +27,13 @@ function BagData:updateCd()
self.ItemData:updateCd() self.ItemData:updateCd()
end end
function BagData:getIsOpen()
return true
end
--@region 道具
function BagData:getItemList()
return self.ItemData:getItemList()
end
--@endregion
return BagData return BagData

View File

@ -352,4 +352,15 @@ function ItemData:isDayChange()
return self.initDay ~= Time:getBeginningOfServerToday() return self.initDay ~= Time:getBeginningOfServerToday()
end end
--@region 背包操作
function ItemData:getItemList()
local items = {}
for _, v in pairs(self.items) do
if v:getNum() > 0 then
table.insert(items, v)
end
end
return items
end
--@endregion
return ItemData return ItemData

View File

@ -25,6 +25,11 @@ function ItemEntity:setDirty()
self.data.isDirty = not self.data.isDirty self.data.isDirty = not self.data.isDirty
end end
-- obj类型
function ItemEntity:getType()
return GConst.REWARD_TYPE.ITEM
end
-- id -- id
function ItemEntity:getId() function ItemEntity:getId()
return self.data.id return self.data.id
@ -106,8 +111,4 @@ function ItemEntity:getDesc()
return I18N:getText("item", self.data.id, "desc") return I18N:getText("item", self.data.id, "desc")
end end
function ItemEntity:getItemType()
return self.config.type
end
return ItemEntity return ItemEntity