From a48651b348a314004ae64a071851566afc36a1fe Mon Sep 17 00:00:00 2001 From: CloudJ Date: Sat, 3 Jun 2023 22:42:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E5=8A=A8=E7=94=BB=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=88=98=E4=BB=A4=E5=AE=9D=E7=AE=B1=E9=83=A8=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扩充至与奖励等数量