抽卡动画添加战令宝箱部分
This commit is contained in:
parent
0fc3edfe24
commit
a48651b348
@ -1,5 +1,19 @@
|
|||||||
local BoxOpenUI = class("BoxOpenUI", BaseUI)
|
local BoxOpenUI = class("BoxOpenUI", BaseUI)
|
||||||
local SPINE_OPEN_TIME = 1.4
|
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)
|
function BoxOpenUI:ctor(params)
|
||||||
self.params = params or {} -- 将信息传递给下一个界面
|
self.params = params or {} -- 将信息传递给下一个界面
|
||||||
@ -18,31 +32,32 @@ end
|
|||||||
function BoxOpenUI:onLoadRootComplete()
|
function BoxOpenUI:onLoadRootComplete()
|
||||||
self.uiMap = self.root:genAllChildren()
|
self.uiMap = self.root:genAllChildren()
|
||||||
self.bg = self.uiMap["box_open_ui.bg"]
|
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:addEventListener(EventManager.CUSTOM_EVENT.CLOSE_BOX_OPEN_UI, function()
|
||||||
self:closeUI()
|
self:closeUI()
|
||||||
end)
|
end)
|
||||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CLOSE_BOX_HERO_UI)
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CLOSE_BOX_HERO_UI)
|
||||||
-- 播放spine表现 播放完毕后打开奖励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
|
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
|
elseif self.type == GConst.ShopConst.BOX_REWARD_TYPE.BOUNTY then
|
||||||
-- TODOJ
|
spineName = BOUNTY_SPINE_NAME[self.index]
|
||||||
end
|
end
|
||||||
if not spineObj then
|
if not spineName then
|
||||||
spineObj = self.summonSpineList[1]
|
spineName = DEFAULT_SPINE_NAME
|
||||||
end
|
end
|
||||||
spineObj:setVisible(true)
|
self.spineObj:loadAssetAsync(spineName, function()
|
||||||
spineObj:playAnim("born", false, true)
|
self.spineObj:playAnim("born", false, true, true)
|
||||||
self:performWithDelayGlobal(function()
|
self.spineObj:getSkeletonGraphic().enabled = true
|
||||||
ModuleManager.ShopManager:showBoxRewardUI(self.params)
|
self:performWithDelayGlobal(function()
|
||||||
end, SPINE_OPEN_TIME)
|
ModuleManager.ShopManager:showBoxRewardUI(self.params)
|
||||||
|
end, SPINE_OPEN_TIME)
|
||||||
|
end, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
return BoxOpenUI
|
return BoxOpenUI
|
||||||
@ -107,6 +107,7 @@ function BoxRewardUI:onLoadRootComplete()
|
|||||||
self.rewardCells = self.rewardCells or {}
|
self.rewardCells = self.rewardCells or {}
|
||||||
local contentTrans = self.scrollRectContent:getTransform()
|
local contentTrans = self.scrollRectContent:getTransform()
|
||||||
local alreadyCellCount = contentTrans.childCount - 1
|
local alreadyCellCount = contentTrans.childCount - 1
|
||||||
|
local rewardCount = #self.fragmentRewards
|
||||||
if alreadyCellCount > 0 then
|
if alreadyCellCount > 0 then
|
||||||
for i = 1, alreadyCellCount do
|
for i = 1, alreadyCellCount do
|
||||||
local prefab = contentTrans:GetChild(i).gameObject
|
local prefab = contentTrans:GetChild(i).gameObject
|
||||||
@ -114,10 +115,18 @@ function BoxRewardUI:onLoadRootComplete()
|
|||||||
local prefabObject = UIPrefabObject:create()
|
local prefabObject = UIPrefabObject:create()
|
||||||
prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab)
|
prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab)
|
||||||
prefabObject:initPrefabHelper()
|
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))
|
table.insert(self.rewardCells, CellManager:addCellComp(prefabObject, BOX_HERO_CELL))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local rewardCount = #self.fragmentRewards
|
|
||||||
local cellCount = #self.rewardCells
|
local cellCount = #self.rewardCells
|
||||||
local needCreateCount = rewardCount - cellCount
|
local needCreateCount = rewardCount - cellCount
|
||||||
-- 将cell扩充至与奖励等数量
|
-- 将cell扩充至与奖励等数量
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user