2019-08-14 16:26:23 +02:00
|
|
|
local Battler = require("scenes.battlesystem.actors.battler")
|
|
|
|
local Ennemy = Battler:extend()
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-08-14 22:47:10 +02:00
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
|
2020-07-19 17:06:17 +02:00
|
|
|
function Ennemy:new(world, x, y, owner)
|
2020-08-03 17:38:30 +02:00
|
|
|
Ennemy.super.new(self, world, x, y, 0, owner)
|
2019-03-10 13:11:26 +01:00
|
|
|
self.isEnnemy = true
|
|
|
|
|
|
|
|
self.actionPerTurn = 2
|
2020-08-04 22:19:11 +02:00
|
|
|
self:initSprite()
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2020-08-07 13:15:04 +02:00
|
|
|
function Ennemy:setCheapEffect(cheapEffect)
|
|
|
|
if (cheapEffect) then
|
|
|
|
self.sprite.sx = 2
|
|
|
|
self.sprite.sy = 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-10 13:11:26 +01:00
|
|
|
function Ennemy:draw()
|
2020-08-04 22:19:11 +02:00
|
|
|
self:drawSprite(0, -self.z)
|
2020-07-19 17:06:17 +02:00
|
|
|
local x, y = self.world.map:gridToPixel(self.x, self.y, true)
|
2019-08-14 22:47:10 +02:00
|
|
|
|
2021-03-11 23:47:32 +01:00
|
|
|
self.owner:drawOversprite(x - 12, y - (self.owner.abstract.data.hudHeight * self.sprite.sy) - self.z)
|
2020-07-24 19:49:24 +02:00
|
|
|
|
2020-07-19 21:41:14 +02:00
|
|
|
if (self.isSelected) then
|
|
|
|
local height = 32
|
|
|
|
self.assets.images["cursorpeak"]:draw(x - 7, y - 24 - 32)
|
|
|
|
end
|
2020-08-22 23:53:13 +02:00
|
|
|
|
|
|
|
self:drawDamageNumber()
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2020-08-05 11:40:29 +02:00
|
|
|
function Ennemy:die()
|
|
|
|
self.assets.sfx["badnicsBoom"]:play()
|
|
|
|
self.world.obj.GFX(self.world, self.x, self.y, self.z, "boomGFX", self, false)
|
|
|
|
self:destroy()
|
|
|
|
end
|
|
|
|
|
2019-08-15 09:35:37 +02:00
|
|
|
function Ennemy:getStats()
|
|
|
|
return self.data.stats
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2020-08-04 22:19:11 +02:00
|
|
|
-- ASSETS FUNCTIONS
|
|
|
|
-- Load and play assets needed by the character
|
|
|
|
|
|
|
|
function Ennemy:getSpritePath()
|
|
|
|
return "datas/gamedata/ennemies/" .. self.owner.category .. "/" .. self.owner.name .. "/sprites"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-03-10 13:11:26 +01:00
|
|
|
return Ennemy
|