65 lines
1.7 KiB
Lua
65 lines
1.7 KiB
Lua
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.target = action.target
|
|
|
|
self.currentStepId = 0
|
|
self.currentStep = nil
|
|
self.stepList = choregraphy
|
|
end
|
|
|
|
function ChoregraphySystem:update(dt)
|
|
if (self.currentStep ~= nil) then
|
|
self.currentStep:updateStep(dt)
|
|
else
|
|
self:switchStep()
|
|
end
|
|
end
|
|
|
|
function ChoregraphySystem:switchStep()
|
|
if self:haveNextStep() then
|
|
self.currentStepId = self.currentStepId + 1
|
|
local stepData = choregraphyUtils.getStepDatas(self.stepList[self.currentStepId])
|
|
core.debug:print("cbs/choregraphy", "Starting step " .. stepData.name)
|
|
if (stepObjectList[stepData.name] ~= nil) then
|
|
self.currentStep = stepObjectList[stepData.name](self, stepData.arguments)
|
|
end
|
|
else
|
|
self:endChoregraphy()
|
|
end
|
|
end
|
|
|
|
function ChoregraphySystem:sendDamage(power, accuracy, isSpecial, isAerial)
|
|
if (self.target ~= nil) then
|
|
if (self.fighter.isAlive) then
|
|
self.fighter:sendDamage(self.target, power, accuracy, isSpecial, isAerial)
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChoregraphySystem:endStep()
|
|
self.currentStep = nil
|
|
end
|
|
|
|
function ChoregraphySystem:endChoregraphy()
|
|
self.actor:choregraphyEnded()
|
|
self.action:choregraphyEnded()
|
|
self.fighter.turnSystem:applyDeath()
|
|
end
|
|
|
|
function ChoregraphySystem:haveNextStep()
|
|
return ((self.currentStepId + 1) <= #self.stepList)
|
|
end
|
|
|
|
return ChoregraphySystem
|