From b5c6cf0b1f95938b29560f679ac771b261d369c4 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 3 Aug 2020 17:59:44 +0200 Subject: [PATCH] feat: add basic choregraphy system Fix #12 --- .../scenes/debug/viewers/choregraphy/init.lua | 16 ++++++--- .../scenes/debug/viewers/choregraphy/menu.lua | 1 + .../viewers/choregraphy/mocks/action.lua | 20 +++++++++++ .../viewers/choregraphy/mocks/fighter.lua | 36 +++++++++++++++++++ .../viewers/choregraphy/mocks/target.lua | 8 +++++ .../viewers/choregraphy/mocks/turnSystem.lua | 11 ++++++ 6 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/action.lua create mode 100644 sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/fighter.lua create mode 100644 sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/target.lua create mode 100644 sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/turnSystem.lua diff --git a/sonic-radiance.love/scenes/debug/viewers/choregraphy/init.lua b/sonic-radiance.love/scenes/debug/viewers/choregraphy/init.lua index 63f7e76..a2cb458 100644 --- a/sonic-radiance.love/scenes/debug/viewers/choregraphy/init.lua +++ b/sonic-radiance.love/scenes/debug/viewers/choregraphy/init.lua @@ -4,6 +4,7 @@ local menu = require "scenes.debug.viewers.choregraphy.menu" local ChoregraphyViewer = Scene:extend() local World = require "scenes.battlesystem.world" +local Fighter = require "scenes.debug.viewers.choregraphy.mocks.fighter" function ChoregraphyViewer:new() @@ -12,6 +13,7 @@ function ChoregraphyViewer:new() self.world = World(self) self:buildMenu() + self:buildMocks() end -- MENU FUNCTIONS @@ -57,14 +59,18 @@ function ChoregraphyViewer:addSubMenu(submenu, parent, name) end -- MOCKS FUNCTIONS +function ChoregraphyViewer:buildMocks() + self.fighter = Fighter(self) +end + +function ChoregraphyViewer:playHeroChoregraphy(character, data) + self.fighter:playHeroChoregraphy(character, data) +end -- OTHER function ChoregraphyViewer:update(dt) - -end - -function ChoregraphyViewer:setBackground(newBackground) - + self.fighter:update(dt) + self.world:update(dt) end function ChoregraphyViewer:draw() diff --git a/sonic-radiance.love/scenes/debug/viewers/choregraphy/menu.lua b/sonic-radiance.love/scenes/debug/viewers/choregraphy/menu.lua index 305c5b2..8a370ee 100644 --- a/sonic-radiance.love/scenes/debug/viewers/choregraphy/menu.lua +++ b/sonic-radiance.love/scenes/debug/viewers/choregraphy/menu.lua @@ -23,6 +23,7 @@ function menu.HeroChoregraphyWidget:new(scene, charName, skillData) end function menu.HeroChoregraphyWidget:action() + self.scene:playHeroChoregraphy(self.character, self.skillData) self.scene.menusystem:deactivate() end diff --git a/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/action.lua b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/action.lua new file mode 100644 index 0000000..859c3b8 --- /dev/null +++ b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/action.lua @@ -0,0 +1,20 @@ +local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent" +local ActionMock = ActionParent:extend() + +local ChoregraphySystem = require "scenes.battlesystem.controllers.fighters.systems.choregraphy" + +function ActionMock:new(fighter, data) + ActionMock.super.new(self, fighter) + self.data = data +end + +function ActionMock:needTarget() + return (self.data.targetNumber == 1), self.data.targetEnnemies +end + +function ActionMock:startAction() + core.debug:print("cbs/action", "Starting mock action") + self:loadChoregraphyFromSkill(self.data) +end + +return ActionMock diff --git a/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/fighter.lua b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/fighter.lua new file mode 100644 index 0000000..2cf05e2 --- /dev/null +++ b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/fighter.lua @@ -0,0 +1,36 @@ +local FighterMock = Object:extend() + +local ActionMock = require "scenes.debug.viewers.choregraphy.mocks.action" +local TargetMock = require "scenes.debug.viewers.choregraphy.mocks.target" +local TurnSystemMock = require "scenes.debug.viewers.choregraphy.mocks.turnSystem" + +function FighterMock:new(scene) + self.scene = scene + self.action = nil + self.actor = nil + self.turnSystem = TurnSystemMock() +end + +function FighterMock:update(dt) + if (self.action ~= nil) then + self.action:update(dt) + end +end + +function FighterMock:playHeroChoregraphy(character, data) + self.name = character + self.abstract = game.characters.list[character] + self.actor = self.scene.world.obj.Hero(self.scene.world, 2, 3, self, 1) + self.action = ActionMock(self, data) + self.action:setTarget(TargetMock(self.scene)) + self.action:start() +end + +function FighterMock:finishAction() + self.action.target.actor:destroy() + self.actor:destroy() + self.action = nil + self.scene.menusystem:activate() +end + +return FighterMock diff --git a/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/target.lua b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/target.lua new file mode 100644 index 0000000..35d08f6 --- /dev/null +++ b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/target.lua @@ -0,0 +1,8 @@ +local TargetMock = Object:extend() + +function TargetMock:new(scene) + self.scene = scene + self.actor = self.scene.world.obj.Battler(self.scene.world, 11, 3, 0, self) +end + +return TargetMock diff --git a/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/turnSystem.lua b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/turnSystem.lua new file mode 100644 index 0000000..dc93f38 --- /dev/null +++ b/sonic-radiance.love/scenes/debug/viewers/choregraphy/mocks/turnSystem.lua @@ -0,0 +1,11 @@ +local TurnSystemMock = Object:extend() + +function TurnSystemMock:new() + +end + +function TurnSystemMock:applyDeath() + +end + +return TurnSystemMock