血条动画
This commit is contained in:
parent
d836860db8
commit
e6015e7e8c
@ -1730,6 +1730,10 @@ function GFunc.getRewardType(reward)
|
||||
end
|
||||
end
|
||||
|
||||
function GFunc.DOBFSliderValue(slider, endValue, duration, snapping)
|
||||
return CS.BF.Utils.DOBFSliderValue(slider, endValue, duration, snapping)
|
||||
end
|
||||
|
||||
--[[
|
||||
设置tabLe只速 出现改写会抛出Lua error
|
||||
用法locaL readOnlyCfg = GFunc.readOnlyTab(cfg) return readOnlyCfg
|
||||
|
||||
@ -243,16 +243,19 @@ function BattleUnitComp:useSkill(index, count, callback)
|
||||
if self.normalSkillCount <= 0 then
|
||||
self.actionOverCallback = nil
|
||||
self.activeSkillIndex = nil
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
callback()
|
||||
return
|
||||
end
|
||||
if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then
|
||||
self.actionOverCallback = nil
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
callback()
|
||||
end
|
||||
else
|
||||
if not self:changeState(UNIT_STATE.SKILL_ATTACK) then
|
||||
self.actionOverCallback = nil
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
callback()
|
||||
end
|
||||
end
|
||||
@ -274,16 +277,19 @@ function BattleUnitComp:useAllSkills(callback)
|
||||
if self.currActiveSkill == nil then -- 没有技能就用普攻
|
||||
if self.normalSkillCount <= 0 then
|
||||
self.actionOverCallback = nil
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
callback()
|
||||
return
|
||||
end
|
||||
if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then
|
||||
self.actionOverCallback = nil
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
callback()
|
||||
end
|
||||
else
|
||||
if not self:changeState(UNIT_STATE.SKILL_ATTACK) then
|
||||
self.actionOverCallback = nil
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
callback()
|
||||
end
|
||||
end
|
||||
@ -294,6 +300,7 @@ function BattleUnitComp:useNormalSkill(count, callback)
|
||||
self.normalSkillCount = count + self.unitEntity:getNormalAttackAddCount()
|
||||
if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then
|
||||
self.actionOverCallback = nil
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
callback()
|
||||
end
|
||||
end
|
||||
@ -634,12 +641,37 @@ function BattleUnitComp:updateSkillAttack(dt)
|
||||
if self.normalSkillCount > 0 then
|
||||
local skill = self.unitEntity:getNormalSkill()
|
||||
self:onSkillTakeEffect(skill)
|
||||
if self.normalSkillCount == 1 and self.currActiveSkill == nil then -- 最后一次攻击
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
else
|
||||
self:onSkillTakeEffect(self.currActiveSkill)
|
||||
if not self:getIsHaveNextAvailableActiveSkill() then
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:getIsHaveNextAvailableActiveSkill()
|
||||
local skillCanUseTimes = self.currActiveSkill:getSkillCanUseTimes()
|
||||
if skillCanUseTimes and skillCanUseTimes > 0 then -- 当前技能可以多次使用
|
||||
return true
|
||||
elseif self.activeSkillIndex then
|
||||
local currActiveSkill = nil
|
||||
local activeSkillIndex = self.activeSkillIndex + 1
|
||||
local activeSkillCount = self.unitEntity:getActiveSkillCount()
|
||||
while activeSkillIndex <= activeSkillCount do
|
||||
currActiveSkill = self.unitEntity:getAvailableActiveSkill(activeSkillIndex)
|
||||
if currActiveSkill then
|
||||
return true
|
||||
end
|
||||
activeSkillIndex = activeSkillIndex + 1
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function BattleUnitComp:moveBackToInitPosition()
|
||||
self.isMove = true
|
||||
@ -763,6 +795,9 @@ function BattleUnitComp:updateNormalAttack(dt)
|
||||
self.currAttackKeyTime = 0
|
||||
local skill = self.unitEntity:getNormalSkill()
|
||||
self:onSkillTakeEffect(skill)
|
||||
if self.normalSkillCount == 1 then -- 如果是最后一次攻击,那么可以开始跑血条了
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -155,9 +155,13 @@ end
|
||||
|
||||
function BattleController:initBattleTeam()
|
||||
self.atkTeam = BattleTeam:create()
|
||||
self.atkTeam:init(BattleConst.SIDE_ATK)
|
||||
self.atkTeam:init(BattleConst.SIDE_ATK, self)
|
||||
self.defTeam = BattleTeam:create()
|
||||
self.defTeam:init(BattleConst.SIDE_DEF)
|
||||
self.defTeam:init(BattleConst.SIDE_DEF, self)
|
||||
end
|
||||
|
||||
function BattleController:setIsPauseHpProgress(value)
|
||||
self.battleUI:setIsPauseHpProgress(value)
|
||||
end
|
||||
|
||||
function BattleController:prepareFight()
|
||||
|
||||
@ -61,14 +61,12 @@ end
|
||||
|
||||
function BattleHelper:getEffectText(parent)
|
||||
if #self.battleEffectTextPool <= 0 then
|
||||
local prefab = CS.UnityEngine.Object.Instantiate(self.effectTextCache:getGameObject(), parent:getTransform(), false)
|
||||
local prefab = CS.UnityEngine.Object.Instantiate(self.effectTextCache:getGameObject())
|
||||
local prefabObject = UIPrefabObject:create()
|
||||
prefabObject:initWithPrefab(self.effectTextCache:getAssetPath(), prefab)
|
||||
prefabObject:initPrefabHelper()
|
||||
prefabObject:addUnloadCallback(function(obj)
|
||||
ResourceManager:unload(obj:getAssetPath())
|
||||
end)
|
||||
prefabObject:getTransform():SetAsLastSibling()
|
||||
prefabObject:setParent(parent, false)
|
||||
local comp = prefabObject:addLuaComponent(GConst.BattleConst.TYPEOF_LUA_COMP.BATTLE_NUMBER_COMPONENT)
|
||||
comp:setEnabled(true)
|
||||
return comp
|
||||
|
||||
@ -2,8 +2,9 @@ local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle"
|
||||
|
||||
local BattleTeam = class("BattleTeam")
|
||||
|
||||
function BattleTeam:init(side)
|
||||
function BattleTeam:init(side, battleController)
|
||||
self.side = side
|
||||
self.battleController = battleController
|
||||
self.unitList = {}
|
||||
self.unitMap = {}
|
||||
self.buffList = {}
|
||||
@ -53,6 +54,7 @@ function BattleTeam:useNormalSkill(matchType, count, callback)
|
||||
return callback()
|
||||
end
|
||||
self.mainUnit = unit
|
||||
self.battleController:setIsPauseHpProgress(true)
|
||||
unit:beforeAttack()
|
||||
unit:useNormalSkill(count, callback)
|
||||
end
|
||||
@ -68,6 +70,7 @@ function BattleTeam:useSkill(matchType, count, callback)
|
||||
return callback()
|
||||
end
|
||||
self.mainUnit = unit
|
||||
self.battleController:setIsPauseHpProgress(true)
|
||||
unit:beforeAttack()
|
||||
unit:useSkill(1, count, callback)
|
||||
end
|
||||
@ -94,6 +97,7 @@ function BattleTeam:useAssistingSkill(assistingList, callback)
|
||||
end
|
||||
|
||||
function BattleTeam:mainUnitUseAllSkills(callback)
|
||||
self.battleController:setIsPauseHpProgress(true)
|
||||
self.mainUnit:beforeAttack()
|
||||
self.mainUnit:useAllSkills(callback)
|
||||
end
|
||||
|
||||
@ -92,20 +92,149 @@ end
|
||||
function BattleUI:initHpNode()
|
||||
self.hpProgressLeft = self.uiMap["battle_ui.top_node.bg_l.atk_slider_green"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressRight = self.uiMap["battle_ui.top_node.bg_r.def_slider_red"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressLeft.value = 1
|
||||
self.hpProgressRight.value = 1
|
||||
self.hpProgressYellowLeft = self.uiMap["battle_ui.top_node.bg_l.atk_slider_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressYellowRight = self.uiMap["battle_ui.top_node.bg_r.def_slider_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressYellowLeft.value = 1
|
||||
self.hpProgressYellowRight.value = 1
|
||||
self.hpTextLeft = self.uiMap["battle_ui.top_node.atk_hp"]
|
||||
self.hpTextRight = self.uiMap["battle_ui.top_node.def_hp"]
|
||||
self.hpPercentLeft = 1
|
||||
self.hpPercentRight = 1
|
||||
end
|
||||
|
||||
function BattleUI:setIsPauseHpProgress(value)
|
||||
if self.isPauseHpProgress == value then
|
||||
return
|
||||
end
|
||||
self.isPauseHpProgress = value
|
||||
if not value then
|
||||
local timeLeft = math.abs(self.hpProgressYellowLeft.value - self.hpPercentLeft)
|
||||
if timeLeft > 0.01 then
|
||||
local delayTime = math.abs(self.hpProgressLeft.value - self.hpPercentLeft)*2
|
||||
if delayTime > 0.05 then
|
||||
if self.hpProgressYellowLeftSid then
|
||||
self:unscheduleGlobal(self.hpProgressYellowLeftSid)
|
||||
end
|
||||
self.hpProgressYellowLeftSid = self:performWithDelayGlobal(function()
|
||||
self:playHpProgressYellowRightTween(timeLeft)
|
||||
end, delayTime)
|
||||
else
|
||||
self:playHpProgressYellowRightTween(timeLeft)
|
||||
end
|
||||
else
|
||||
if self.hpProgressYellowLeftTween then
|
||||
self.hpProgressYellowLeftTween:Pause()
|
||||
end
|
||||
self.hpProgressYellowLeft.value = self.hpPercentLeft
|
||||
end
|
||||
local timeRight = math.abs(self.hpProgressYellowRight.value - self.hpPercentRight)
|
||||
if timeRight > 0.01 then
|
||||
local delayTime = math.abs(self.hpProgressRight.value - self.hpPercentRight)*2
|
||||
if delayTime > 0.05 then
|
||||
if self.hpProgressYellowRightSid then
|
||||
self:unscheduleGlobal(self.hpProgressYellowRightSid)
|
||||
end
|
||||
self.hpProgressYellowRightSid = self:performWithDelayGlobal(function()
|
||||
self:playHpProgressYellowRightTween(delayTime)
|
||||
end, delayTime)
|
||||
else
|
||||
self:playHpProgressYellowRightTween(delayTime)
|
||||
end
|
||||
else
|
||||
if self.hpProgressYellowRightTween then
|
||||
self.hpProgressYellowRightTween:Pause()
|
||||
end
|
||||
self.hpProgressYellowRight.value = self.hpPercentRight
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:playHpProgressYellowLeftTween(time)
|
||||
if self.hpProgressYellowLeftTween == nil then
|
||||
self.hpProgressYellowLeftTween = GFunc.DOBFSliderValue(self.hpProgressYellowLeft, self.hpPercentLeft, time, false)
|
||||
self.hpProgressYellowLeftTween:SetIntId(GConst.DOTWEEN_IDS.BATTLE)
|
||||
self.hpProgressYellowLeftTween:SetAutoKill(false)
|
||||
else
|
||||
self.hpProgressYellowLeftTween:ChangeEndValue(self.hpPercentLeft, time, true)
|
||||
self.hpProgressYellowLeftTween:Restart()
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:playHpProgressYellowRightTween(time)
|
||||
if self.hpProgressYellowRightTween == nil then
|
||||
self.hpProgressYellowRightTween = GFunc.DOBFSliderValue(self.hpProgressYellowRight, self.hpPercentRight, time, false)
|
||||
self.hpProgressYellowRightTween:SetIntId(GConst.DOTWEEN_IDS.BATTLE)
|
||||
self.hpProgressYellowRightTween:SetAutoKill(false)
|
||||
else
|
||||
self.hpProgressYellowRightTween:ChangeEndValue(self.hpPercentRight, time, true)
|
||||
self.hpProgressYellowRightTween:Restart()
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:refreshAtkHp(num, percent)
|
||||
self.hpTextLeft:setText(GFunc.num2Str(num))
|
||||
if not self.isPauseHpProgress then
|
||||
if self.hpProgressLeftTween then
|
||||
self.hpProgressLeftTween:Pause()
|
||||
end
|
||||
if self.hpProgressYellowLeftTween then
|
||||
self.hpProgressYellowLeftTween:Pause()
|
||||
end
|
||||
if self.hpProgressYellowLeftSid then
|
||||
self:unscheduleGlobal(self.hpProgressYellowLeftSid)
|
||||
self.hpProgressYellowLeftSid = nil
|
||||
end
|
||||
self.hpProgressLeft.value = percent
|
||||
self.hpProgressYellowLeft.value = percent
|
||||
return
|
||||
end
|
||||
if self.hpPercentLeft == percent then
|
||||
return
|
||||
end
|
||||
self.hpPercentLeft = percent
|
||||
local time = math.abs(self.hpProgressLeft.value - percent)*2
|
||||
if self.hpProgressLeftTween == nil then
|
||||
self.hpProgressLeftTween = GFunc.DOBFSliderValue(self.hpProgressLeft, percent, time, false)
|
||||
self.hpProgressLeftTween:SetIntId(GConst.DOTWEEN_IDS.BATTLE)
|
||||
self.hpProgressLeftTween:SetAutoKill(false)
|
||||
else
|
||||
self.hpProgressLeftTween:ChangeEndValue(percent, time, true)
|
||||
self.hpProgressLeftTween:Restart()
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:refreshDefHp(num, percent)
|
||||
self.hpTextRight:setText(GFunc.num2Str(num))
|
||||
if not self.isPauseHpProgress then
|
||||
if self.hpProgressRightTween then
|
||||
self.hpProgressrightTween:Pause()
|
||||
end
|
||||
if self.hpProgressYellowRightTween then
|
||||
self.hpProgressYellowRightTween:Pause()
|
||||
end
|
||||
if self.hpProgressYellowRightSid then
|
||||
self:unscheduleGlobal(self.hpProgressYellowRightSid)
|
||||
self.hpProgressYellowRightSid = nil
|
||||
end
|
||||
self.hpProgressRight.value = percent
|
||||
self.hpProgressYellowRight.value = percent
|
||||
return
|
||||
end
|
||||
if self.hpPercentRight == percent then
|
||||
return
|
||||
end
|
||||
self.hpPercentRight = percent
|
||||
local time = math.abs(self.hpProgressRight.value - percent)*2
|
||||
if self.hpProgressRightTween == nil then
|
||||
self.hpProgressRightTween = GFunc.DOBFSliderValue(self.hpProgressRight, percent, time, false)
|
||||
self.hpProgressRightTween:SetIntId(GConst.DOTWEEN_IDS.BATTLE)
|
||||
self.hpProgressRightTween:SetAutoKill(false)
|
||||
else
|
||||
self.hpProgressRightTween:ChangeEndValue(percent, time, true)
|
||||
self.hpProgressRightTween:Restart()
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:refreshSkill(elementMap)
|
||||
@ -545,6 +674,30 @@ function BattleUI:clear()
|
||||
if self.battleNode then
|
||||
self.battleNode:removeAllChildren()
|
||||
end
|
||||
if self.hpProgressYellowLeftSid then
|
||||
self:unscheduleGlobal(self.hpProgressYellowLeftSid)
|
||||
self.hpProgressYellowLeftSid = nil
|
||||
end
|
||||
if self.hpProgressYellowRightSid then
|
||||
self:unscheduleGlobal(self.hpProgressYellowRightSid)
|
||||
self.hpProgressYellowRightSid = nil
|
||||
end
|
||||
if self.hpProgressLeftTween then
|
||||
self.hpProgressLeftTween:Kill()
|
||||
self.hpProgressLeftTween = nil
|
||||
end
|
||||
if self.hpProgressYellowLeftTween then
|
||||
self.hpProgressYellowLeftTween:Kill()
|
||||
self.hpProgressYellowLeftTween = nil
|
||||
end
|
||||
if self.hpProgressRightTween then
|
||||
self.hpProgressRightTween:Kill()
|
||||
self.hpProgressRightTween = nil
|
||||
end
|
||||
if self.hpProgressYellowRightTween then
|
||||
self.hpProgressYellowRightTween:Kill()
|
||||
self.hpProgressYellowRightTween = nil
|
||||
end
|
||||
if self.battleNumberNode then
|
||||
self.battleNumberNode:removeAllChildren()
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user