sonic-radiance/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua
2020-08-04 17:50:03 +02:00

68 lines
1.5 KiB
Lua

local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
local VillainFighter = FighterParent:extend()
local SimpleHPBar = require "game.modules.gui.simplehpbar"
local POSITIONS = {1, 3, 5}
local ENNEMY_LINE = 11;
function VillainFighter:new(owner, category, ennemy, id)
self.name = ennemy
self.category = category
self.super.new(self, owner, false, id)
self.hpbar = SimpleHPBar(self.abstract.hp)
self.isBoss = false
end
function VillainFighter:updateAssets(dt)
self.hpbar:update(dt)
end
function VillainFighter:getAbstract()
return game.ennemies:getEnnemyData(self.category, self.name)
end
function VillainFighter:createActor()
local x, y = ENNEMY_LINE, POSITIONS[self.id]
return self.world.obj.Ennemy(self.world, x, y, self)
end
function VillainFighter:startAction()
end
function VillainFighter:endAction()
end
function FighterParent:die()
self.isAlive = false
self.actor:destroy()
end
function VillainFighter:setBonus(pvFactor, statFactor)
self.abstract:setBonus(pvFactor, statFactor)
end
-- LIFE FUNCTIONS
function VillainFighter:setHP(value, relative)
VillainFighter.super.setHP(self, value, relative)
self.hpbar:setHP(self.abstract.hp)
end
-- DRAW FUNCTIONS
function VillainFighter:drawIcon(x, y)
love.graphics.setColor(1, 0, 0, 1)
love.graphics.rectangle("fill", x, y, 16, 16)
love.graphics.setColor(1, 1, 1, 1)
end
function VillainFighter:drawHUD(x, y)
if (not self.isBoss) then
self.hpbar:draw(x, y)
end
end
return VillainFighter