improvement: adapt overworld to changes

This commit is contained in:
Kazhnuz 2022-05-11 23:07:19 +02:00
parent 6c7e0caf4b
commit f5bff3e1b9
2 changed files with 16 additions and 8 deletions

View file

@ -158,13 +158,16 @@ function PlayerActions:endFly()
end end
function PlayerActions:actionSwitch() function PlayerActions:actionSwitch()
if self.keys["select"].isPressed and (self.currentAction == "idle") then if self.keys["L1"].isPressed and (self.currentAction == "idle") then
self:switchActiveCharacter() self:switchActiveCharacter()
end end
if self.keys["R1"].isPressed and (self.currentAction == "idle") then
self:switchActiveCharacter(-1)
end
end end
function PlayerActions:actionRun() function PlayerActions:actionRun()
if self.keys["C"].isPressed then if self.keys["X"].isPressed then
if (self:canDoAction("run") and self.speedFactor > 0) then if (self:canDoAction("run") and self.speedFactor > 0) then
self.dashJustStarted = true self.dashJustStarted = true
if (utils.table.contain({"run", "idle"}, self.currentAction)) then if (utils.table.contain({"run", "idle"}, self.currentAction)) then
@ -174,7 +177,7 @@ function PlayerActions:actionRun()
end end
self.xsp, self.ysp = self:getDash() self.xsp, self.ysp = self:getDash()
end end
elseif (not self.keys["C"].isDown) then elseif (not self.keys["X"].isDown) then
if (self.currentAction == "run") then if (self.currentAction == "run") then
self.currentAction = "idle" self.currentAction = "idle"
elseif (self.currentAction == "jumpdash") then elseif (self.currentAction == "jumpdash") then

View file

@ -1,8 +1,13 @@
local Team = Object:extend() local Team = Object:extend()
function Team:initTeam() function Team:initTeam(forceCanGameOver)
self.active = game.characters:getActiveCharacterData() self.active = game.characters:getActiveCharacterData()
self.canChangeActive = true self.canChangeActive = true
if (forceCanKO == true) then
self.canKO = true
else
self.canKO = game.difficulty:get("playerKoChar") == false
end
end end
function Team:updateActiveCharacter() function Team:updateActiveCharacter()
@ -16,7 +21,7 @@ function Team:updateActiveCharacter()
if (everybodyIsKo) then if (everybodyIsKo) then
self.scene:gameover() self.scene:gameover()
else else
if ((self.active.hp == 0) and not game.difficulty:get("playerKoChar")) then if ((self.active.hp == 0) and self.canKO) then
self:switchActiveCharacter() self:switchActiveCharacter()
end end
end end
@ -26,9 +31,9 @@ function Team:getCurrentCharType()
return self.active.data.class return self.active.data.class
end end
function Team:switchActiveCharacter() function Team:switchActiveCharacter(direction)
if (self.canChangeActive) then if (self.canChangeActive and self.scene.gui:getElement("teamEmblems") ~= nil) then
local count = game.characters:setActiveCharacter() local count = game.characters:setActiveCharacter(direction)
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")