diff --git a/sonic-radiance.love/scenes/battlesystem/actors/parent.lua b/sonic-radiance.love/scenes/battlesystem/actors/parent.lua index e2c8110..d2d4775 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/parent.lua @@ -47,6 +47,13 @@ function Parent:update(dt) self.tweens:update(dt) end +-- GET FUNCTIONS +-- Get informations + +function Parent:getCoordinate() + return self.x, self.y +end + -- SPRITE FUNCTIONS -- Handle the character sprite diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua index d2a4c00..581bbef 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua @@ -98,6 +98,7 @@ end function HeroFighter:receiveTarget(target) self.selection = nil if (self.action ~= nil) then + self.action:setTarget(target) self.action:start() end end diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua index b1e8006..a9899a5 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua @@ -1,11 +1,14 @@ local ChoregraphySystem = Object:extend() local choregraphyUtils = require "game.utils.choregraphy" +local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step" function ChoregraphySystem:new(action, choregraphy) self.action = action self.fighter = action.fighter self.actor = self.fighter.actor + self.assets = self.fighter.actor.assets + self.world = self.actor.world self.currentStepId = 0 self.currentStep = nil @@ -14,7 +17,7 @@ end function ChoregraphySystem:update(dt) if (self.currentStep ~= nil) then - self.currentStep:update(dt) + self.currentStep:updateStep(dt) else self:switchStep() end @@ -25,7 +28,9 @@ function ChoregraphySystem:switchStep() self.currentStepId = self.currentStepId + 1 local stepData = choregraphyUtils.getStepDatas(self.stepList[self.currentStepId]) core.debug:print("cbs/choregraphy", "Starting step " .. stepData.name) - --self.currentStep = self.stepList[self.currentStepId] + if (stepObjectList[stepData.name] ~= nil) then + self.currentStep = stepObjectList[stepData.name](self, stepData.arguments) + end else self:endChoregraphy() end diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/addGFX.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/addGFX.lua new file mode 100644 index 0000000..7b70183 --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/addGFX.lua @@ -0,0 +1,29 @@ +local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent" +local StepGFX = StepParent:extend() + +function StepGFX:new(controller, args) + StepGFX.super.new(self, controller, args) +end + +function StepGFX:start() + local x, y = self:getStepCoordinate() + + self.choregraphy.world.obj.GFX(self.choregraphy.world, x, y, 0, self.arguments.sprite, self, self.arguments.blockProcess) + + if (not self.arguments.blockProcess) then + self:finish() + end +end + +function StepGFX:update(dt) + +end + +function StepGFX:getSignal(signal) + if (signal == "gfxEnded") then + self:finish() + end +end + + +return StepGFX diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua new file mode 100644 index 0000000..2c8b191 --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua @@ -0,0 +1,14 @@ +local actions = {} + +local baseURI = "scenes.battlesystem.controllers.fighters.systems.choregraphy.step." + +actions["addGFX"] = require(baseURI .. "addGFX") +--actions["dashForward"] = require(baseURI .. "dashForward") +--actions["jump"] = require(baseURI .. "jump") +actions["playSFX"] = require(baseURI .. "playSFX") +--actions["sendDamage"] = require(baseURI .. "sendDamage") +--actions["sendDamageToPoint"] = require(baseURI .. "sendDamageToPoint") +--actions["setAnimation"] = require(baseURI .. "setAnimation") +actions["wait"] = require(baseURI .. "wait") + +return actions diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua index 5694e3f..5d56108 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua @@ -1,16 +1,31 @@ local StepParent = Object:extend() -function StepParent:new(choregraphySystem, name, arguments) - self.name = name +function StepParent:new(choregraphySystem, arguments) self.choregraphy = choregraphySystem self.arguments = arguments self.isStarted = false end -function StepParent:update(dt) +function StepParent:updateStep(dt) if (not self.isStarted) then - self:startStep() + self:start() + self.isStarted = true + else + self:update(dt) end end +function StepParent:getStepCoordinate() + if (self.arguments.origin == "target") then + local target = self.choregraphy.action.target + local x, y = target.actor:getCoordinate() + return x + self.arguments.x, y + self.arguments.y + end +end + +function StepParent:finish() + print("action finished") + self.choregraphy:endStep() +end + return StepParent diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/playSFX.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/playSFX.lua new file mode 100644 index 0000000..e5d24ac --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/playSFX.lua @@ -0,0 +1,13 @@ +local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent" +local PlaySFX = StepParent:extend() + +function PlaySFX:new(system, args) + PlaySFX.super.new(self, system, args) +end + +function PlaySFX:start() + self.choregraphy.assets.sfx[self.arguments.sfx]:play() + self:finish() +end + +return PlaySFX diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/wait.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/wait.lua new file mode 100644 index 0000000..5098318 --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/wait.lua @@ -0,0 +1,19 @@ +local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent" +local WaitStep = StepParent:extend() + +function WaitStep:new(controller, args) + WaitStep.super.new(self, controller, args) +end + +function WaitStep:start() + self.timer = 0 +end + +function WaitStep:update(dt) + self.timer = self.timer + dt + if (self.timer > self.arguments.duration) then + self:finish() + end +end + +return WaitStep;