From 955d8d33d95d6d6eae4c8257e187b117acd39f9a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 3 Aug 2020 09:24:52 +0200 Subject: [PATCH] chore: make the statusbar independant of the battle system --- .../game/modules/gui/statusbar.lua | 17 ++++++----------- .../controllers/fighters/character.lua | 9 +++++++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sonic-radiance.love/game/modules/gui/statusbar.lua b/sonic-radiance.love/game/modules/gui/statusbar.lua index 91d8fdc..1ef4f5f 100644 --- a/sonic-radiance.love/game/modules/gui/statusbar.lua +++ b/sonic-radiance.love/game/modules/gui/statusbar.lua @@ -6,14 +6,12 @@ local gui = require "game.modules.gui" local HUDBASE = 8 local HUDSEP = 152 -function StatusBar:new(fighter) - self.fighter = fighter - self.hud = fighter.turnSystem.hud - self.assets = self.fighter.assets +function StatusBar:new(abstract, scene) + self.assets = scene.assets + self.abstract = abstract - self.charid = self.fighter.name - self.stats = self.fighter:getStats() - self.abstract = self.fighter.abstract + self.charid = self.abstract.simplename + self.stats = self.abstract:getStats() self.hp = self.abstract.hp self.pp = self.abstract.pp @@ -44,10 +42,7 @@ function StatusBar:drawEmblem(x, y) self.assets.images[emblem2]:draw(x, y) end -function StatusBar:draw() - local x = HUDBASE + (self.fighter.id-1)*HUDSEP - local y = self.hud:getPlayerHUDPosition() - +function StatusBar:draw(x, y) self:drawEmblem(x, y) self.assets.images["statusbar"]:draw(x+12, y-6) diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua index 365d894..ed63881 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua @@ -8,11 +8,14 @@ local actionList = require "scenes.battlesystem.controllers.fighters.systems.act local POSITIONS = {3, 1, 5} local HEROES_LINE = 2; +local HUDBASE = 8 +local HUDSEP = 152 + function HeroFighter:new(owner, character, id) self.name = character self.super.new(self, owner, true, id) - self.statusbar = StatusBar(self) + self.statusbar = StatusBar(self.abstract, self.turnSystem.scene) self:initVoices() self.action = nil @@ -149,7 +152,9 @@ function HeroFighter:drawIcon(x, y) end function HeroFighter:drawHUD() - self.statusbar:draw() + local x = HUDBASE + (self.id-1)*HUDSEP + local y = self.turnSystem.hud:getPlayerHUDPosition() + self.statusbar:draw(x, y) end return HeroFighter