格挡动作表现、反击界面表现

This commit is contained in:
xiekaidong 2023-05-23 16:39:29 +08:00
parent 1e6e99de9a
commit 637264f383
8 changed files with 96 additions and 22 deletions

View File

@ -1,5 +1,7 @@
local LocalizationGlobalConst =
{
COUNTER_ATTACK_DESC = "COUNTER_ATTACK_DESC",
BLOCK_DESC = "BLOCK_DESC",
MAIN_BTN_1 = "MAIN_BTN_1",
QLT_DESC_1 = "QLT_DESC_1",
QLT_DESC_2 = "QLT_DESC_2",

View File

@ -118,6 +118,9 @@ local localization_global =
["BTN_READ"] = "读取",
["BATTLE_DESC_9"] = "{0}攻击力:<color=#ffffff>{1}</color>",
["BATTLE_DESC_10"] = "已激活效果",
["BLOCK_DESC"] = "格挡",
["COUNTER_ATTACK_DESC"] = "反击",
}
return localization_global

View File

@ -31,6 +31,7 @@ BattleConst.EFFECT_COLOR_RED = 1
BattleConst.EFFECT_COLOR_GREEN = 2
BattleConst.EFFECT_COLOR_BLUE = 3
BattleConst.EFFECT_COLOR_WHILTE = 4
BattleConst.EFFECT_COLOR_SPECIAL = 5
BattleConst.EFFECT_TYPE_MOVE_L = 1
BattleConst.EFFECT_TYPE_MOVE_R = 2
BattleConst.EFFECT_TYPE_CRIT = 3
@ -179,6 +180,7 @@ BattleConst.SPINE_ANIMATION_NAME = {
DEAD = "death",
BORN = "born",
OUT = "out",
BLOCK = "block",
}
BattleConst.EFFECT_TYPE = {

View File

@ -5,6 +5,9 @@ function BattleNumberComp:init()
local uiMap = self.baseObject:genAllChildren()
self.animator = self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
self.effectText = uiMap["battle_number.text_number"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT)
if not self.effectText then
self.effectText = uiMap["battle_number.text_number"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
end
self.time = 0
end

View File

@ -86,7 +86,7 @@ function BattleUnitComp:_initBase()
self.currAttackBlockIndex = 0 -- 多段伤害索引
self.validEffectIdx = {}
self.switchTime = 0
self.isPlayHurt = 0
self.playIdleSubAniDuration = {}
self.attackDurationMap = {}
self.attackKeyFrameTimeMap = {}
self.shieldBuffList = {}
@ -227,11 +227,6 @@ function BattleUnitComp:stopRunAction()
end
function BattleUnitComp:playAnimation(name, loop, forceRefresh)
if name == SPINE_ANIMATION_NAME.HIT then
self.isPlayHurt = 1
else
self.isPlayHurt = 0
end
self.currAnimationName = name
self.baseObject:playAnimation(name, loop, forceRefresh)
end
@ -651,28 +646,58 @@ function BattleUnitComp:enterIdleState()
end
function BattleUnitComp:updateIdle(dt)
self:updateHurt(dt)
self:updateIdleSubAni(dt)
end
function BattleUnitComp:updateIdleSubAni(...)
if not self.currAnimationName then
return
end
if self.currAnimationName == SPINE_ANIMATION_NAME.HIT then
self:updateHurt(...)
elseif self.currAnimationName == SPINE_ANIMATION_NAME.BLOCK then
self:updateBlock(...)
end
end
function BattleUnitComp:playHurt()
self.hurtTime = 0
if self.currHitDuration == nil then
self.currHitDuration = self:getAnimationDuration(SPINE_ANIMATION_NAME.HIT)
local name = SPINE_ANIMATION_NAME.HIT
self.playIdleSubAniTime = 0
if self.playIdleSubAniDuration[name] == nil then
self.playIdleSubAniDuration[name] = self:getAnimationDuration(name)
end
self:playAnimation(SPINE_ANIMATION_NAME.HIT, false, false)
self:playAnimation(name, false, false)
end
function BattleUnitComp:updateHurt(dt)
if self.isPlayHurt == 0 then
return
self.playIdleSubAniTime = self.playIdleSubAniTime + dt
if self.playIdleSubAniTime >= self.playIdleSubAniDuration[SPINE_ANIMATION_NAME.HIT] then
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
end
if self.isPlayHurt == 1 then
self.hurtTime = self.hurtTime + dt
if self.hurtTime >= self.currHitDuration then
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
self.isPlayHurt = 0
end
end
function BattleUnitComp:playBlock()
local name = SPINE_ANIMATION_NAME.BLOCK
self.playIdleSubAniTime = 0
if self.playIdleSubAniDuration[name] == nil then
self.playIdleSubAniDuration[name] = self:getAnimationDuration(name)
end
self:playAnimation(name, false, false)
local direction = BattleConst.EFFECT_TYPE_MOVE_R
local x, y = self.baseObject:fastGetLocalPosition()
if self.side == BattleConst.SIDE_ATK then
direction = BattleConst.EFFECT_TYPE_MOVE_L
end
self:showEffectNumber(BattleConst.EFFECT_COLOR_SPECIAL, direction, I18N:getGlobalText(I18N.GlobalConst.BLOCK_DESC), x, y, 0)
end
function BattleUnitComp:updateBlock(dt)
self.playIdleSubAniTime = self.playIdleSubAniTime + dt
if self.playIdleSubAniTime >= self.playIdleSubAniDuration[SPINE_ANIMATION_NAME.BLOCK] then
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
end
end
@ -1210,6 +1235,7 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx)
local block = target.unitEntity:getBlock()
if block > 0 then
if BattleHelper:random(1, DEFAULT_FACTOR) <= block then -- 格挡成功
target:playBlock()
return
end
end
@ -1446,6 +1472,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
local counterattack = self.unitEntity:getCounterAttack()
if counterattack > DEFAULT_FACTOR or BattleHelper:random(1, DEFAULT_FACTOR) <= counterattack then -- 通过命中概率
self.unitEntity:addCounterAttackCount(1)
self.battleController:showCounterAttack(self.unitEntity:getCounterAttackCount(), self.side)
end
end
end

View File

@ -282,6 +282,14 @@ function BattleController:hideCombo()
self.battleUI:hideCombo()
end
function BattleController:showCounterAttack(count, side)
self.battleUI:showCounterAttack(count, side)
end
function BattleController:hideCounterAttack()
self.battleUI:hideCounterAttack()
end
function BattleController:prepareFight()
local count = 0
local totalCount = 3
@ -298,7 +306,8 @@ function BattleController:prepareFight()
BattleHelper:setEffectTextCache(self.battleUI:getBattleNumberRed(),
self.battleUI:getBattleNumberGreen(),
self.battleUI:getBattleNumberBlue(),
self.battleUI:getBattleNumberWhite())
self.battleUI:getBattleNumberWhite(),
self.battleUI:getBattleNumberSpecial())
self:initAtkUnits(onPreloadFinished)
self:initDefUnits(onPreloadFinished)
self.battleUI:refreshChessBoard(self:getChessBoardBgName())
@ -578,6 +587,7 @@ function BattleController:enterNextTeamAction()
self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_TEAM_ACTION_OVER
self:hideCombo()
self:hideCounterAttack()
if self:checkTeamIsDead(function() self:enterRoundEnd() end) then
return

View File

@ -176,7 +176,7 @@ function BattleHelper:addSpineBoneFollowerGraphic(effectObj)
return boneFollower
end
function BattleHelper:setEffectTextCache(cache1, cache2, cache3, cache4)
function BattleHelper:setEffectTextCache(cache1, cache2, cache3, cache4, cache5)
if self.effectTextCacheList == nil then
self.effectTextCacheList = {}
end
@ -184,6 +184,7 @@ function BattleHelper:setEffectTextCache(cache1, cache2, cache3, cache4)
self.effectTextCacheList[2] = cache2
self.effectTextCacheList[3] = cache3
self.effectTextCacheList[4] = cache4
self.effectTextCacheList[5] = cache5
end
function BattleHelper:getEffectText(parent, colorType)

View File

@ -67,6 +67,7 @@ function BattleUI:_display()
self:initSelectSkillNode()
self:initCommonSkillDescTips()
self:initBossEnterAni()
self:initCounterAttack()
end
function BattleUI:_addListeners()
@ -385,6 +386,7 @@ function BattleUI:initNumberNode()
self.battleNumberGreen = self.uiMap["battle_ui.cache_node.battle_number_green"]
self.battleNumberBlue = self.uiMap["battle_ui.cache_node.battle_number_blue"]
self.battleNumberWhite = self.uiMap["battle_ui.cache_node.battle_number_white"]
self.battleNumberSpecial = self.uiMap["battle_ui.cache_node.battle_number_special"]
end
function BattleUI:getNumberNode()
@ -407,6 +409,10 @@ function BattleUI:getBattleNumberWhite()
return self.battleNumberWhite
end
function BattleUI:getBattleNumberSpecial()
return self.battleNumberSpecial
end
function BattleUI:initComboNode()
self.comboNode = self.uiMap["battle_ui.top_node.combo"]
self.comboAnimator = self.comboNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
@ -521,6 +527,26 @@ function BattleUI:showCombo(count)
end
end
function BattleUI:initCounterAttack()
self.counterAttackNode = self.uiMap["battle_ui.battle_root.battle_number_node.counter_attack"]
self.counterTx = self.uiMap["battle_ui.battle_root.battle_number_node.counter_attack.text_number"]
self.counterAttackNode:setVisible(false)
end
function BattleUI:showCounterAttack(count, side)
local x = 280
if side == GConst.BattleConst.SIDE_ATK then
x = -280
end
self.counterAttackNode:setAnchoredPositionX(x)
self.counterTx:setText(I18N:getGlobalText(I18N.GlobalConst.COUNTER_ATTACK_DESC) .. "+" .. count)
self.counterAttackNode:setVisible(true)
end
function BattleUI:hideCounterAttack()
self.counterAttackNode:setVisible(false)
end
function BattleUI:initFxNode()
self.fxNode = self.uiMap["battle_ui.battle_root.batttle_fx_node"]
end