feat(cbs/choregraphy): add some basic steps

This commit is contained in:
Kazhnuz 2020-07-24 21:54:12 +02:00
parent bb3d823404
commit eec4ef060b
8 changed files with 109 additions and 6 deletions

View file

@ -47,6 +47,13 @@ function Parent:update(dt)
self.tweens:update(dt) self.tweens:update(dt)
end end
-- GET FUNCTIONS
-- Get informations
function Parent:getCoordinate()
return self.x, self.y
end
-- SPRITE FUNCTIONS -- SPRITE FUNCTIONS
-- Handle the character sprite -- Handle the character sprite

View file

@ -98,6 +98,7 @@ end
function HeroFighter:receiveTarget(target) function HeroFighter:receiveTarget(target)
self.selection = nil self.selection = nil
if (self.action ~= nil) then if (self.action ~= nil) then
self.action:setTarget(target)
self.action:start() self.action:start()
end end
end end

View file

@ -1,11 +1,14 @@
local ChoregraphySystem = Object:extend() local ChoregraphySystem = Object:extend()
local choregraphyUtils = require "game.utils.choregraphy" local choregraphyUtils = require "game.utils.choregraphy"
local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step"
function ChoregraphySystem:new(action, choregraphy) function ChoregraphySystem:new(action, choregraphy)
self.action = action self.action = action
self.fighter = action.fighter self.fighter = action.fighter
self.actor = self.fighter.actor self.actor = self.fighter.actor
self.assets = self.fighter.actor.assets
self.world = self.actor.world
self.currentStepId = 0 self.currentStepId = 0
self.currentStep = nil self.currentStep = nil
@ -14,7 +17,7 @@ end
function ChoregraphySystem:update(dt) function ChoregraphySystem:update(dt)
if (self.currentStep ~= nil) then if (self.currentStep ~= nil) then
self.currentStep:update(dt) self.currentStep:updateStep(dt)
else else
self:switchStep() self:switchStep()
end end
@ -25,7 +28,9 @@ function ChoregraphySystem:switchStep()
self.currentStepId = self.currentStepId + 1 self.currentStepId = self.currentStepId + 1
local stepData = choregraphyUtils.getStepDatas(self.stepList[self.currentStepId]) local stepData = choregraphyUtils.getStepDatas(self.stepList[self.currentStepId])
core.debug:print("cbs/choregraphy", "Starting step " .. stepData.name) 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 else
self:endChoregraphy() self:endChoregraphy()
end end

View file

@ -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

View file

@ -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

View file

@ -1,16 +1,31 @@
local StepParent = Object:extend() local StepParent = Object:extend()
function StepParent:new(choregraphySystem, name, arguments) function StepParent:new(choregraphySystem, arguments)
self.name = name
self.choregraphy = choregraphySystem self.choregraphy = choregraphySystem
self.arguments = arguments self.arguments = arguments
self.isStarted = false self.isStarted = false
end end
function StepParent:update(dt) function StepParent:updateStep(dt)
if (not self.isStarted) then if (not self.isStarted) then
self:startStep() self:start()
self.isStarted = true
else
self:update(dt)
end end
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 return StepParent

View file

@ -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

View file

@ -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;