sonic-radiance/sonic-radiance.love/scenes/battlesystem/init.lua

83 lines
1.7 KiB
Lua
Raw Permalink Normal View History

local Scene = require "core.modules.scenes"
local BattleSystem = Scene:extend()
local World = require "scenes.battlesystem.world"
local MenuSystem = require "scenes.battlesystem.menu"
2020-05-01 14:50:21 +02:00
local Turns = require "scenes.battlesystem.controllers"
2020-05-01 14:19:00 +02:00
local HUD = require "scenes.battlesystem.gui.hud"
local VictoryScreen = require "scenes.battlesystem.screens.victory"
function BattleSystem:new()
BattleSystem.super.new(self)
2019-08-14 13:56:25 +02:00
self.assets:batchImport("scenes.battlesystem.assets")
2019-08-19 12:00:24 +02:00
self.assets:setMusic("assets/music/battle1.mp3")
self.assets:playMusic()
self:initManagers()
self:register()
self:startBattle()
self.screen = nil
end
function BattleSystem:initManagers()
self.datas = {}
self.world = World(self)
self.menu = MenuSystem(self)
2020-05-01 14:50:21 +02:00
self.turns = Turns(self)
2020-05-01 14:19:00 +02:00
self.hud = HUD(self)
end
function BattleSystem:startBattle()
2020-05-01 14:50:21 +02:00
self.turns:startBattle()
2020-05-01 14:19:00 +02:00
self.hud:movePlayerHUD(true)
end
function BattleSystem:finishBattle()
2020-05-01 14:19:00 +02:00
self.hud:movePlayerHUD(false)
2019-08-19 12:00:24 +02:00
self.assets:setMusic("assets/music/victory.mp3")
self.assets:playMusic()
self.screen = VictoryScreen(self)
end
function BattleSystem:haveMenus()
for k,v in pairs(self.menusystem.menus) do
return true
end
return false
end
function BattleSystem:update(dt)
self.world:update(dt)
2020-05-01 14:50:21 +02:00
self.turns:update(dt)
2020-05-01 14:19:00 +02:00
self.hud:update(dt)
if (self.screen ~= nil) then
self.screen:update(dt)
end
end
function BattleSystem:draw()
self.world:draw()
2020-05-01 14:19:00 +02:00
self.hud:draw()
if (self.screen ~= nil) then
self.screen:draw()
end
end
function BattleSystem:exit()
self.world:destroy()
self.battlearena = nil
collectgarbage()
end
return BattleSystem