2021-04-10 17:14:41 +02:00
|
|
|
local Team = Object:extend()
|
|
|
|
|
2022-05-11 23:07:19 +02:00
|
|
|
function Team:initTeam(forceCanGameOver)
|
2021-04-10 17:14:41 +02:00
|
|
|
self.active = game.characters:getActiveCharacterData()
|
|
|
|
self.canChangeActive = true
|
2022-05-11 23:07:19 +02:00
|
|
|
if (forceCanKO == true) then
|
|
|
|
self.canKO = true
|
|
|
|
else
|
|
|
|
self.canKO = game.difficulty:get("playerKoChar") == false
|
|
|
|
end
|
2021-04-10 17:14:41 +02:00
|
|
|
end
|
|
|
|
|
2021-04-18 19:59:03 +02:00
|
|
|
function Team:updateActiveCharacter()
|
2021-04-19 18:04:29 +02:00
|
|
|
local everybodyIsKo = true
|
|
|
|
for id, name in ipairs(game.characters.team) do
|
|
|
|
if (game.characters.list[name].hp > 0) then
|
|
|
|
everybodyIsKo = false
|
|
|
|
break;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if (everybodyIsKo) then
|
|
|
|
self.scene:gameover()
|
|
|
|
else
|
2022-05-11 23:07:19 +02:00
|
|
|
if ((self.active.hp == 0) and self.canKO) then
|
2021-04-19 18:04:29 +02:00
|
|
|
self:switchActiveCharacter()
|
|
|
|
end
|
2021-04-18 19:59:03 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-10 17:59:01 +02:00
|
|
|
function Team:getCurrentCharType()
|
|
|
|
return self.active.data.class
|
|
|
|
end
|
|
|
|
|
2022-05-11 23:07:19 +02:00
|
|
|
function Team:switchActiveCharacter(direction)
|
|
|
|
if (self.canChangeActive and self.scene.gui:getElement("teamEmblems") ~= nil) then
|
|
|
|
local count = game.characters:setActiveCharacter(direction)
|
2021-04-10 17:43:10 +02:00
|
|
|
self.active = game.characters:getActiveCharacterData()
|
2021-04-10 17:14:41 +02:00
|
|
|
self.canChangeActive = false
|
|
|
|
self.tweens:newTimer(0.3, "changeCharacter")
|
2021-12-05 17:52:27 +01:00
|
|
|
self.scene.gui:getElement("teamEmblems"):changeActivePlayer(count)
|
2021-04-10 17:14:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Team:endCharacterSwitchAnimation()
|
|
|
|
self.canChangeActive = true
|
|
|
|
self:updateCurrentCharset()
|
|
|
|
end
|
|
|
|
|
|
|
|
return Team
|