From dc84eb073dc0b87fc9302a32da0238c548e4c4e1 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Mon, 24 Jul 2023 11:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=81=93=E5=85=B7=E5=AE=9D?= =?UTF-8?q?=E7=AE=B1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/config/item.lua | 16 +++++ lua/app/module/item/item_const.lua | 2 + lua/app/module/tips/tips_manager.lua | 10 +++ lua/app/ui/tips/box_item_tips.lua | 87 ++++++++++++++++++++++++++ lua/app/ui/tips/box_item_tips.lua.meta | 10 +++ 5 files changed, 125 insertions(+) create mode 100644 lua/app/ui/tips/box_item_tips.lua create mode 100644 lua/app/ui/tips/box_item_tips.lua.meta diff --git a/lua/app/config/item.lua b/lua/app/config/item.lua index ec16929d..fc96d574 100644 --- a/lua/app/config/item.lua +++ b/lua/app/config/item.lua @@ -457,6 +457,7 @@ local item = { ["icon"]="27" }, [28]={ + ["type"]=7, ["qlt"]=1, ["icon"]="28", ["item_drop"]={ @@ -487,6 +488,7 @@ local item = { } }, [29]={ + ["type"]=7, ["qlt"]=1, ["icon"]="29", ["item_drop"]={ @@ -541,6 +543,7 @@ local item = { } }, [30]={ + ["type"]=7, ["qlt"]=2, ["icon"]="30", ["item_drop"]={ @@ -619,6 +622,7 @@ local item = { } }, [31]={ + ["type"]=7, ["qlt"]=2, ["icon"]="31", ["item_drop"]={ @@ -697,6 +701,7 @@ local item = { } }, [32]={ + ["type"]=7, ["qlt"]=3, ["icon"]="32", ["item_drop"]={ @@ -775,6 +780,7 @@ local item = { } }, [33]={ + ["type"]=7, ["qlt"]=3, ["icon"]="33", ["item_drop"]={ @@ -853,6 +859,7 @@ local item = { } }, [34]={ + ["type"]=7, ["qlt"]=4, ["icon"]="34", ["item_drop"]={ @@ -931,6 +938,7 @@ local item = { } }, [35]={ + ["type"]=7, ["qlt"]=4, ["icon"]="35", ["item_drop"]={ @@ -1009,6 +1017,7 @@ local item = { } }, [36]={ + ["type"]=7, ["qlt"]=5, ["icon"]="36", ["item_drop"]={ @@ -1087,6 +1096,7 @@ local item = { } }, [37]={ + ["type"]=7, ["qlt"]=5, ["icon"]="37", ["item_drop"]={ @@ -1165,6 +1175,7 @@ local item = { } }, [38]={ + ["type"]=4, ["qlt"]=1, ["icon"]="38", ["reward"]={ @@ -1203,6 +1214,7 @@ local item = { } }, [39]={ + ["type"]=4, ["qlt"]=2, ["icon"]="39", ["reward"]={ @@ -1241,6 +1253,7 @@ local item = { } }, [40]={ + ["type"]=4, ["qlt"]=3, ["icon"]="40", ["reward"]={ @@ -1279,6 +1292,7 @@ local item = { } }, [41]={ + ["type"]=4, ["qlt"]=4, ["icon"]="41", ["reward"]={ @@ -1317,6 +1331,7 @@ local item = { } }, [42]={ + ["type"]=4, ["qlt"]=5, ["icon"]="42", ["reward"]={ @@ -1355,6 +1370,7 @@ local item = { } }, [43]={ + ["type"]=4, ["qlt"]=5, ["icon"]="43", ["reward"]={ diff --git a/lua/app/module/item/item_const.lua b/lua/app/module/item/item_const.lua index f492656f..52244e97 100644 --- a/lua/app/module/item/item_const.lua +++ b/lua/app/module/item/item_const.lua @@ -24,6 +24,8 @@ ItemConst.ITEM_TYPE = { BOX = 4, HERO_FRAGMENT = 5, WEIGHT_FRAGMENT = 6, + RANDOM_BOX_ITEM = 7, + FIXED_BOX_ITEM = 8, } 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 53e5b591..a48b327b 100644 --- a/lua/app/module/tips/tips_manager.lua +++ b/lua/app/module/tips/tips_manager.lua @@ -44,6 +44,9 @@ function TipsManager:showRewardTips(rewardId, rewardType, tarPrefabObj, alignTyp -- 英雄碎片 ModuleManager.HeroManager:showHeroDetailUI(info.parameter, true) return + elseif info.type == GConst.ItemConst.ITEM_TYPE.RANDOM_BOX_ITEM or info.type == GConst.ItemConst.ITEM_TYPE.FIXED_BOX_ITEM then + self:showBoxItemTips(rewardId) + return end end end @@ -108,6 +111,13 @@ function TipsManager:showHeroFragmentTips(itemId) UIManager:showUI("app/ui/tips/hero_fragment_tips", params) end +function TipsManager:showBoxItemTips(itemId) + local params = { + itemId = itemId + } + UIManager:showUI("app/ui/tips/box_item_tips", params) +end + -- formation = {heroEntity, ...} function TipsManager:showHeroFormation(targetObj, formation) local tarCornerScreenPos, location = self:getCornerScreenPosition(targetObj, TipsManager.ALIGN_TYPE.BOTTOM_CENTER) diff --git a/lua/app/ui/tips/box_item_tips.lua b/lua/app/ui/tips/box_item_tips.lua new file mode 100644 index 00000000..9943369a --- /dev/null +++ b/lua/app/ui/tips/box_item_tips.lua @@ -0,0 +1,87 @@ +local BoxItemTips = class("BoxItemTips", BaseUI) + +function BoxItemTips:ctor(params) + self.itemId = params.itemId +end + +function BoxItemTips:onPressBackspace() + self:closeUI() +end + +function BoxItemTips:getPrefabPath() + return "assets/prefabs/ui/tips/box_item_tips.prefab" +end + +function BoxItemTips:isFullScreen() + return false +end + +function BoxItemTips:onLoadRootComplete() + local cfg = ConfigManager:getConfig("item")[self.itemId] + if cfg == nil then + return self:closeUI() + end + local drop = nil + local titleTx = I18N:getGlobalText(I18N.GlobalConst.BOX_ITEM_TIPS_DESC_1) + self.isFixed = false + if cfg.item_drop then + drop = cfg.item_drop + else + drop = cfg.reward + self.isFixed = true + titleTx = I18N:getText("item", self.itemId, "desc") + end + if drop == nil then + return self:closeUI() + end + self.itemList = {} + for _, v in ipairs(drop) do + local itemCfg = ConfigManager:getConfig("item")[v.id] + local unit = { + reward = v, + sort = itemCfg.qlt * 10000 + v.id + } + table.insert(self.itemList, unit) + end + table.sort(self.itemList, function(a, b) + return a.sort > b.sort + 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["box_item_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["box_item_tips.title_bg_img.card"]:setSprite(GConst.ATLAS_PATH.ICON_ITEM, cfg.icon) + uiMap["box_item_tips.title_bg_img.desc"]:setText(titleTx) + uiMap["box_item_tips.title_bg_img.title_text"]:setText(I18N:getText("item", self.itemId, "name")) + uiMap["box_item_tips.title_bg_img.close_btn"]:addClickListener(function() + self:closeUI() + end) + + self:initScrollRect() +end + +function BoxItemTips:initScrollRect() + local scrollRectComp = self.uiMap["box_item_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:refreshByConfig(self.itemList[index].reward) + if not self.isFixed then + cell:hideCountTx() + end + end) + scrollRectComp:clearCells() + scrollRectComp:refillCells(#self.itemList) +end + +return BoxItemTips \ No newline at end of file diff --git a/lua/app/ui/tips/box_item_tips.lua.meta b/lua/app/ui/tips/box_item_tips.lua.meta new file mode 100644 index 00000000..c972ef26 --- /dev/null +++ b/lua/app/ui/tips/box_item_tips.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 134c3a84c0e95ba48a713bc7331dbec9 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}