2019-03-10 13:26:20 +01:00
|
|
|
local Scene = require "core.modules.scenes"
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-03-10 13:26:20 +01:00
|
|
|
local BattleSystem = Scene:extend()
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
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"
|
2019-03-10 13:26:20 +01:00
|
|
|
|
2020-05-01 14:19:00 +02:00
|
|
|
local HUD = require "scenes.battlesystem.gui.hud"
|
|
|
|
|
2019-08-16 22:37:43 +02:00
|
|
|
local VictoryScreen = require "scenes.battlesystem.screens.victory"
|
|
|
|
|
2019-03-10 13:26:20 +01:00
|
|
|
function BattleSystem:new()
|
2019-03-10 13:33:38 +01:00
|
|
|
BattleSystem.super.new(self)
|
2019-08-14 13:56:25 +02:00
|
|
|
|
2019-08-13 21:08:37 +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()
|
|
|
|
|
2019-03-10 13:26:20 +01:00
|
|
|
self:initManagers()
|
2019-03-10 13:33:38 +01:00
|
|
|
|
|
|
|
self:register()
|
2019-08-16 18:33:47 +02:00
|
|
|
|
|
|
|
self:startBattle()
|
2019-08-16 22:37:43 +02:00
|
|
|
|
|
|
|
self.screen = nil
|
2019-03-10 13:26:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function BattleSystem:initManagers()
|
|
|
|
self.datas = {}
|
2019-08-14 16:26:23 +02:00
|
|
|
self.world = World(self)
|
2019-03-23 11:51:47 +01:00
|
|
|
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)
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-08-16 18:33:47 +02:00
|
|
|
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)
|
2019-08-16 18:33:47 +02:00
|
|
|
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()
|
2019-08-16 22:37:43 +02:00
|
|
|
self.screen = VictoryScreen(self)
|
2019-08-16 18:33:47 +02:00
|
|
|
end
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function BattleSystem:haveMenus()
|
|
|
|
for k,v in pairs(self.menusystem.menus) do
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2019-03-10 13:11:26 +01:00
|
|
|
function BattleSystem:update(dt)
|
2019-08-14 16:26:23 +02:00
|
|
|
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)
|
2019-08-16 22:37:43 +02:00
|
|
|
if (self.screen ~= nil) then
|
|
|
|
self.screen:update(dt)
|
|
|
|
end
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function BattleSystem:draw()
|
2019-08-14 16:26:23 +02:00
|
|
|
self.world:draw()
|
2020-05-01 14:19:00 +02:00
|
|
|
self.hud:draw()
|
2019-08-16 22:37:43 +02:00
|
|
|
if (self.screen ~= nil) then
|
|
|
|
self.screen:draw()
|
|
|
|
end
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-03-10 13:26:20 +01:00
|
|
|
function BattleSystem:exit()
|
|
|
|
self.world:destroy()
|
|
|
|
self.battlearena = nil
|
2019-03-10 13:11:26 +01:00
|
|
|
|
|
|
|
collectgarbage()
|
|
|
|
end
|
|
|
|
|
|
|
|
return BattleSystem
|