From d40112ba31aa9b130947cd4468a8b1e4593b638c Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 25 Jul 2020 12:03:14 +0200 Subject: [PATCH] improvement: handle better defeated fighter turns --- .../scenes/battlesystem/controllers/init.lua | 4 ++-- .../scenes/battlesystem/controllers/parent.lua | 12 +++++------- .../scenes/battlesystem/gui/hud.lua | 14 +++++++++++++- sonic-radiance.love/scenes/battlesystem/init.lua | 4 ++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua index a4f48aa..1f5b376 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua @@ -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 diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua index 198f358..69cb720 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua @@ -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 diff --git a/sonic-radiance.love/scenes/battlesystem/gui/hud.lua b/sonic-radiance.love/scenes/battlesystem/gui/hud.lua index 2c1a570..f9cecd9 100644 --- a/sonic-radiance.love/scenes/battlesystem/gui/hud.lua +++ b/sonic-radiance.love/scenes/battlesystem/gui/hud.lua @@ -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 diff --git a/sonic-radiance.love/scenes/battlesystem/init.lua b/sonic-radiance.love/scenes/battlesystem/init.lua index 8882278..94573aa 100644 --- a/sonic-radiance.love/scenes/battlesystem/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/init.lua @@ -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()