feat: handle ko characters on overworld

Preparation for full damage support
This commit is contained in:
Kazhnuz 2021-04-18 19:59:03 +02:00
parent cd174e3153
commit 36e30be245
3 changed files with 14 additions and 2 deletions

View file

@ -131,6 +131,7 @@ end
function CharacterManager:setActiveCharacter(direction) function CharacterManager:setActiveCharacter(direction)
local direction = direction or 1 local direction = direction or 1
local count = direction
self.active = self.active + utils.math.sign(direction) self.active = self.active + utils.math.sign(direction)
if (self.active > #self.team) then if (self.active > #self.team) then
self.active = 1 self.active = 1
@ -138,6 +139,10 @@ function CharacterManager:setActiveCharacter(direction)
if (self.active < 1) then if (self.active < 1) then
self.active = #self.team self.active = #self.team
end end
if (self.list[self.team[self.active]].hp <= 0) and not game.difficulty:get("playerKoChar") then
count = count + self:setActiveCharacter(direction)
end
return count
end end
function CharacterManager:fixActiveCharacter() function CharacterManager:fixActiveCharacter()

View file

@ -44,6 +44,7 @@ end
function Player:updateStart(dt) function Player:updateStart(dt)
self.tweens:update(dt) self.tweens:update(dt)
self:updateTerrain() self:updateTerrain()
self:updateActiveCharacter()
self:act() self:act()

View file

@ -15,17 +15,23 @@ function Team:initTeam()
self.canChangeActive = true self.canChangeActive = true
end end
function Team:updateActiveCharacter()
if ((self.active.hp == 0) and not game.difficulty:get("playerKoChar")) then
self:switchActiveCharacter()
end
end
function Team:getCurrentCharType() function Team:getCurrentCharType()
return self.active.data.class return self.active.data.class
end end
function Team:switchActiveCharacter() function Team:switchActiveCharacter()
if (self.canChangeActive) then if (self.canChangeActive) then
game.characters:setActiveCharacter() local count = game.characters:setActiveCharacter()
self.active = game.characters:getActiveCharacterData() self.active = game.characters:getActiveCharacterData()
self.canChangeActive = false self.canChangeActive = false
self.tweens:newTimer(0.3, "changeCharacter") self.tweens:newTimer(0.3, "changeCharacter")
self.tweens:newTween(0, 0.3, {activeVisible = self.activeVisible + 1}, "inQuad") self.tweens:newTween(0, 0.3, {activeVisible = self.activeVisible + count}, "inQuad")
end end
end end