6bca41d794
There is still a lot of work though
49 lines
1 KiB
Lua
49 lines
1 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, owner)
|
|
Ennemy.super.new(self, world, x, y, 0)
|
|
self.isEnnemy = true
|
|
self.owner = owner
|
|
|
|
self.actionPerTurn = 2
|
|
|
|
self:receiveDatas()
|
|
self.hp = self.data.stats.hpmax
|
|
self.pp = self.data.stats.ppmax
|
|
|
|
self.shownHP = self.hp
|
|
end
|
|
|
|
function Ennemy:draw()
|
|
local x, y = self.world.map: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)
|
|
|
|
self.owner:drawHUD(x - 14, y - 38)
|
|
end
|
|
|
|
function Ennemy:receiveDatas()
|
|
self.data = game.ennemies:getEnnemyData(self.owner.name)
|
|
end
|
|
|
|
function Ennemy:setHP(value, relative)
|
|
if (relative) then
|
|
value = self.hp + value
|
|
end
|
|
|
|
self.hp = value
|
|
self.tweens:newTween(0, 0.1, {shownHP = self.hp}, 'inCubic')
|
|
if (self.hp <= 0) then
|
|
self:destroy()
|
|
end
|
|
end
|
|
|
|
function Ennemy:getStats()
|
|
return self.data.stats
|
|
end
|
|
|
|
return Ennemy
|