61 lines
1.4 KiB
Lua
61 lines
1.4 KiB
Lua
local Battler = require("scenes.battlesystem.actors.battler")
|
|
local Ennemy = Battler:extend()
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
function Ennemy:new(world, x, y, id, number)
|
|
Ennemy.super.new(self, world, x, y, 0)
|
|
self.isEnnemy = true
|
|
self.ennid = id or "motobug"
|
|
|
|
self.actionPerTurn = 2
|
|
|
|
self:receiveDatas()
|
|
self.hp = self.data.stats.hpmax
|
|
self.pp = self.data.stats.ppmax
|
|
end
|
|
|
|
function Ennemy:draw()
|
|
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
|
love.graphics.setColor(1, 0, 0, 1)
|
|
love.graphics.rectangle("fill", x - 8, y - 32, 16, 32)
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
end
|
|
|
|
function Ennemy:drawHUD()
|
|
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
|
love.graphics.setColor(0, 0, 0, 1)
|
|
gui.drawBar(x - 14, y - 38, 26, 4)
|
|
love.graphics.setColor(248/255, 160/255, 0, 1)
|
|
local bar = math.floor(24 * (self.hp / self.data.stats.hpmax))
|
|
gui.drawBar(x - 14, y - 37, bar, 2)
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
end
|
|
|
|
function Ennemy: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 Ennemy:receiveDatas()
|
|
self.data = game.ennemies:getEnnemyData(self.ennid)
|
|
end
|
|
|
|
function Ennemy:setHP(value, relative)
|
|
if (relative) then
|
|
value = self.hp + value
|
|
end
|
|
|
|
self.hp = value
|
|
if (self.hp <= 0) then
|
|
self:destroy()
|
|
end
|
|
end
|
|
|
|
function Ennemy:getStats()
|
|
return self.data.stats
|
|
end
|
|
|
|
return Ennemy
|