From a48651b348a314004ae64a071851566afc36a1fe Mon Sep 17 00:00:00 2001 From: CloudJ Date: Sat, 3 Jun 2023 22:42:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=88=98=E4=BB=A4=E5=AE=9D=E7=AE=B1=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/shop/box_open_ui.lua | 45 ++++++++++++++++++++----------- lua/app/ui/shop/box_reward_ui.lua | 11 +++++++- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/lua/app/ui/shop/box_open_ui.lua b/lua/app/ui/shop/box_open_ui.lua index a8b34207..8aebc8f3 100644 --- a/lua/app/ui/shop/box_open_ui.lua +++ b/lua/app/ui/shop/box_open_ui.lua @@ -1,5 +1,19 @@ local BoxOpenUI = class("BoxOpenUI", BaseUI) local SPINE_OPEN_TIME = 1.4 +local DEFAULT_SPINE_NAME = "ui_shop_box_1" -- 默认的展示动画 + +local SUMMON_SPINE_NAME = { + [1] = "ui_shop_box_1", + [2] = "ui_shop_box_2", + [3] = "ui_shop_box_3", +} +local BOUNTY_SPINE_NAME = { + [8] = "ui_bounty_chestopen_1", + [9] = "ui_bounty_chestopen_2", + [11] = "ui_bounty_chestopen_3", + [18] = "ui_bounty_chestopen_4", + [10] = "ui_bounty_chestopen_5", +} function BoxOpenUI:ctor(params) self.params = params or {} -- 将信息传递给下一个界面 @@ -18,31 +32,32 @@ end function BoxOpenUI:onLoadRootComplete() self.uiMap = self.root:genAllChildren() self.bg = self.uiMap["box_open_ui.bg"] - self.summonSpineList = {} - for i = 1, 3 do - table.insert(self.summonSpineList, self.uiMap["box_open_ui.ui_spine_obj_" .. i]) - self.summonSpineList[i]:setVisible(false) - end -- 奖励界面打开时 关闭此界面 self:addEventListener(EventManager.CUSTOM_EVENT.CLOSE_BOX_OPEN_UI, function() self:closeUI() end) EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CLOSE_BOX_HERO_UI) -- 播放spine表现 播放完毕后打开奖励UI - local spineObj + self.spineObj = self.uiMap["box_open_ui.ui_spine_obj"] + local spineName + + Logger.logHighlight("type:%s index:%s", self.type, self.index) + if self.type == GConst.ShopConst.BOX_REWARD_TYPE.SUMMON then - spineObj = self.summonSpineList[self.index] + spineName = SUMMON_SPINE_NAME[self.index] elseif self.type == GConst.ShopConst.BOX_REWARD_TYPE.BOUNTY then - -- TODOJ + spineName = BOUNTY_SPINE_NAME[self.index] end - if not spineObj then - spineObj = self.summonSpineList[1] + if not spineName then + spineName = DEFAULT_SPINE_NAME end - spineObj:setVisible(true) - spineObj:playAnim("born", false, true) - self:performWithDelayGlobal(function() - ModuleManager.ShopManager:showBoxRewardUI(self.params) - end, SPINE_OPEN_TIME) + self.spineObj:loadAssetAsync(spineName, function() + self.spineObj:playAnim("born", false, true, true) + self.spineObj:getSkeletonGraphic().enabled = true + self:performWithDelayGlobal(function() + ModuleManager.ShopManager:showBoxRewardUI(self.params) + end, SPINE_OPEN_TIME) + end, false) end return BoxOpenUI \ No newline at end of file diff --git a/lua/app/ui/shop/box_reward_ui.lua b/lua/app/ui/shop/box_reward_ui.lua index 8ca6caf0..f1a14520 100644 --- a/lua/app/ui/shop/box_reward_ui.lua +++ b/lua/app/ui/shop/box_reward_ui.lua @@ -107,6 +107,7 @@ function BoxRewardUI:onLoadRootComplete() self.rewardCells = self.rewardCells or {} local contentTrans = self.scrollRectContent:getTransform() local alreadyCellCount = contentTrans.childCount - 1 + local rewardCount = #self.fragmentRewards if alreadyCellCount > 0 then for i = 1, alreadyCellCount do local prefab = contentTrans:GetChild(i).gameObject @@ -114,10 +115,18 @@ function BoxRewardUI:onLoadRootComplete() local prefabObject = UIPrefabObject:create() prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab) prefabObject:initPrefabHelper() + -- 设定位置 + local index = i + local rowIdx = (index - 1) % CELL_NUM + 1 -- 横排位置 1-4 + local cowIdx = (index - 1) // CELL_NUM + 1 + if rewardCount <= CELL_NUM then -- 居中展示 + prefabObject:setAnchoredPosition(POSITION_X_DATA[rewardCount][rowIdx], 0) + else + prefabObject:setAnchoredPosition(POSITION_X_DATA[4][rowIdx], -(cowIdx - 1) * REWARD_CELL_HEIGHT) + end table.insert(self.rewardCells, CellManager:addCellComp(prefabObject, BOX_HERO_CELL)) end end - local rewardCount = #self.fragmentRewards local cellCount = #self.rewardCells local needCreateCount = rewardCount - cellCount -- 将cell扩充至与奖励等数量 From 1d7603ac2e4ad8ca5800c59a35539dcc26340352 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Sat, 3 Jun 2023 22:55:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=A6=96=E5=85=85=E4=BE=A7=E8=BE=B9?= =?UTF-8?q?=E6=A0=8F=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua b/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua index b952199a..38ffd9ed 100644 --- a/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua +++ b/lua/app/ui/main_city/cell/side_bar_first_recharge_cell.lua @@ -9,8 +9,8 @@ function SideBarFirstRechargeCell:getIsOpen() return DataManager.ShopData:getShowFirstRechargeSideBar() end -function SideBarFirstRechargeCell:getIconRes() - return "main_btn_gift_3" +function SideBarFirstRechargeCell:getSpineName() + return "ui_main_btn_gift_first" end function SideBarFirstRechargeCell:getIsShowRedPoint() From 954d4c317d1d5f4dc05fae759142efdf6d7e7389 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Sat, 3 Jun 2023 23:29:23 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=95=86=E5=9F=8E=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/shop/shop_const.lua | 12 +++++++ .../ui/currency_bar/cell/currency_cell.lua | 4 +-- lua/app/ui/main_city/main_city_ui.lua | 9 ++++- lua/app/ui/shop/cell/chapter_cell.lua | 6 ++-- lua/app/ui/shop/first_recharge_pop_ui.lua | 2 +- lua/app/ui/shop/gift_pop_ui.lua | 2 +- lua/app/ui/shop/shop_comp.lua | 36 +++++++++++++++++++ 7 files changed, 63 insertions(+), 8 deletions(-) diff --git a/lua/app/module/shop/shop_const.lua b/lua/app/module/shop/shop_const.lua index fba495eb..823b41d4 100644 --- a/lua/app/module/shop/shop_const.lua +++ b/lua/app/module/shop/shop_const.lua @@ -15,6 +15,18 @@ ShopConst.BOX_REWARD_TYPE = { BOUNTY = 2, } +ShopConst.PAGE_TYPE = { + DISCOUNT = 1, + MAIN = 2 +} +-- 商店主要商品页面的类型 +ShopConst.MAIN_PAGE_TYPE = { + BOX = 1, + HOT = 2, + GEM = 3, + GOLD = 4 +} + ShopConst.GEM_ICON_NAME = { [1] = "shop_diamond_1", [2] = "shop_diamond_1", diff --git a/lua/app/ui/currency_bar/cell/currency_cell.lua b/lua/app/ui/currency_bar/cell/currency_cell.lua index 14cb1d80..9400eab4 100644 --- a/lua/app/ui/currency_bar/cell/currency_cell.lua +++ b/lua/app/ui/currency_bar/cell/currency_cell.lua @@ -39,12 +39,12 @@ function ResourceCell:show(itemId, hideAddImg) self.timeTx:setVisible(true) elseif itemId == GConst.ItemConst.ITEM_ID_GOLD then self.baseObject:addClickListener(function() - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = 2}) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = GConst.ShopConst.PAGE_TYPE.MAIN, subType = GConst.ShopConst.MAIN_PAGE_TYPE.GOLD}) end) self.addImg:setVisible(true) elseif itemId == GConst.ItemConst.ITEM_ID_GEM then self.baseObject:addClickListener(function() - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = 2}) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = GConst.ShopConst.PAGE_TYPE.MAIN, subType = GConst.ShopConst.MAIN_PAGE_TYPE.GEM}) end) self.addImg:setVisible(true) else diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index e284bda1..c363c79e 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -132,10 +132,14 @@ function MainCityUI:_addListeners() end) self:addEventListener(EventManager.CUSTOM_EVENT.GO_SHOP, function(params) if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, false) then - local page = params and params.page or 2 -- 默认主要商品 + local page = params and params.page or GConst.ShopConst.PAGE_TYPE.MAIN -- 默认主要商品 + local subType = params.subType if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP then if self.subComps and self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] then self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:switchPage(page) + if page == GConst.ShopConst.PAGE_TYPE.MAIN and subType then + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:goSubType(subType) + end end return end @@ -147,6 +151,9 @@ function MainCityUI:_addListeners() self:refreshBottom(GConst.MainCityConst.BOTTOM_PAGE.SHOP, true) if self.subComps and self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] then self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:switchPage(page) + if page == GConst.ShopConst.PAGE_TYPE.MAIN and subType then + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:goSubType(subType) + end end end end) diff --git a/lua/app/ui/shop/cell/chapter_cell.lua b/lua/app/ui/shop/cell/chapter_cell.lua index 3d7f187e..c259aa4f 100644 --- a/lua/app/ui/shop/cell/chapter_cell.lua +++ b/lua/app/ui/shop/cell/chapter_cell.lua @@ -82,9 +82,9 @@ function ChapterCell:refresh(idx, cfgInfo, totalCount, arrowCallback) end end self.reweardLayout:RefreshLayout() - -- 价格(使用1类型) - self.originPriceImg1:setVisible(true) - self.originPriceText1:setVisible(true) + -- 价格(使用1类型)(取消原价) + self.originPriceImg1:setVisible(false) + self.originPriceText1:setVisible(false) self.priceText1:setVisible(true) self.originPriceImg2:setVisible(false) diff --git a/lua/app/ui/shop/first_recharge_pop_ui.lua b/lua/app/ui/shop/first_recharge_pop_ui.lua index 8dcaeb48..d4b21310 100644 --- a/lua/app/ui/shop/first_recharge_pop_ui.lua +++ b/lua/app/ui/shop/first_recharge_pop_ui.lua @@ -87,7 +87,7 @@ function FirstRechargePopUI:onClickFuncBtn() if canGet then PayManager:purchasePackage(GConst.ShopConst.FIRST_RECHARGE_ID, PayManager.PURCHARSE_TYPE.ACT_GIFT) else - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = 1}) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = GConst.ShopConst.PAGE_TYPE.DISCOUNT}) self:closeUI() end end diff --git a/lua/app/ui/shop/gift_pop_ui.lua b/lua/app/ui/shop/gift_pop_ui.lua index aa9aaa18..b8dc7fae 100644 --- a/lua/app/ui/shop/gift_pop_ui.lua +++ b/lua/app/ui/shop/gift_pop_ui.lua @@ -199,7 +199,7 @@ function GiftPopUI:onClickGift() if canGet then PayManager:purchasePackage(self.actId, self.actType) else - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = 1}) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = GConst.ShopConst.PAGE_TYPE.DISCOUNT}) self:closeUI() end else diff --git a/lua/app/ui/shop/shop_comp.lua b/lua/app/ui/shop/shop_comp.lua index 433a9a74..ea87956a 100644 --- a/lua/app/ui/shop/shop_comp.lua +++ b/lua/app/ui/shop/shop_comp.lua @@ -79,6 +79,42 @@ function ShopComp:switchPage(page) end end +function ShopComp:goSubType(subType) + local scrollRectObj = self.uiMap["shop_comp.main.scrollrect"] + local contentObj = self.uiMap["shop_comp.main.scrollrect.viewport.content"] + local boxHeight = 0 + if self.boxSellCell and self.boxSellCell:getIsOpen() then + boxHeight = self.boxSellCell:getCellHeight() + end + local hotHeight = 0 + if self.hotSellCell and self.hotSellCell:getIsOpen() then + hotHeight = self.hotSellCell:getCellHeight() + end + local gemHeight = 0 + if self.gemSellCell and self.gemSellCell:getIsOpen() then + gemHeight = self.gemSellCell:getCellHeight() + end + local goldHeight = 0 + if self.goldSellCell and self.goldSellCell:getIsOpen() then + goldHeight = self.goldSellCell:getCellHeight() + end + + Logger.logHighlight("goSubType -- %s %s %s %s %s %s %s %s", self.boxSellCell, boxHeight, self.hotSellCell, hotHeight, self.gemSellCell, gemHeight, self.goldSellCell, goldHeight) + + local maxHeight = math.min(boxHeight + hotHeight + gemHeight + goldHeight - scrollRectObj:fastGetSizeDeltaY()) + local height = 0 + if subType == GConst.ShopConst.MAIN_PAGE_TYPE.BOX then + -- 默认在开头 + elseif subType == GConst.ShopConst.MAIN_PAGE_TYPE.HOT then + height = height + boxHeight + elseif subType == GConst.ShopConst.MAIN_PAGE_TYPE.GEM then + height = height + boxHeight + hotHeight + elseif subType == GConst.ShopConst.MAIN_PAGE_TYPE.GOLD then + height = height + boxHeight + hotHeight + gemHeight + end + contentObj:setAnchoredPositionY(math.min(height, maxHeight)) +end + function ShopComp:initMainPage() self.mainNode = self.uiMap["shop_comp.main"] local scrollrect = self.uiMap["shop_comp.main.scrollrect"]