diff --git a/lua/app/common/module_manager.lua b/lua/app/common/module_manager.lua index 1e614934..c04c2c88 100644 --- a/lua/app/common/module_manager.lua +++ b/lua/app/common/module_manager.lua @@ -89,6 +89,7 @@ local MODULE_PATHS = { ActPvpManager = "app/module/activity/act_pvp/act_pvp_manager", -- 天赋 TalentManager = "app/module/talent/talent_manager", + BagManager = "app/module/bag/bag_manager", } -- 这里的key对应func_open里的id diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index e626dda4..91fc5b66 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -680,6 +680,7 @@ local LocalizationGlobalConst = HERO_DESC_21 = "HERO_DESC_21", HERO_DESC_22 = "HERO_DESC_22", HERO_DESC_23 = "HERO_DESC_23", + BAG_DESC_1 = "BAG_DESC_1", } return LocalizationGlobalConst \ No newline at end of file diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index 471d71d7..14ee3613 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -680,6 +680,7 @@ local localization_global = ["HERO_DESC_21"] = "等级达到{0}可升星", ["HERO_DESC_22"] = "去升星", ["HERO_DESC_23"] = "技能等级:{0}", + ["BAG_DESC_1"] = "背包", } return localization_global \ No newline at end of file diff --git a/lua/app/global/global_func.lua b/lua/app/global/global_func.lua index 3d57c15f..7c031d29 100644 --- a/lua/app/global/global_func.lua +++ b/lua/app/global/global_func.lua @@ -2043,4 +2043,8 @@ function GFunc.getAttrNameCfg() return AttrNameCfg end +function GFunc.showCommonBoxUI(id, showTips) + ModuleManager.CommonManager:showCommonBoxUI(id, showTips) +end + return GFunc \ No newline at end of file diff --git a/lua/app/module/bag.meta b/lua/app/module/bag.meta new file mode 100644 index 00000000..a9a6871a --- /dev/null +++ b/lua/app/module/bag.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8aab66b72295428584f98745cd4316e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/module/bag/bag_manager.lua b/lua/app/module/bag/bag_manager.lua new file mode 100644 index 00000000..df6b4fb4 --- /dev/null +++ b/lua/app/module/bag/bag_manager.lua @@ -0,0 +1,7 @@ +local BagManager = class("BagManager", BaseModule) + +function BagManager:showBagMainUI() + UIManager:showUI("app/ui/bag/bag_main_ui") +end + +return BagManager \ No newline at end of file diff --git a/lua/app/module/bag/bag_manager.lua.meta b/lua/app/module/bag/bag_manager.lua.meta new file mode 100644 index 00000000..52672e42 --- /dev/null +++ b/lua/app/module/bag/bag_manager.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: abcae0ad41ca74a53977e09c921870b1 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/module/common/common_manager.lua b/lua/app/module/common/common_manager.lua index 3179fd66..a7b14d37 100644 --- a/lua/app/module/common/common_manager.lua +++ b/lua/app/module/common/common_manager.lua @@ -1,37 +1,45 @@ local CommonManager = class("CommonManager", BaseModule) function CommonManager:showMopUpUI(actType, rewards, remainCount, callback, customtitleTx, target) - local params = { - actType = actType, - customtitleTx = customtitleTx, - rewards = rewards, - remainCount = remainCount, - callback = callback, + local params = { + actType = actType, + customtitleTx = customtitleTx, + rewards = rewards, + remainCount = remainCount, + callback = callback, - ---- 有目标的扫荡 可为nil - target = target, - } - AudioManager:playEffect(AudioManager.EFFECT_ID.DUNGEON_SMASH) - UIManager:showUI("app/ui/common/mop_up_ui", params) + ---- 有目标的扫荡 可为nil + target = target, + } + AudioManager:playEffect(AudioManager.EFFECT_ID.DUNGEON_SMASH) + UIManager:showUI("app/ui/common/mop_up_ui", params) end function CommonManager:showFormationUI(formationType) - local params = { - formationType = formationType - } - UIManager:showUI("app/ui/common/common_formation_ui", params) + local params = { + formationType = formationType + } + UIManager:showUI("app/ui/common/common_formation_ui", params) end function CommonManager:showExchangeUI(defaultNum, remainNum, reward, cost, callback) - local params = { - defaultNum = defaultNum, - remainNum = remainNum, - reward = reward, - cost = cost, - callback = callback - } + local params = { + defaultNum = defaultNum, + remainNum = remainNum, + reward = reward, + cost = cost, + callback = callback + } - UIManager:showUI("app/ui/common/common_exchange_ui", params) + UIManager:showUI("app/ui/common/common_exchange_ui", params) +end + +function CommonManager:showCommonBoxUI(id, showTips) + local params = { + id = id, + showTips = showTips, + } + UIManager:showUI("app/ui/common/common_box_ui", params) end return CommonManager \ No newline at end of file diff --git a/lua/app/module/item/item_const.lua b/lua/app/module/item/item_const.lua index 91789e97..583bf7f3 100644 --- a/lua/app/module/item/item_const.lua +++ b/lua/app/module/item/item_const.lua @@ -36,8 +36,8 @@ ItemConst.ITEM_TYPE = { FIXED_BOX_ITEM = 8, AVATAR = 9, FRAME = 10, - EPIC_HERO_FRAMENT = 11, - SKIN = 12 + -- EPIC_HERO_FRAMENT = 11, + -- SKIN = 12 } return ItemConst \ No newline at end of file diff --git a/lua/app/module/tips/tips_manager.lua b/lua/app/module/tips/tips_manager.lua index 4a9edc8d..ed307651 100644 --- a/lua/app/module/tips/tips_manager.lua +++ b/lua/app/module/tips/tips_manager.lua @@ -33,11 +33,14 @@ function TipsManager:showRewardTips(rewardId, rewardType, tarPrefabObj, alignTyp local info = ConfigManager:getConfig("item")[rewardId] if info then 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 权重随机碎片 or 史诗英雄碎片 self:showHeroFragmentTips(rewardId) return + elseif info.type == GConst.ItemConst.ITEM_TYPE.WEIGHT_FRAGMENT then + -- 宝箱 + self:showWeightBoxTips(rewardId) + return elseif info.type == GConst.ItemConst.ITEM_TYPE.BOX then -- 宝箱 self:showBoxTips(rewardId) @@ -153,6 +156,13 @@ function TipsManager:showBoxTips(itemId) UIManager:showUI("app/ui/tips/box_tips", params) end +function TipsManager:showWeightBoxTips(itemId) + local params = { + itemId = itemId + } + UIManager:showUI("app/ui/tips/weight_box_tips", params) +end + function TipsManager:getRewardDesc(rewardId, rewardType) if rewardType == GConst.REWARD_TYPE.ITEM then local item18NInfo = I18N:getConfig("item")[rewardId] diff --git a/lua/app/ui/bag.meta b/lua/app/ui/bag.meta new file mode 100644 index 00000000..77b63834 --- /dev/null +++ b/lua/app/ui/bag.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2d759ce286cc84722bb74dbc806f3a9b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/ui/bag/bag_main_ui.lua b/lua/app/ui/bag/bag_main_ui.lua new file mode 100644 index 00000000..1eb2f007 --- /dev/null +++ b/lua/app/ui/bag/bag_main_ui.lua @@ -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("" .. self.btnTxs[i] .. "") + 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 \ No newline at end of file diff --git a/lua/app/ui/bag/bag_main_ui.lua.meta b/lua/app/ui/bag/bag_main_ui.lua.meta new file mode 100644 index 00000000..b220747a --- /dev/null +++ b/lua/app/ui/bag/bag_main_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 346aab93c85d448538267fce2f1e9d74 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/common/cell/reward_cell.lua b/lua/app/ui/common/cell/reward_cell.lua index 75b814b9..0029058f 100644 --- a/lua/app/ui/common/cell/reward_cell.lua +++ b/lua/app/ui/common/cell/reward_cell.lua @@ -149,6 +149,24 @@ function RewardCell:_refreshItem(info, count) self:showLight(false) 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) self.icon:setSprite(atlas, res) end diff --git a/lua/app/ui/common/common_box_ui.lua b/lua/app/ui/common/common_box_ui.lua new file mode 100755 index 00000000..73bfccce --- /dev/null +++ b/lua/app/ui/common/common_box_ui.lua @@ -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 \ No newline at end of file diff --git a/lua/app/ui/common/common_box_ui.lua.meta b/lua/app/ui/common/common_box_ui.lua.meta new file mode 100644 index 00000000..db833fdc --- /dev/null +++ b/lua/app/ui/common/common_box_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 84f546e396b49411885fd77c0f869bcb +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/game_setting/select_other_btn_ui.lua b/lua/app/ui/game_setting/select_other_btn_ui.lua index d6adbe7e..d0568cf2 100644 --- a/lua/app/ui/game_setting/select_other_btn_ui.lua +++ b/lua/app/ui/game_setting/select_other_btn_ui.lua @@ -67,7 +67,7 @@ function SelectOtherBtnUI:onLoadRootComplete() self.uiMap["select_other_btn_ui.bg.mail_btn"]:setVisible(false) end - if true then + if DataManager.BagData:getIsOpen() then cellCount = cellCount + 1 y = y - BTN_INTERVAL local bagBtn = self.uiMap["select_other_btn_ui.bg.bag_btn"] @@ -79,9 +79,9 @@ function SelectOtherBtnUI:onLoadRootComplete() bagBtn:setAnchoredPositionY(y) bagBtn:addClickListener(function() self:closeUI() - ModuleManager.GameSettingManager:showSettingUI() + ModuleManager.BagManager:showBagMainUI() 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 if Platform:getIsDevChannel() then diff --git a/lua/app/ui/tips/weight_box_tips.lua b/lua/app/ui/tips/weight_box_tips.lua new file mode 100644 index 00000000..cfbccb94 --- /dev/null +++ b/lua/app/ui/tips/weight_box_tips.lua @@ -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 \ No newline at end of file diff --git a/lua/app/ui/tips/weight_box_tips.lua.meta b/lua/app/ui/tips/weight_box_tips.lua.meta new file mode 100644 index 00000000..5119e55f --- /dev/null +++ b/lua/app/ui/tips/weight_box_tips.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7686743f9231048df9d7b5e17d300c27 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/bag/bag_data.lua b/lua/app/userdata/bag/bag_data.lua index aca24a04..3567752a 100644 --- a/lua/app/userdata/bag/bag_data.lua +++ b/lua/app/userdata/bag/bag_data.lua @@ -27,4 +27,13 @@ function BagData:updateCd() self.ItemData:updateCd() end +function BagData:getIsOpen() + return true +end + +--@region 道具 +function BagData:getItemList() + return self.ItemData:getItemList() +end +--@endregion return BagData \ No newline at end of file diff --git a/lua/app/userdata/bag/item_data.lua b/lua/app/userdata/bag/item_data.lua index 5be024a5..0f6296b8 100644 --- a/lua/app/userdata/bag/item_data.lua +++ b/lua/app/userdata/bag/item_data.lua @@ -352,4 +352,15 @@ function ItemData:isDayChange() return self.initDay ~= Time:getBeginningOfServerToday() 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 \ No newline at end of file diff --git a/lua/app/userdata/bag/item_entity.lua b/lua/app/userdata/bag/item_entity.lua index c8c2e928..14eb2611 100644 --- a/lua/app/userdata/bag/item_entity.lua +++ b/lua/app/userdata/bag/item_entity.lua @@ -25,6 +25,11 @@ function ItemEntity:setDirty() self.data.isDirty = not self.data.isDirty end +-- obj类型 +function ItemEntity:getType() + return GConst.REWARD_TYPE.ITEM +end + -- id function ItemEntity:getId() return self.data.id @@ -106,8 +111,4 @@ function ItemEntity:getDesc() return I18N:getText("item", self.data.id, "desc") end -function ItemEntity:getItemType() - return self.config.type -end - return ItemEntity \ No newline at end of file