chore: make the statusbar independant of the battle system

This commit is contained in:
Kazhnuz 2020-08-03 09:24:52 +02:00
parent 786dc78a13
commit 955d8d33d9
2 changed files with 13 additions and 13 deletions

View file

@ -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)

View file

@ -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