feat:detect tagged actions and handle tags
This commit is contained in:
parent
f7221971c3
commit
0377077ca9
3 changed files with 44 additions and 3 deletions
|
@ -15,7 +15,7 @@ return {
|
||||||
|
|
||||||
choregraphy = { -- the main attack choregraphy
|
choregraphy = { -- the main attack choregraphy
|
||||||
{"setAnimation", "none", "walk", false},
|
{"setAnimation", "none", "walk", false},
|
||||||
{"goTo", "none", "target", 0, 0, 0.6, false},
|
{"taggedAction", "playerMove", {"goTo", "none", "target", 0, 0, 0.6, false}},
|
||||||
{"wait", "none", 0.3},
|
{"wait", "none", 0.3},
|
||||||
{"setAnimation", "none", "spin", false},
|
{"setAnimation", "none", "spin", false},
|
||||||
{'playSFX', "none", 'spinrelease'},
|
{'playSFX', "none", 'spinrelease'},
|
||||||
|
|
|
@ -3,6 +3,9 @@ local ChoregraphySystem = Object:extend()
|
||||||
local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step"
|
local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step"
|
||||||
local qteObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.qte"
|
local qteObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.qte"
|
||||||
|
|
||||||
|
local ACTION_STARTED = 1
|
||||||
|
local ACTION_FINISHED = 2
|
||||||
|
|
||||||
function ChoregraphySystem:new(action, choregraphy)
|
function ChoregraphySystem:new(action, choregraphy)
|
||||||
self.action = action
|
self.action = action
|
||||||
self.fighter = action.fighter
|
self.fighter = action.fighter
|
||||||
|
@ -21,6 +24,8 @@ function ChoregraphySystem:new(action, choregraphy)
|
||||||
self.qte.current = nil
|
self.qte.current = nil
|
||||||
self.qte.wasSuccess = false
|
self.qte.wasSuccess = false
|
||||||
self.qte.list = {}
|
self.qte.list = {}
|
||||||
|
|
||||||
|
self.finishedTagActions = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChoregraphySystem:update(dt)
|
function ChoregraphySystem:update(dt)
|
||||||
|
@ -38,16 +43,30 @@ end
|
||||||
function ChoregraphySystem:switchStep()
|
function ChoregraphySystem:switchStep()
|
||||||
if self:haveNextStep() then
|
if self:haveNextStep() then
|
||||||
self.currentStepId = self.currentStepId + 1
|
self.currentStepId = self.currentStepId + 1
|
||||||
local stepData = core.datas:parse("choregraphystep", self.stepList[self.currentStepId])
|
local stepData, tagName = self:parseStep(self.stepList[self.currentStepId])
|
||||||
core.debug:print("cbs/choregraphy", "Starting step " .. stepData.name)
|
|
||||||
if (stepObjectList[stepData.name] ~= nil and self:checkCondition(stepData.condition)) then
|
if (stepObjectList[stepData.name] ~= nil and self:checkCondition(stepData.condition)) then
|
||||||
self.currentStep = stepObjectList[stepData.name](self, stepData.arguments)
|
self.currentStep = stepObjectList[stepData.name](self, stepData.arguments)
|
||||||
|
if (not utils.string.isEmpty(tagName)) then
|
||||||
|
self.currentStep:addTag(tagName)
|
||||||
|
self:startTagAction(tagName)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:endChoregraphy()
|
self:endChoregraphy()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ChoregraphySystem:parseStep(step)
|
||||||
|
local tagName = ""
|
||||||
|
if (step[1] == "taggedAction") then
|
||||||
|
tagName = step[2]
|
||||||
|
step = step[3]
|
||||||
|
end
|
||||||
|
local stepData = core.datas:parse("choregraphystep", step)
|
||||||
|
core.debug:print("cbs/choregraphy", "Starting step " .. stepData.name)
|
||||||
|
return stepData, tagName
|
||||||
|
end
|
||||||
|
|
||||||
function ChoregraphySystem:checkCondition(condition)
|
function ChoregraphySystem:checkCondition(condition)
|
||||||
local conditionArgs = utils.string.split(condition, ":")
|
local conditionArgs = utils.string.split(condition, ":")
|
||||||
local success = true
|
local success = true
|
||||||
|
@ -80,6 +99,20 @@ function ChoregraphySystem:endQte(success)
|
||||||
table.insert(self.qte.list, success)
|
table.insert(self.qte.list, success)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ChoregraphySystem:testTagAction(tag, statut)
|
||||||
|
local tagStatut = self.finishedTagActions[tag] or 0
|
||||||
|
return (statut <= tagStatut)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ChoregraphySystem:startTagAction(tag)
|
||||||
|
self.finishedTagActions[tag] = ACTION_FINISHED
|
||||||
|
end
|
||||||
|
|
||||||
|
function ChoregraphySystem:finishTagAction(tag)
|
||||||
|
core.debug:print("choregraphy/step", "Tag action " .. tag .. " finished.")
|
||||||
|
self.finishedTagActions[tag] = ACTION_STARTED
|
||||||
|
end
|
||||||
|
|
||||||
function ChoregraphySystem:sendDamage(power, type, element, isSpecial)
|
function ChoregraphySystem:sendDamage(power, type, element, isSpecial)
|
||||||
if (self.target ~= nil) then
|
if (self.target ~= nil) then
|
||||||
if (self.fighter.isAlive) then
|
if (self.fighter.isAlive) then
|
||||||
|
|
|
@ -5,6 +5,14 @@ function StepParent:new(choregraphySystem, arguments, canBeAsync)
|
||||||
self.arguments = arguments
|
self.arguments = arguments
|
||||||
self.isStarted = false
|
self.isStarted = false
|
||||||
self.canBeAsync = (canBeAsync == true)
|
self.canBeAsync = (canBeAsync == true)
|
||||||
|
self.tag = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
function StepParent:addTag(tag)
|
||||||
|
if (self.canBeAsync) then
|
||||||
|
core.debug:print("choregraphy/step", "Tag " .. tag .. " added to step.")
|
||||||
|
self.tag = tag
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function StepParent:updateStep(dt)
|
function StepParent:updateStep(dt)
|
||||||
|
|
Loading…
Reference in a new issue