boss入场动画

This commit is contained in:
xiekaidong 2023-05-30 17:42:02 +08:00
parent b6fc8538a2
commit b7614062f0
3 changed files with 62 additions and 12 deletions

View File

@ -51,6 +51,37 @@ function UISpineObject:playAnim(animName, loop, forceRefresh, forceGetSG)
end
end
function UISpineObject:getAnimationKeyFrameTime(animName)
if not self.animationKeyFrameTime then
self.animationKeyFrameTime = {}
end
local timeList = self.animationKeyFrameTime[animName]
if not timeList then
timeList = {}
self.animationKeyFrameTime[animName] = timeList
if not self.uiSpineHelper then
self.uiSpineHelper = self:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_UI_SPINE_HELPER)
if self.uiSpineHelper == nil then
self.uiSpineHelper = self:addComponent(GConst.TYPEOF_UNITY_CLASS.BF_UI_SPINE_HELPER)
end
end
local list = self.uiSpineHelper:GetAnimationKeyFrameTime(animName)
local count = list.Count
if count > 0 then
for i = 1, count do
table.insert(timeList, list[i - 1])
end
end
end
return timeList
end
function UISpineObject:clearAnimationKeyFrameTime()
for aniName, _ in pairs(self.animationKeyFrameTime) do
self.animationKeyFrameTime[aniName] = nil
end
end
--未验证TODO
function UISpineObject:rePlayAnim(animName, loop, forceRefresh)
self:getAnimationState()

View File

@ -148,6 +148,7 @@ GConst.TYPEOF_UNITY_CLASS = {
BF_UI_ERASER_TEXTURE = typeof(CS.BF.UIEraserTexture),
BF_UNITY_SLIDER = typeof(CS.BF.BFUnitySlider),
BF_ELIMINATION_TOUCH_EVENT = typeof(CS.BF.EliminationTouchEvent),
BF_UI_SPINE_HELPER = typeof(CS.BF.UISpineHelper),
}
-- lua 组件

View File

@ -15,6 +15,7 @@ local CacheVector2 = CS.UnityEngine.Vector2(0, 0)
local CACHE_SKILL_POS_1 = {x = 10, y = 360}
local CACHE_SKILL_POS_2 = {x = 10, y = 420}
local BATTLE_COMMON_PATH = "assets/arts/textures/background/battle_common/%s.png"
local BOARD_SFX_ORDER = 13
function BattleUI:getPrefabPath()
return "assets/prefabs/ui/battle/battle_ui.prefab"
@ -1562,7 +1563,7 @@ function BattleUI:getSfxLine(index, func)
self.root.lineSfxObjs[index] = {
isLoaded = true
}
EffectManager:loadUIEffectAsync(GConst.BattleConst.LINE_SFX, self, self.gridNode, 11, function(obj)
EffectManager:loadUIEffectAsync(GConst.BattleConst.LINE_SFX, self, self.gridNode, BOARD_SFX_ORDER, function(obj)
self.root.lineSfxObjs[index].obj = obj
if self.hidingAllSfxLine then
obj:setActive(false)
@ -1653,7 +1654,7 @@ function BattleUI:getSfxSmoke(index, func)
self.root.smokeSfxObjs[index] = {
isLoaded = true
}
EffectManager:loadUIEffectAsync(GConst.BattleConst.LINK_SMOKE, self, self.gridNode, 11, function(obj)
EffectManager:loadUIEffectAsync(GConst.BattleConst.LINK_SMOKE, self, self.gridNode, BOARD_SFX_ORDER, function(obj)
self.root.smokeSfxObjs[index].obj = obj
obj:setLocalScale(1.5, 1.5, 1.5)
if self.hidingAllSfxSmoke then
@ -1843,7 +1844,7 @@ function BattleUI:initUISfxs()
for index, info in pairs(self.root.lineSfxObjs) do
if info.obj then
info.obj:setActive(true)
info.obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), 11)
info.obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), BOARD_SFX_ORDER)
info.obj:setActive(false)
end
end
@ -1853,7 +1854,7 @@ function BattleUI:initUISfxs()
for index, info in pairs(self.root.smokeSfxObjs) do
if info.obj then
info.obj:setActive(true)
info.obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), 11)
info.obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), BOARD_SFX_ORDER)
info.obj:setActive(false)
end
end
@ -2035,7 +2036,7 @@ end
function BattleUI:initBossEnterAni()
local uiMap = self.root:genAllChildren()
self.bossEnterNode = uiMap["battle_ui.bg_2.boss_enter_node"]
self.bossEnterImg = uiMap["battle_ui.bg_2.boss_enter_node.img"]
self.bossEnterImg = uiMap["battle_ui.bg_2.boss_enter_node.ui_spine_obj"]
self.bossName = uiMap["battle_ui.bg_2.boss_enter_node.boss_name"]
self.bossEnterNodeCanvasGroup = self.bossEnterNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
self.bossEnterNode:setVisible(false)
@ -2051,9 +2052,15 @@ function BattleUI:showBossEnterAni(bornTime, bossName, monsterComp, callback)
end
self.bossEnterNode:setVisible(true)
self.bossEnterImg:setVisible(false)
self.bossName:setText(GConst.EMPTY_STRING)
self.bossName:setText(bossName)
self.bossName:setAnchoredPositionX(-800)
self.bossEnterNodeCanvasGroup.alpha = 0
monsterComp:getBaseObject():setLocalPosition(DEFAULT_X, 0, 0)
local keyFrameTimes = self.bossEnterImg:getAnimationKeyFrameTime("idle")
local keyFrameTime = 0
if keyFrameTimes then
keyFrameTime = keyFrameTimes[1] or 0
end
if self.bossEnterAniSeq then
self.bossEnterAniSeq:Kill()
self.bossEnterAniSeq = nil
@ -2062,23 +2069,34 @@ function BattleUI:showBossEnterAni(bornTime, bossName, monsterComp, callback)
self.bossEnterAniSeq:Append(self.bossEnterNodeCanvasGroup:DOFade(1, 0.2))
self.bossEnterAniSeq:AppendCallback(function()
self.bossEnterImg:setVisible(true)
self.bossEnterImg:playAnim("idle", false, true)
monsterComp:initPosition()
monsterComp:getBaseObject():setParent(self.maxLayerNode, false)
if callback then
callback()
end
self.battleController:showBuffTips(GConst.BattleConst.SIDE_DEF, true)
end)
self.bossEnterAniSeq:AppendInterval(bornTime)
self.bossEnterAniSeq:AppendCallback(function()
self.bossName:setText(bossName)
end)
self.bossEnterAniSeq:AppendInterval(0.5)
self.bossEnterAniSeq:AppendInterval(2)
self.bossEnterAniSeq:Append(self.bossEnterNodeCanvasGroup:DOFade(0, 0.2))
self.bossEnterAniSeq:AppendCallback(function()
monsterComp:getBaseObject():setParent(self:getBattleNode(), false)
self.bossEnterNode:setVisible(false)
self.battleController:showBuffTips(GConst.BattleConst.SIDE_DEF, true)
end)
if keyFrameTime > 0 then
local addTime = 1
self.bossEnterAniSeq:InsertCallback(keyFrameTime + 0.2, function()
self.bossName:setText(bossName)
self.battleController:setTimeScale(0)
end)
self.bossEnterAniSeq:Insert(keyFrameTime + 0.2, self.bossName:getTransform():DOAnchorPosX(-212, 0.2))
self.bossEnterAniSeq:InsertCallback(keyFrameTime + 0.2 + addTime, function()
self.battleController:setTimeScale(DataManager.BattleData:getTimeScale())
end)
else
self.bossEnterAniSeq:Insert(0.2, self.bossName:getTransform():DOAnchorPosX(-212, 0.2))
end
end
function BattleUI:clear()