血量
This commit is contained in:
parent
93ee4653af
commit
c6ae8e7c99
@ -25,7 +25,7 @@ function BattleUnitComp:initPosition()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:playBorn()
|
function BattleUnitComp:playBorn()
|
||||||
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
self:changeState(UNIT_STATE.IDLE)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:_initBase()
|
function BattleUnitComp:_initBase()
|
||||||
@ -361,8 +361,7 @@ function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectSta
|
|||||||
end
|
end
|
||||||
local x, y, z = self.baseObject:fastGetLocalPosition()
|
local x, y, z = self.baseObject:fastGetLocalPosition()
|
||||||
self:showEffectNumber(num, x, y)
|
self:showEffectNumber(num, x, y)
|
||||||
local hpPercent = self.unitEntity:getHpPercent()
|
self.battleController:refreshHp(self.side, self.unitEntity:getHp(), self.unitEntity:getHpPercent())
|
||||||
-- self.controlUnitComp:RefreshHpBar(hpPercent)
|
|
||||||
|
|
||||||
-- local shieldHp = self.unitEntity:getShieldHp()
|
-- local shieldHp = self.unitEntity:getShieldHp()
|
||||||
-- if shieldHp and shieldHp.value > 0 then
|
-- if shieldHp and shieldHp.value > 0 then
|
||||||
|
|||||||
@ -164,6 +164,7 @@ function BattleController:initAtkUnits(callback)
|
|||||||
local function onloadFinished()
|
local function onloadFinished()
|
||||||
count = count + 1
|
count = count + 1
|
||||||
if count == totalCount then
|
if count == totalCount then
|
||||||
|
self.battleUI:refreshAtkHp(atkTeam:getHp(), atkTeam:getHpPercent())
|
||||||
callback()
|
callback()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -186,6 +187,14 @@ function BattleController:initAtkUnits(callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleController:refreshHp(side, num, percent)
|
||||||
|
if side == BattleConst.SIDE_ATK then
|
||||||
|
self.battleUI:refreshAtkHp(num, percent)
|
||||||
|
else
|
||||||
|
self.battleUI:refreshDefHp(num, percent)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function BattleController:getOtherSideMainUnit(side)
|
function BattleController:getOtherSideMainUnit(side)
|
||||||
if side == BattleConst.SIDE_ATK then
|
if side == BattleConst.SIDE_ATK then
|
||||||
return self.defMainUnit
|
return self.defMainUnit
|
||||||
|
|||||||
@ -23,6 +23,7 @@ function BattleControllerStage:initDefUnits(callback)
|
|||||||
self.defUnits[unitEntity:getMatchType()] = monsterComp
|
self.defUnits[unitEntity:getMatchType()] = monsterComp
|
||||||
table.insert(self.allUnits, monsterComp)
|
table.insert(self.allUnits, monsterComp)
|
||||||
self.defMainUnit = monsterComp
|
self.defMainUnit = monsterComp
|
||||||
|
self.battleUI:refreshDefHp(unitEntity:getHp(), unitEntity:getHpPercent())
|
||||||
callback()
|
callback()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -36,6 +36,7 @@ function BattleUI:_display()
|
|||||||
self:initSkill()
|
self:initSkill()
|
||||||
self:initBattlefield()
|
self:initBattlefield()
|
||||||
self:initNumberNode()
|
self:initNumberNode()
|
||||||
|
self:initHpNode()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUI:_addListeners()
|
function BattleUI:_addListeners()
|
||||||
@ -88,6 +89,24 @@ function BattleUI:getBattleNumber()
|
|||||||
return self.battleNumber
|
return self.battleNumber
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUI:initHpNode()
|
||||||
|
self.hpNode = self.uiMap["battle_ui.battle_hp_node"]
|
||||||
|
self.hpProgressLeft = self.uiMap["battle_ui.battle_hp_node.progress_left"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
self.hpProgressRight = self.uiMap["battle_ui.battle_hp_node.progress_right"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
self.hpTextRight = self.uiMap["battle_ui.battle_hp_node.text_right"]
|
||||||
|
self.hpTextLeft = self.uiMap["battle_ui.battle_hp_node.text_left"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:refreshAtkHp(num, percent)
|
||||||
|
self.hpTextLeft:setText(GFunc.num2Str(num))
|
||||||
|
self.hpProgressLeft.value = percent
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:refreshDefHp(num, percent)
|
||||||
|
self.hpTextRight:setText(GFunc.num2Str(num))
|
||||||
|
self.hpProgressRight.value = percent
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUI:refreshSkill(elementMap)
|
function BattleUI:refreshSkill(elementMap)
|
||||||
if not self.skillObjs then
|
if not self.skillObjs then
|
||||||
return
|
return
|
||||||
|
|||||||
@ -113,6 +113,10 @@ function BattleTeamEntity:getMembersCount()
|
|||||||
return self.membersCount
|
return self.membersCount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleTeamEntity:getHp()
|
||||||
|
return self.attr.hp
|
||||||
|
end
|
||||||
|
|
||||||
function BattleTeamEntity:getHpPercent()
|
function BattleTeamEntity:getHpPercent()
|
||||||
return self.attr.hp / self.attr.max_hp
|
return self.attr.hp / self.attr.max_hp
|
||||||
end
|
end
|
||||||
@ -174,6 +178,9 @@ function BattleTeamEntity:addShield(num)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleTeamEntity:takeDamageOrCure(num)
|
function BattleTeamEntity:takeDamageOrCure(num)
|
||||||
|
if self.isDead then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
if num < 0 then -- 是伤害的话处理一下护盾
|
if num < 0 then -- 是伤害的话处理一下护盾
|
||||||
num = self:handleShield(num)
|
num = self:handleShield(num)
|
||||||
if num >= 0 then -- 这次伤害被抵消了
|
if num >= 0 then -- 这次伤害被抵消了
|
||||||
@ -185,6 +192,7 @@ function BattleTeamEntity:takeDamageOrCure(num)
|
|||||||
local hurtEventNum = 0
|
local hurtEventNum = 0
|
||||||
if self.attr.hp <= 0 then -- 死了
|
if self.attr.hp <= 0 then -- 死了
|
||||||
hurtEventNum = -hpBefore
|
hurtEventNum = -hpBefore
|
||||||
|
self.attr.hp = 0
|
||||||
self:die()
|
self:die()
|
||||||
elseif self.attr.hp < self.attr.max_hp then
|
elseif self.attr.hp < self.attr.max_hp then
|
||||||
hurtEventNum = num
|
hurtEventNum = num
|
||||||
|
|||||||
@ -57,6 +57,10 @@ function BattleUnitEntity:takeDamageOrCure(num)
|
|||||||
return self.team:takeDamageOrCure(num)
|
return self.team:takeDamageOrCure(num)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUnitEntity:getHp()
|
||||||
|
return self.team:getHp()
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUnitEntity:getHpPercent()
|
function BattleUnitEntity:getHpPercent()
|
||||||
return self.team:getHpPercent()
|
return self.team:getHpPercent()
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user