feat: add basic choregraphy system

Fix #12
This commit is contained in:
Kazhnuz 2020-08-03 17:59:44 +02:00
parent f867cba68d
commit b5c6cf0b1f
6 changed files with 87 additions and 5 deletions

View file

@ -4,6 +4,7 @@ local menu = require "scenes.debug.viewers.choregraphy.menu"
local ChoregraphyViewer = Scene:extend() local ChoregraphyViewer = Scene:extend()
local World = require "scenes.battlesystem.world" local World = require "scenes.battlesystem.world"
local Fighter = require "scenes.debug.viewers.choregraphy.mocks.fighter"
function ChoregraphyViewer:new() function ChoregraphyViewer:new()
@ -12,6 +13,7 @@ function ChoregraphyViewer:new()
self.world = World(self) self.world = World(self)
self:buildMenu() self:buildMenu()
self:buildMocks()
end end
-- MENU FUNCTIONS -- MENU FUNCTIONS
@ -57,14 +59,18 @@ function ChoregraphyViewer:addSubMenu(submenu, parent, name)
end end
-- MOCKS FUNCTIONS -- MOCKS FUNCTIONS
function ChoregraphyViewer:buildMocks()
self.fighter = Fighter(self)
end
function ChoregraphyViewer:playHeroChoregraphy(character, data)
self.fighter:playHeroChoregraphy(character, data)
end
-- OTHER -- OTHER
function ChoregraphyViewer:update(dt) function ChoregraphyViewer:update(dt)
self.fighter:update(dt)
end self.world:update(dt)
function ChoregraphyViewer:setBackground(newBackground)
end end
function ChoregraphyViewer:draw() function ChoregraphyViewer:draw()

View file

@ -23,6 +23,7 @@ function menu.HeroChoregraphyWidget:new(scene, charName, skillData)
end end
function menu.HeroChoregraphyWidget:action() function menu.HeroChoregraphyWidget:action()
self.scene:playHeroChoregraphy(self.character, self.skillData)
self.scene.menusystem:deactivate() self.scene.menusystem:deactivate()
end end

View file

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

View file

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

View file

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

View file

@ -0,0 +1,11 @@
local TurnSystemMock = Object:extend()
function TurnSystemMock:new()
end
function TurnSystemMock:applyDeath()
end
return TurnSystemMock