improvement: handle better defeated fighter turns

This commit is contained in:
Kazhnuz 2020-07-25 12:03:14 +02:00
parent 4ab2e72231
commit d40112ba31
4 changed files with 22 additions and 12 deletions

View file

@ -62,7 +62,6 @@ function TurnController:nextAction()
self.turns.current = self.turns.current + 1
core.debug:print("cbs/turns", "switching to next action")
end
self.hud:moveBattleCursor(self.turns.current)
self:startAction()
end
@ -101,13 +100,14 @@ function TurnController:startAction()
local nextAction = self.actionList[self.turns.current]
print(nextAction)
local nextFighter = nextAction.fighter
if (nextFighter.isDestroyed == true) then
if (not nextFighter:canFight()) then
-- On skipe le personnage s'il a été detruit
self:nextAction()
else
self.currentFighter = nextFighter
core.debug:print("cbs/turns", "Activating " .. self.currentFighter.name)
self.currentFighter:setActive()
self.hud:moveBattleCursor(self.turns.current)
end
end

View file

@ -42,13 +42,11 @@ end
function FighterControllerParent:putActions(actionList)
for i, fighter in ipairs(self.list) do
if fighter:canFight() then
for i=1, fighter:getNbrActionPerTurn() do
local action = {}
action.fighter = fighter
action.number = i
table.insert(actionList, action)
end
for i=1, fighter:getNbrActionPerTurn() do
local action = {}
action.fighter = fighter
action.number = i
table.insert(actionList, action)
end
end

View file

@ -39,7 +39,11 @@ end
function HUD:draw()
for i, action in ipairs(self.turns.actionList) do
action.fighter:drawIcon(4 + (i-1)*(20), 6)
if action.fighter:canFight() then
action.fighter:drawIcon(4 + (i-1)*(20), 6)
else
self:drawEmptyIcon(4 + (i-1)*(20), 6)
end
end
local cursorx = self.battlerCursor * 20 - 8
@ -59,4 +63,12 @@ function HUD:draw()
love.graphics.print(turnnbr, x + 33, y + 1)
end
function HUD:drawEmptyIcon(x, y)
local outlineLight = 0.15
love.graphics.circle("fill", x + 8, y + 8, 2, 8)
love.graphics.setColor(outlineLight, outlineLight, outlineLight, 1)
love.graphics.circle("line", x + 8, y + 8, 2, 8)
utils.graphics.resetColor()
end
return HUD

View file

@ -13,8 +13,8 @@ function BattleSystem:new()
self.assets:batchImport("scenes.battlesystem.assets")
self.assets:setMusic("assets/music/battle1.mp3")
self.assets:playMusic()
--self.assets:setMusic("assets/music/battle1.mp3")
--self.assets:playMusic()
self:initManagers()