82 lines
1.7 KiB
Lua
82 lines
1.7 KiB
Lua
local Scene = require "core.modules.scenes"
|
|
|
|
local BattleSystem = Scene:extend()
|
|
|
|
local World = require "scenes.battlesystem.world"
|
|
local MenuSystem = require "scenes.battlesystem.menu"
|
|
local Turns = require "scenes.battlesystem.controllers"
|
|
|
|
local HUD = require "scenes.battlesystem.gui.hud"
|
|
|
|
local VictoryScreen = require "scenes.battlesystem.screens.victory"
|
|
|
|
function BattleSystem:new()
|
|
BattleSystem.super.new(self)
|
|
|
|
self.assets:batchImport("scenes.battlesystem.assets")
|
|
|
|
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)
|
|
self.turns = Turns(self)
|
|
|
|
self.hud = HUD(self)
|
|
end
|
|
|
|
function BattleSystem:startBattle()
|
|
self.turns:startBattle()
|
|
self.hud:movePlayerHUD(true)
|
|
end
|
|
|
|
function BattleSystem:finishBattle()
|
|
self.hud:movePlayerHUD(false)
|
|
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)
|
|
self.turns:update(dt)
|
|
self.hud:update(dt)
|
|
if (self.screen ~= nil) then
|
|
self.screen:update(dt)
|
|
end
|
|
end
|
|
|
|
function BattleSystem:draw()
|
|
self.world:draw()
|
|
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
|