buff显示逻辑
This commit is contained in:
parent
1fad0b8c47
commit
a6b3df378f
@ -7,18 +7,10 @@ local GAME_RES_WHITE_LIST = {
|
|||||||
GConst.ATLAS_PATH.COMMON,
|
GConst.ATLAS_PATH.COMMON,
|
||||||
-- icon
|
-- icon
|
||||||
GConst.ATLAS_PATH.ICON_SKILL,
|
GConst.ATLAS_PATH.ICON_SKILL,
|
||||||
|
GConst.ATLAS_PATH.ICON_SKILL_ROGUE,
|
||||||
GConst.ATLAS_PATH.ICON_ITEM,
|
GConst.ATLAS_PATH.ICON_ITEM,
|
||||||
GConst.ATLAS_PATH.ICON_EQUIP,
|
GConst.ATLAS_PATH.ICON_HERO,
|
||||||
GConst.ATLAS_PATH.ICON_AVATAR,
|
GConst.ATLAS_PATH.ICON_BUFF,
|
||||||
GConst.ATLAS_PATH.ICON_RUNE,
|
|
||||||
GConst.ATLAS_PATH.ICON_LEGACY,
|
|
||||||
-- hero
|
|
||||||
GConst.SPINE_ASSET_PATH.P0001,
|
|
||||||
GConst.SPINE_ASSET_PATH.P0002,
|
|
||||||
GConst.SPINE_ASSET_PATH.P0003,
|
|
||||||
GConst.SPINE_ASSET_PATH.P0004,
|
|
||||||
-- 战斗伤害字体
|
|
||||||
"assets/arts/fonts/tmpfonts/battle/font_battle_sdf.asset",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
---- 预加载游戏资源
|
---- 预加载游戏资源
|
||||||
|
|||||||
@ -175,6 +175,7 @@ GConst.ATLAS_PATH = {
|
|||||||
ICON_SKILL = "assets/arts/atlas/icon/skill.asset",
|
ICON_SKILL = "assets/arts/atlas/icon/skill.asset",
|
||||||
ICON_HERO = "assets/arts/atlas/icon/hero.asset",
|
ICON_HERO = "assets/arts/atlas/icon/hero.asset",
|
||||||
ICON_SKILL_ROGUE = "assets/arts/atlas/icon/skill_rogue.asset",
|
ICON_SKILL_ROGUE = "assets/arts/atlas/icon/skill_rogue.asset",
|
||||||
|
ICON_BUFF = "assets/arts/atlas/icon/buff.asset",
|
||||||
}
|
}
|
||||||
|
|
||||||
GConst.TOUCH_EVENT = {
|
GConst.TOUCH_EVENT = {
|
||||||
|
|||||||
@ -477,6 +477,7 @@ function BattleUnitComp:exitDeadState()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:enterDeadState()
|
function BattleUnitComp:enterDeadState()
|
||||||
|
self:removeAllBuff()
|
||||||
local aniName = SPINE_ANIMATION_NAME.DEAD
|
local aniName = SPINE_ANIMATION_NAME.DEAD
|
||||||
self.deadTime = self:getAnimationDuration(aniName) + 0.1
|
self.deadTime = self:getAnimationDuration(aniName) + 0.1
|
||||||
self:playAnimation(aniName, false, false)
|
self:playAnimation(aniName, false, false)
|
||||||
@ -915,6 +916,10 @@ function BattleUnitComp:updateBuffState(buff, num)
|
|||||||
self.team:updateBuffState(buff, num)
|
self.team:updateBuffState(buff, num)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:removeAllBuff()
|
||||||
|
self.team:removeAllBuff()
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUnitComp:onSkillTakeEffect(skill)
|
function BattleUnitComp:onSkillTakeEffect(skill)
|
||||||
skill:endUse()
|
skill:endUse()
|
||||||
local effectList = skill:getEffectList()
|
local effectList = skill:getEffectList()
|
||||||
|
|||||||
@ -183,6 +183,14 @@ function BattleController:moveBattlefield(time)
|
|||||||
self.battleUI:moveBattlefield(time)
|
self.battleUI:moveBattlefield(time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleController:refreshBuff(side, buffList)
|
||||||
|
self.battleUI:refreshBuff(side, buffList)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleController:clearBuff(side)
|
||||||
|
self.battleUI:clearBuff(side)
|
||||||
|
end
|
||||||
|
|
||||||
function BattleController:prepareFight()
|
function BattleController:prepareFight()
|
||||||
local count = 0
|
local count = 0
|
||||||
local totalCount = 3
|
local totalCount = 3
|
||||||
|
|||||||
@ -156,6 +156,7 @@ function BattleTeam:handleShield(reduceShield, unit)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local needReedRefreshBuff = false
|
||||||
local shieldNum = 0
|
local shieldNum = 0
|
||||||
local currShieldBuff = self.shieldBuffList[1]
|
local currShieldBuff = self.shieldBuffList[1]
|
||||||
while currShieldBuff do
|
while currShieldBuff do
|
||||||
@ -170,6 +171,9 @@ function BattleTeam:handleShield(reduceShield, unit)
|
|||||||
currShieldBuff.result = 0
|
currShieldBuff.result = 0
|
||||||
for k, v in ipairs(self.buffList) do
|
for k, v in ipairs(self.buffList) do
|
||||||
if v == currShieldBuff then
|
if v == currShieldBuff then
|
||||||
|
if not needReedRefreshBuff and currShieldBuff.buff:getIcon() then
|
||||||
|
needReedRefreshBuff = true
|
||||||
|
end
|
||||||
self:updateBuffState(currShieldBuff.buff, -1)
|
self:updateBuffState(currShieldBuff.buff, -1)
|
||||||
BattleBuffHandle.removeBuff(unit, currShieldBuff)
|
BattleBuffHandle.removeBuff(unit, currShieldBuff)
|
||||||
currShieldBuff = nil
|
currShieldBuff = nil
|
||||||
@ -182,11 +186,31 @@ function BattleTeam:handleShield(reduceShield, unit)
|
|||||||
end
|
end
|
||||||
currShieldBuff = self.shieldBuffList[1]
|
currShieldBuff = self.shieldBuffList[1]
|
||||||
end
|
end
|
||||||
|
if needReedRefreshBuff then
|
||||||
|
self.battleController:refreshBuff(self.side, self.buffList)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleTeam:addBuff(buffEffect)
|
function BattleTeam:addBuff(buffEffect)
|
||||||
table.insert(self.buffList, buffEffect)
|
table.insert(self.buffList, buffEffect)
|
||||||
self:updateBuffState(buffEffect.buff, 1)
|
self:updateBuffState(buffEffect.buff, 1)
|
||||||
|
if buffEffect.buff:getIcon() then
|
||||||
|
self.battleController:refreshBuff(self.side, self.buffList)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleTeam:removeAllBuff()
|
||||||
|
local buffEffect = nil
|
||||||
|
local count = #self.buffList
|
||||||
|
for i = count, 1, -1 do
|
||||||
|
buffEffect = self.buffList[i]
|
||||||
|
if buffEffect then
|
||||||
|
self:updateBuffState(buffEffect.buff, -1)
|
||||||
|
table.remove(self.buffList, i)
|
||||||
|
BattleBuffHandle.removeBuff(self, buffEffect)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.battleController:clearBuff(self.side)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleTeam:doBuffWork()
|
function BattleTeam:doBuffWork()
|
||||||
@ -205,6 +229,7 @@ function BattleTeam:doBuffWork()
|
|||||||
BattleBuffHandle.removeBuff(self.mainUnit, buffEffect)
|
BattleBuffHandle.removeBuff(self.mainUnit, buffEffect)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.battleController:refreshBuff(self.side, self.buffList)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleTeam:updateBuffState(buff, num)
|
function BattleTeam:updateBuffState(buff, num)
|
||||||
|
|||||||
@ -34,6 +34,7 @@ function BattleUI:_display()
|
|||||||
self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"]
|
self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"]
|
||||||
self:initBg()
|
self:initBg()
|
||||||
self:initSkill()
|
self:initSkill()
|
||||||
|
self:initBuff()
|
||||||
self:initBattlefield()
|
self:initBattlefield()
|
||||||
self:initNumberNode()
|
self:initNumberNode()
|
||||||
self:initHpNode()
|
self:initHpNode()
|
||||||
@ -101,6 +102,117 @@ function BattleUI:initSkill()
|
|||||||
uiMap["battle_ui.bg_2.skill_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
|
uiMap["battle_ui.bg_2.skill_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUI:initBuff()
|
||||||
|
self.atkBuffIconList = {
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.buff_1"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.buff_2"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.buff_3"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.buff_4"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.buff_5"],
|
||||||
|
}
|
||||||
|
for k, v in ipairs(self.atkBuffIconList) do
|
||||||
|
v:setLocalScale(0, 0, 0)
|
||||||
|
end
|
||||||
|
self.atkBuffTextList = {
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.text_1"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.text_2"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.text_3"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.text_4"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_l.text_5"],
|
||||||
|
}
|
||||||
|
for k, v in ipairs(self.atkBuffTextList) do
|
||||||
|
v:setText(GConst.EMPTY_STRING)
|
||||||
|
end
|
||||||
|
self.defBuffIconList = {
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.buff_1"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.buff_2"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.buff_3"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.buff_4"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.buff_5"],
|
||||||
|
}
|
||||||
|
for k, v in ipairs(self.atkBuffIconList) do
|
||||||
|
v:setLocalScale(0, 0, 0)
|
||||||
|
end
|
||||||
|
self.defBuffTextList = {
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.text_1"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.text_2"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.text_3"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.text_4"],
|
||||||
|
self.uiMap["battle_ui.top_node.buff_r.text_5"],
|
||||||
|
}
|
||||||
|
for k, v in ipairs(self.defBuffTextList) do
|
||||||
|
v:setText(GConst.EMPTY_STRING)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:refreshBuff(side, buffList)
|
||||||
|
if side == GConst.BattleConst.SIDE_ATK then
|
||||||
|
local buffObj = nil
|
||||||
|
local count = #buffList
|
||||||
|
local buffIconCount = #self.atkBuffIconList
|
||||||
|
local index = 1
|
||||||
|
for i = 1, count do
|
||||||
|
buffObj = buffList[i]
|
||||||
|
if buffObj and buffObj.buff:getIcon() then
|
||||||
|
local icon = self.atkBuffIconList[index]
|
||||||
|
local text = self.atkBuffTextList[index]
|
||||||
|
icon:setLocalScale(1, 1, 1)
|
||||||
|
icon:setTexture(GConst.ATLAS_PATH.ICON_BUFF, buffObj.buff:getIcon())
|
||||||
|
text:setText(buffObj.round)
|
||||||
|
index = index + 1
|
||||||
|
if index > buffIconCount then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = index, buffIconCount do
|
||||||
|
self.atkBuffIconList[i]:setLocalScale(0, 0, 0)
|
||||||
|
self.atkBuffTextList[i]:setText(GConst.EMPTY_STRING)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local buffObj = nil
|
||||||
|
local count = #buffList
|
||||||
|
local buffIconCount = #self.defBuffIconList
|
||||||
|
local index = 1
|
||||||
|
for i = 1, count do
|
||||||
|
buffObj = buffList[i]
|
||||||
|
if buffObj and buffObj.buff:getIcon() then
|
||||||
|
local icon = self.defBuffIconList[index]
|
||||||
|
local text = self.defBuffTextList[index]
|
||||||
|
icon:setLocalScale(1, 1, 1)
|
||||||
|
icon:setTexture(GConst.ATLAS_PATH.ICON_BUFF, buffObj.buff:getIcon())
|
||||||
|
text:setText(buffObj.round)
|
||||||
|
index = index + 1
|
||||||
|
if index > buffIconCount then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = index, buffIconCount do
|
||||||
|
self.defBuffIconList[i]:setLocalScale(0, 0, 0)
|
||||||
|
self.defBuffTextList[i]:setText(GConst.EMPTY_STRING)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:clearBuff(side)
|
||||||
|
if side == GConst.BattleConst.SIDE_ATK then
|
||||||
|
for k, v in ipairs(self.atkBuffIconList) do
|
||||||
|
v:setLocalScale(0, 0, 0)
|
||||||
|
end
|
||||||
|
for k, v in ipairs(self.atkBuffTextList) do
|
||||||
|
v:setText(GConst.EMPTY_STRING)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for k, v in ipairs(self.defBuffIconList) do
|
||||||
|
v:setLocalScale(0, 0, 0)
|
||||||
|
end
|
||||||
|
for k, v in ipairs(self.defBuffTextList) do
|
||||||
|
v:setText(GConst.EMPTY_STRING)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUI:initBattlefield()
|
function BattleUI:initBattlefield()
|
||||||
self.battleNode = self.uiMap["battle_ui.battle_node"]
|
self.battleNode = self.uiMap["battle_ui.battle_node"]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -66,4 +66,8 @@ function BattleBuffEntity:setTargetSide(side)
|
|||||||
self.targetSide = side
|
self.targetSide = side
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getIcon()
|
||||||
|
return self.buffInfo.icon
|
||||||
|
end
|
||||||
|
|
||||||
return BattleBuffEntity
|
return BattleBuffEntity
|
||||||
Loading…
x
Reference in New Issue
Block a user