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"
|
2019-03-10 13:26:20 +01:00
|
|
|
|
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)
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-08-16 18:33:47 +02:00
|
|
|
function BattleSystem:startBattle()
|
|
|
|
self.world:startBattle()
|
|
|
|
end
|
|
|
|
|
|
|
|
function BattleSystem:finishBattle()
|
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-03-10 13:11:26 +01:00
|
|
|
function BattleSystem:update(dt)
|
2019-08-14 16:26:23 +02:00
|
|
|
self.world: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()
|
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
|