fix: correctly apply death at start of battle

Fix #28
This commit is contained in:
Kazhnuz 2020-08-22 23:28:05 +02:00
parent 9326a5dc91
commit 4ff4c989d4
6 changed files with 39 additions and 4 deletions

View file

@ -119,12 +119,19 @@ return {
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
["getKo"] = {
startAt = 50,
endAt = 52,
loop = 52,
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
startAt = 52,
endAt = 52,
loop = 52,
speed = 15,
pauseAtEnd = true,
}
}
}

View file

@ -119,12 +119,19 @@ return {
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
["getKo"] = {
startAt = 58,
endAt = 62,
loop = 62,
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
startAt = 62,
endAt = 62,
loop = 62,
speed = 15,
pauseAtEnd = true,
}
}
}

View file

@ -119,12 +119,19 @@ return {
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
["getKo"] = {
startAt = 53,
endAt = 59,
loop = 59,
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
startAt = 59,
endAt = 59,
loop = 59,
speed = 15,
pauseAtEnd = true,
}
}
}

View file

@ -7,6 +7,7 @@ local Hero = Battler:extend()
function Hero:new(world, x, y, owner, charnumber)
Hero.super.new(self, world, x, y, 0, owner)
self:initSprite()
self.isKo = false
end
-- UPDATE FUNCTION
@ -24,7 +25,15 @@ function Hero:getHurt()
end
function Hero:die()
if (not self.isKo) then
self:changeAnimation("getKo")
self.isKo = true
end
end
function Hero:setAsKo()
self:changeAnimation("ko")
self.isKo = true
end
-- ASSETS FUNCTIONS

View file

@ -39,7 +39,11 @@ end
function HeroFighter:createActor()
local x, y = HEROES_LINE, ((self.id-1)*(4/(#game.characters.team-1))+1)
return self.world.obj.Hero(self.world, x, y, self)
local hero = self.world.obj.Hero(self.world, x, y, self)
if (self.abstract.hp <= 0) then
hero:setAsKo()
end
return hero
end
function HeroFighter:startAction()

View file

@ -31,6 +31,7 @@ function TurnController:new(scene, battleData)
-- Change the seed at the start of each battle
math.randomseed( os.time() )
self:applyDeath()
end
function TurnController:startBattle()