2020-08-03 09:34:23 +02:00
|
|
|
local Emblem = Object:extend()
|
2021-04-18 19:30:57 +02:00
|
|
|
local greyscale = require "game.modules.drawing.greyscale"
|
2020-08-03 09:34:23 +02:00
|
|
|
|
|
|
|
function Emblem:new(abstract, scene)
|
|
|
|
self.assets = scene.assets
|
|
|
|
self.abstract = abstract
|
|
|
|
|
|
|
|
self.charid = self.abstract.simplename
|
|
|
|
self.stats = self.abstract:getStats()
|
|
|
|
end
|
|
|
|
|
|
|
|
function Emblem:draw(x, y)
|
2020-08-04 19:53:11 +02:00
|
|
|
self:drawBackground(x, y)
|
|
|
|
self:drawForeground(x, y)
|
|
|
|
end
|
2020-08-03 09:34:23 +02:00
|
|
|
|
2020-08-04 19:53:11 +02:00
|
|
|
function Emblem:drawForeground(x, y)
|
|
|
|
local emblem2 = "m_" .. self.abstract.data.class
|
2020-08-03 09:34:23 +02:00
|
|
|
core.screen:setScissor(x, y-16, 32, 40)
|
2021-04-18 19:30:57 +02:00
|
|
|
if (self.abstract.hp > 0) then
|
2021-08-21 17:05:49 +02:00
|
|
|
self.assets.sprites[self.charid]:draw(x+14, y+14)
|
2021-04-18 19:30:57 +02:00
|
|
|
else
|
|
|
|
greyscale.startShader()
|
|
|
|
self.assets.sprites[self.charid]:drawFrame(1, x+14, y+14)
|
|
|
|
end
|
2020-08-03 09:34:23 +02:00
|
|
|
core.screen:resetScissor( )
|
|
|
|
self.assets.images[emblem2]:draw(x, y)
|
2021-04-18 19:30:57 +02:00
|
|
|
greyscale.endShader()
|
2020-08-03 09:34:23 +02:00
|
|
|
end
|
|
|
|
|
2020-08-04 19:53:11 +02:00
|
|
|
function Emblem:drawBackground(x, y)
|
|
|
|
local emblem1 = "e_" .. self.abstract.data.class
|
|
|
|
|
2021-04-18 19:30:57 +02:00
|
|
|
if (self.abstract.hp > 0) then
|
|
|
|
self.assets.images[emblem1]:draw(x, y)
|
|
|
|
else
|
|
|
|
greyscale.startShader()
|
|
|
|
self.assets.images[emblem1]:draw(x, y)
|
|
|
|
greyscale.endShader()
|
|
|
|
end
|
2020-08-04 19:53:11 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2020-08-03 09:34:23 +02:00
|
|
|
return Emblem
|