战斗buff

This commit is contained in:
chenxi 2023-04-20 11:19:31 +08:00
parent a98cf98c58
commit ae30c47881
3 changed files with 62 additions and 4 deletions

View File

@ -191,6 +191,22 @@ function BattleController:clearBuff(side)
self.battleUI:clearBuff(side)
end
function BattleController:showBuffTips(side)
if side == BattleConst.SIDE_ATK then
local buffList = self.atkTeam:getBuffList()
if #buffList <= 0 then
return
end
self.battleUI:showLeftBuffTips(buffList)
else
local buffList = self.defTeam:getBuffList()
if #buffList <= 0 then
return
end
self.battleUI:showRightBuffTips(buffList)
end
end
function BattleController:prepareFight()
local count = 0
local totalCount = 3

View File

@ -28,6 +28,10 @@ function BattleTeam:prepare()
end
end
function BattleTeam:getBuffList()
return self.buffList
end
function BattleTeam:getMainUnit()
return self.mainUnit
end

View File

@ -103,6 +103,7 @@ function BattleUI:initSkill()
end
function BattleUI:initBuff()
-- buff icon
self.atkBuffIconList = {
self.uiMap["battle_ui.top_node.buff_l.buff_1"],
self.uiMap["battle_ui.top_node.buff_l.buff_2"],
@ -111,6 +112,9 @@ function BattleUI:initBuff()
self.uiMap["battle_ui.top_node.buff_l.buff_5"],
}
for k, v in ipairs(self.atkBuffIconList) do
v:addClickListener(function()
self.battleController:showBuffTips(1)
end)
v:setLocalScale(0, 0, 0)
end
self.atkBuffTextList = {
@ -131,6 +135,9 @@ function BattleUI:initBuff()
self.uiMap["battle_ui.top_node.buff_r.buff_5"],
}
for k, v in ipairs(self.atkBuffIconList) do
v:addClickListener(function()
self.battleController:showBuffTips(2)
end)
v:setLocalScale(0, 0, 0)
end
self.defBuffTextList = {
@ -143,6 +150,15 @@ function BattleUI:initBuff()
for k, v in ipairs(self.defBuffTextList) do
v:setText(GConst.EMPTY_STRING)
end
-- buff的tips
self.battleBuffTipsRoot = self.uiMap["battle_ui.battle_buff_tips"]
self.battleBuffTipsRoot:setLocalScale(0, 0, 0)
local battleBuffTipsMask = self.uiMap["battle_ui.battle_buff_tips.mask"]
battleBuffTipsMask:addClickListener(function()
self.battleBuffTipsRoot:setLocalScale(0, 0, 0)
end)
self.battleBuffTipsBg = self.uiMap["battle_ui.battle_buff_tips.bg"]
self.battleBuffTipsBuff = self.uiMap["battle_ui.battle_buff_tips.bg.buff"]
end
function BattleUI:refreshBuff(side, buffList)
@ -157,8 +173,13 @@ function BattleUI:refreshBuff(side, buffList)
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)
icon:setSprite(GConst.ATLAS_PATH.ICON_BUFF, buffObj.buff:getIcon())
local round = buffObj.round
if round <= 1 or round > 9 then
text:setText(GConst.EMPTY_STRING)
else
text:setText(tostring(round))
end
index = index + 1
if index > buffIconCount then
break
@ -180,8 +201,13 @@ function BattleUI:refreshBuff(side, buffList)
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)
icon:setSprite(GConst.ATLAS_PATH.ICON_BUFF, buffObj.buff:getIcon())
local round = buffObj.round
if round <= 1 or round > 9 then
text:setText(GConst.EMPTY_STRING)
else
text:setText(tostring(round))
end
index = index + 1
if index > buffIconCount then
break
@ -213,6 +239,18 @@ function BattleUI:clearBuff(side)
end
end
function BattleUI:showLeftBuffTips(buffList)
self:showBuffTips(buffList)
end
function BattleUI:showLeftBuffTips(buffList)
self:showBuffTips(buffList)
end
function BattleUI:showBuffTips(buffList)
end
function BattleUI:initBattlefield()
self.battleNode = self.uiMap["battle_ui.battle_node"]
end