战斗支持血量换皮肤
This commit is contained in:
parent
c11428b80b
commit
027809a5bd
@ -51,6 +51,13 @@ function CharacterSpineObject:refreshSkeletonDataAsset(dataAsset)
|
||||
self.characterSpineHelper:Reload()
|
||||
end
|
||||
|
||||
function CharacterSpineObject:setSkin(skinName)
|
||||
local skeletonGraphic = self:getSkeletonGraphic()
|
||||
skeletonGraphic.initialSkinName = skinName
|
||||
skeletonGraphic:Initialize(true)
|
||||
self.characterSpineHelper:Reload()
|
||||
end
|
||||
|
||||
function CharacterSpineObject:_genAllChildren()
|
||||
local childMap = {}
|
||||
if self.characterSpineHelper then
|
||||
|
||||
@ -694,6 +694,7 @@ function BattleUnitComp:exitIdleState()
|
||||
end
|
||||
|
||||
function BattleUnitComp:enterIdleState()
|
||||
self:refreshHpSkin()
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
||||
end
|
||||
|
||||
@ -1698,6 +1699,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
local delayTime = self.lastSameTimeHealCount * BattleConst.EFFECT_NUMBER_INTERVAL
|
||||
self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y, delayTime)
|
||||
end
|
||||
self:refreshHpSkin()
|
||||
local hpPercent = self.unitEntity:getHpPercent()
|
||||
self.battleController:refreshHp(self.side, hp, hpPercent)
|
||||
if not atker:getIsFinalBlock() or atker:getIsCentralizedAttack() then
|
||||
@ -1743,6 +1745,25 @@ function BattleUnitComp:showEffectNumber(colorType, effectType, num, x, y, delay
|
||||
self.battleController:showEffectNumber(colorType, effectType, num, x, y + addY, delayTime, showCombo)
|
||||
end
|
||||
|
||||
function BattleUnitComp:refreshHpSkin()
|
||||
if self.unitEntity:getHpSkinInfo() then
|
||||
local skin
|
||||
local hpp = self.unitEntity:getHpPercent() * DEFAULT_FACTOR
|
||||
for index, info in ipairs(self.unitEntity:getHpSkinInfo()) do
|
||||
if hpp <= info.hpp then
|
||||
skin = info.skin
|
||||
break
|
||||
end
|
||||
end
|
||||
if self.lastHpSkin == skin then
|
||||
return
|
||||
end
|
||||
self.lastHpSkin = skin
|
||||
Logger.logHighlight(skin)
|
||||
self.baseObject:setSkin(skin)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:playDead(callback)
|
||||
self.deadOverCallback = callback
|
||||
if self:getIsClear() then
|
||||
|
||||
@ -658,6 +658,8 @@ function BattleData:addMonster(monsterId, newTeam, battleController)
|
||||
isBoss = monsterInfo.is_boss,
|
||||
exp = monsterInfo.monster_exp or 0,
|
||||
body = monsterInfo.body,
|
||||
hpSkinHp = monsterInfo.monster_hp,
|
||||
hpSkinSkin = monsterInfo.monster_hp_skin,
|
||||
attr = {
|
||||
hp = hp,
|
||||
max_hp = hp,
|
||||
|
||||
@ -12,6 +12,7 @@ function BattleUnitEntity:init(unitData, side, team)
|
||||
self.damageCount = 0 -- 记录伤害
|
||||
self.healCount = 0 -- 记录治疗
|
||||
self.activeSkillReleaseCount = 0 -- 记录主动技能释放次数
|
||||
self.hpSkinInfo = nil
|
||||
self:initSkill()
|
||||
end
|
||||
|
||||
@ -429,6 +430,25 @@ function BattleUnitEntity:getAttrValue(attr)
|
||||
return self.team:getAttrValue(attr)
|
||||
end
|
||||
|
||||
function BattleUnitEntity:getHpSkinInfo()
|
||||
if not self.hpSkinInfo then
|
||||
if self.unitData.hpSkinHp and self.unitData.hpSkinSkin then
|
||||
self.hpSkinInfo = {}
|
||||
for index, v in pairs(self.unitData.hpSkinHp) do
|
||||
local skin = self.unitData.hpSkinSkin[index]
|
||||
if not skin then
|
||||
break
|
||||
end
|
||||
table.insert(self.hpSkinInfo, {hpp = v, skin = skin})
|
||||
end
|
||||
table.sort(self.hpSkinInfo, function(a, b)
|
||||
return a.hpp < b.hpp
|
||||
end)
|
||||
end
|
||||
end
|
||||
return self.hpSkinInfo
|
||||
end
|
||||
|
||||
function BattleUnitEntity:addSkillExtraUseTimes(skillId, count)
|
||||
if self.skillExtraUseTimes == nil then
|
||||
self.skillExtraUseTimes = {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user