feat: add cheapEffect

Fix #26
This commit is contained in:
Kazhnuz 2020-08-07 13:15:04 +02:00
parent 58cd72ac45
commit 04ae4ef657
4 changed files with 17 additions and 5 deletions

View file

@ -11,6 +11,13 @@ function Ennemy:new(world, x, y, owner)
self:initSprite()
end
function Ennemy:setCheapEffect(cheapEffect)
if (cheapEffect) then
self.sprite.sx = 2
self.sprite.sy = 2
end
end
function Ennemy:draw()
self:drawSprite(0, -self.z)
local x, y = self.world.map:gridToPixel(self.x, self.y, true)

View file

@ -166,11 +166,12 @@ function Parent:drawSprite(tx, ty)
local ty = ty or 0
if (self.sprite.active) then
local sx = self.direction * self.sprite.sx
local sy = self.sprite.sy
if (self.sprite.clone ~= nil) then
self.sprite.clone:draw(x + tx, y + ty, 0, self.direction, 1, self.sprite.ox, self.sprite.oy)
self.sprite.clone:draw(x + tx, y + ty, 0, sx, sy, self.sprite.ox, self.sprite.oy)
else
self.assets.sprites[self.sprite.name]:drawAnimation(x + tx, y + ty, 0, self.direction, 1, self.sprite.ox, self.sprite.oy)
self.assets.sprites[self.sprite.name]:drawAnimation(x + tx, y + ty, 0, sx, sy, self.sprite.ox, self.sprite.oy)
end
end
end
@ -184,7 +185,7 @@ end
function Parent:drawShadow()
local x, y = self.world.map:gridToPixel(self.x, self.y, true)
self.assets.images["actorsShadow"]:draw(x, y, 0, 1, 1, 12, 5)
self.assets.images["actorsShadow"]:draw(x, y, 0, self.sprite.sx, self.sprite.sy, 12, 5)
if (self.isSelected == true) then
self.assets.sprites["cursorground"]:drawAnimation(x - 2, y - 1, 0, 1, 1, 12, 5)
end

View file

@ -33,7 +33,7 @@ function EnnemyController:addBoss(ennData)
local boss = Villain(self, ennData.category, ennData.name, self:count() + 1)
boss:setBonus(ennData.pvFactor, ennData.statFactor)
boss.isBoss = true
boss.cheapEffect = ennData.cheapEffect
boss:setCheapEffect(ennData.cheapEffect)
self:add(boss)
end

View file

@ -18,6 +18,10 @@ function VillainFighter:new(owner, category, ennemy, id)
self.isBoss = false
end
function VillainFighter:setCheapEffect(cheapEffect)
self.actor:setCheapEffect(cheapEffect)
end
function VillainFighter:updateAssets(dt)
self.hpbar:update(dt)
end