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 HUDBASE = 8
local HUDSEP = 152 local HUDSEP = 152
function StatusBar:new(fighter) function StatusBar:new(abstract, scene)
self.fighter = fighter self.assets = scene.assets
self.hud = fighter.turnSystem.hud self.abstract = abstract
self.assets = self.fighter.assets
self.charid = self.fighter.name self.charid = self.abstract.simplename
self.stats = self.fighter:getStats() self.stats = self.abstract:getStats()
self.abstract = self.fighter.abstract
self.hp = self.abstract.hp self.hp = self.abstract.hp
self.pp = self.abstract.pp self.pp = self.abstract.pp
@ -44,10 +42,7 @@ function StatusBar:drawEmblem(x, y)
self.assets.images[emblem2]:draw(x, y) self.assets.images[emblem2]:draw(x, y)
end end
function StatusBar:draw() function StatusBar:draw(x, y)
local x = HUDBASE + (self.fighter.id-1)*HUDSEP
local y = self.hud:getPlayerHUDPosition()
self:drawEmblem(x, y) self:drawEmblem(x, y)
self.assets.images["statusbar"]:draw(x+12, y-6) 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 POSITIONS = {3, 1, 5}
local HEROES_LINE = 2; local HEROES_LINE = 2;
local HUDBASE = 8
local HUDSEP = 152
function HeroFighter:new(owner, character, id) function HeroFighter:new(owner, character, id)
self.name = character self.name = character
self.super.new(self, owner, true, id) self.super.new(self, owner, true, id)
self.statusbar = StatusBar(self) self.statusbar = StatusBar(self.abstract, self.turnSystem.scene)
self:initVoices() self:initVoices()
self.action = nil self.action = nil
@ -149,7 +152,9 @@ function HeroFighter:drawIcon(x, y)
end end
function HeroFighter:drawHUD() 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 end
return HeroFighter return HeroFighter