From b95ad72dcb9669c0008611e5908091a342d29e18 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 31 Jul 2020 20:06:35 +0200 Subject: [PATCH] feat: add basic qte framework --- .../datas/gamedata/skills/attack.lua | 4 ++ .../game/utils/choregraphy/arguments.lua | 1 + .../game/utils/choregraphy/init.lua | 48 ++++++++++++++++++- .../game/utils/choregraphy/qte.lua | 3 ++ .../fighters/systems/choregraphy/init.lua | 18 +++++++ .../fighters/systems/choregraphy/qte/init.lua | 5 ++ .../systems/choregraphy/step/addQTE.lua | 26 ++++++++++ .../systems/choregraphy/step/init.lua | 1 + 8 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 sonic-radiance.love/game/utils/choregraphy/qte.lua create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/init.lua create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/addQTE.lua diff --git a/sonic-radiance.love/datas/gamedata/skills/attack.lua b/sonic-radiance.love/datas/gamedata/skills/attack.lua index 54c43e9..d3ba280 100644 --- a/sonic-radiance.love/datas/gamedata/skills/attack.lua +++ b/sonic-radiance.love/datas/gamedata/skills/attack.lua @@ -14,6 +14,8 @@ return { choregraphy = { -- the main attack choregraphy {"setAnimation", "none", "walk", false}, {'goTo', "none", "target", -1, 0, 0.3, true}, + + {"addQTE", "none", {"simplePrompt", "A", 0.2}, "target", false}, {'playSFX', "none", 'hit'}, {'setAnimation', "none", 'hit1start', true}, {'sendDamage', "none", 33, 100, false, false}, @@ -21,6 +23,7 @@ return { {'playSFX', "sentDamage", 'hitconnect'}, {'setAnimation', "none", 'hit1end', true}, + {"addQTE", "none", {"simplePrompt", "A", 0.2}, "target", false}, {'playSFX', "none", 'hit'}, {'setAnimation', "none", 'hit2start', true}, {'sendDamage', "none", 33, 100, false, false}, @@ -28,6 +31,7 @@ return { {'playSFX', "sentDamage", 'hitconnect'}, {'setAnimation', "none", 'hit2end', true}, + {"addQTE", "none", {"simplePrompt", "A", 0.2}, "target", false}, {'playSFX', "none", 'hit'}, {'setAnimation', "none", 'hit3start', true}, {'sendDamage', "none", 33, 100, false, false}, diff --git a/sonic-radiance.love/game/utils/choregraphy/arguments.lua b/sonic-radiance.love/game/utils/choregraphy/arguments.lua index 8a4d3f2..a400c51 100644 --- a/sonic-radiance.love/game/utils/choregraphy/arguments.lua +++ b/sonic-radiance.love/game/utils/choregraphy/arguments.lua @@ -9,6 +9,7 @@ return { ["jumpTo"] = {"origin", "x", "y", "duration", "blockProcess"}, ["jumpBack"] = {"duration", "blockProcess"}, ["waitActorFinished"] = {"waitFor"}, + ["addQTE"] = {"qteData", "origin", "blockProcess"} --[name] = {args}, } diff --git a/sonic-radiance.love/game/utils/choregraphy/init.lua b/sonic-radiance.love/game/utils/choregraphy/init.lua index 5aa85a0..5f8f831 100644 --- a/sonic-radiance.love/game/utils/choregraphy/init.lua +++ b/sonic-radiance.love/game/utils/choregraphy/init.lua @@ -1,5 +1,7 @@ ChoregraphyUtils = {} +-- steps utils + function ChoregraphyUtils.getStepStructure(stepName) local stepTypeList = require "game.utils.choregraphy.arguments" return stepTypeList[stepName] @@ -9,7 +11,7 @@ function ChoregraphyUtils.stepExists(stepName) return (ChoregraphyUtils.getStepStructure(stepName) ~= nil) end -function ChoregraphyUtils.validate(stepBaseDatas) +function ChoregraphyUtils.validateStep(stepBaseDatas) local structure = ChoregraphyUtils.getStepStructure(stepBaseDatas[1]) if (structure == nil) then return false @@ -23,7 +25,7 @@ function ChoregraphyUtils.getStepDatas(stepBaseDatas) local stepData = {} stepData.name = stepBaseDatas[1] - if (ChoregraphyUtils.validate(stepBaseDatas)) then + if (ChoregraphyUtils.validateStep(stepBaseDatas)) then stepData.condition = stepBaseDatas[2] local structure = ChoregraphyUtils.getStepStructure(stepData.name) @@ -42,4 +44,46 @@ function ChoregraphyUtils.getStepDatas(stepBaseDatas) end +-- QTE utils + +function ChoregraphyUtils.getQteStructure(qteName) + local stepTypeList = require "game.utils.choregraphy.qte" + return stepTypeList[qteName] +end + +function ChoregraphyUtils.qteExists(qteName) + return (ChoregraphyUtils.getQteStructure(qteName) ~= nil) +end + +function ChoregraphyUtils.validateQte(qteBaseDatas) + local structure = ChoregraphyUtils.getQteStructure(qteBaseDatas[1]) + if (structure == nil) then + return false + else + return ((#structure + 1) == #qteBaseDatas) + end +end + +function ChoregraphyUtils.getQteDatas(qteBaseDatas) + + local qteData = {} + qteData.name = qteBaseDatas[1] + + if (ChoregraphyUtils.validateQte(qteBaseDatas)) then + local structure = ChoregraphyUtils.getQteStructure(qteData.name) + + qteData.arguments = {} + + for i, argumentName in ipairs(structure) do + local argumentContent = qteBaseDatas[i + 1] + qteData.arguments[argumentName] = argumentContent + end + + return qteData + else + error("Le QTE " .. qteData.name .. " à un nbr d'argument incorrect") + end + +end + return ChoregraphyUtils diff --git a/sonic-radiance.love/game/utils/choregraphy/qte.lua b/sonic-radiance.love/game/utils/choregraphy/qte.lua new file mode 100644 index 0000000..4414f08 --- /dev/null +++ b/sonic-radiance.love/game/utils/choregraphy/qte.lua @@ -0,0 +1,3 @@ +return { + ["simplePrompt"] = {"key", "duration"} +} 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 47ad32b..9d47bb8 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 @@ -2,6 +2,7 @@ local ChoregraphySystem = Object:extend() local choregraphyUtils = require "game.utils.choregraphy" local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step" +local qteObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.qte" function ChoregraphySystem:new(action, choregraphy) self.action = action @@ -14,9 +15,17 @@ function ChoregraphySystem:new(action, choregraphy) self.currentStepId = 0 self.currentStep = nil self.stepList = choregraphy + + self.qte = {} + self.qte.current = nil + self.qte.wasSuccess = false end function ChoregraphySystem:update(dt) + if (self.qte.current ~= nil) then + self.qte.current:update(dt) + end + if (self.currentStep ~= nil) then self.currentStep:updateStep(dt) else @@ -37,6 +46,15 @@ function ChoregraphySystem:switchStep() end end +function ChoregraphySystem:addQTE(action, origin, qteBaseData, blockProcess) + local qteData = choregraphyUtils.getQteDatas(qteBaseData) + if (qteObjectList[qteData.name] ~= nil) then + self.qte.current = qteObjectList[qteData.name](self, qteData.arguments, action) + self.qte.current:blockAction(action, blockProcess) + self.qte.current:setOrigin(origin) + end +end + function ChoregraphySystem:sendDamage(power, accuracy, isSpecial, isAerial) if (self.target ~= nil) then if (self.fighter.isAlive) then diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/init.lua new file mode 100644 index 0000000..c3e7f9f --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/init.lua @@ -0,0 +1,5 @@ +local qtes = {} + +local baseURI = "scenes.battlesystem.controllers.fighters.systems.choregraphy.qte." + +return qtes diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/addQTE.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/addQTE.lua new file mode 100644 index 0000000..13fd8f5 --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/addQTE.lua @@ -0,0 +1,26 @@ +local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent" +local StepQTE = StepParent:extend() + +function StepQTE:new(controller, args) + StepQTE.super.new(self, controller, args) +end + +function StepQTE:start() + self.choregraphy:addQTE(self, self.arguments.origin, self.arguments.qteData, self.arguments.blockProcess) + if (not self.arguments.blockProcess) then + self:finish() + end +end + +function StepQTE:update(dt) + +end + +function StepQTE:getSignal(signal) + if (signal == "gfxEnded") then + self:finish() + end +end + + +return StepQTE 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 index 2dd3b8c..a827847 100644 --- 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 @@ -3,6 +3,7 @@ local actions = {} local baseURI = "scenes.battlesystem.controllers.fighters.systems.choregraphy.step." actions["addGFX"] = require(baseURI .. "addGFX") +actions["addQTE"] = require(baseURI .. "addQTE") actions["goTo"] = require(baseURI .. "goTo") actions["jumpBack"] = require(baseURI .. "jumpBack") actions["playSFX"] = require(baseURI .. "playSFX")