2021-08-21 17:00:42 +02:00
|
|
|
local Scene = require("game.scenes")
|
2020-08-16 10:52:00 +02:00
|
|
|
local PlayStyle = Scene:extend()
|
|
|
|
|
2022-01-06 18:57:42 +01:00
|
|
|
local TweenManager = require "birb.classes.time"
|
|
|
|
local PauseScreen = require("game.modules.subgames.pause")
|
2021-08-15 15:39:16 +02:00
|
|
|
local TestWorld = require("game.modules.subgames.world.parent")
|
2020-08-16 10:52:00 +02:00
|
|
|
|
|
|
|
function PlayStyle:new(supportedLevels, missionfile)
|
2022-01-06 18:57:42 +01:00
|
|
|
PlayStyle.super.new(self, false, false)
|
2020-08-16 10:52:00 +02:00
|
|
|
self.timer = 0
|
2021-08-15 16:01:25 +02:00
|
|
|
self.assets:batchImport("assets.subgames")
|
2020-08-16 10:52:00 +02:00
|
|
|
--self:loadMissionFile(supportedLevels, missionfile)
|
|
|
|
|
|
|
|
self:initWorld()
|
|
|
|
self:initMission()
|
|
|
|
self:initCharacters()
|
|
|
|
|
2022-01-06 18:57:42 +01:00
|
|
|
self.tweens = TweenManager(self)
|
|
|
|
PauseScreen()
|
|
|
|
|
2020-08-16 11:03:06 +02:00
|
|
|
self.haveStarted = false
|
2022-01-06 18:57:42 +01:00
|
|
|
self.canPause = true
|
2020-08-16 10:52:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:loadMissionFile(supportedLevels, missionfile)
|
|
|
|
self.mission = require("datas.gamedata.missions." .. missionfile)
|
|
|
|
self.assets:setMusic("assets/music/" .. self.mission.music)
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:initWorld()
|
|
|
|
TestWorld(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:initMission()
|
|
|
|
-- NOTHING
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:initCharacters()
|
|
|
|
self.world:setPlayerNumber(1)
|
|
|
|
self.world.cameras:setMode("split")
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:getCharacterName(charID)
|
|
|
|
return self.characterList[charID]
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:update(dt)
|
2020-08-16 11:03:06 +02:00
|
|
|
if (self.haveStarted) then
|
|
|
|
PlayStyle.super.update(self, dt)
|
|
|
|
self:updatePauseMenus(dt)
|
|
|
|
else
|
|
|
|
self:startLevel()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:updatePauseMenus(dt)
|
2022-01-06 18:57:42 +01:00
|
|
|
self.tweens:update(dt)
|
|
|
|
if self.gui.screens["pauseScreen"].isVisible == false then
|
2020-08-16 10:52:00 +02:00
|
|
|
self.timer = self.timer + dt
|
|
|
|
end
|
|
|
|
|
|
|
|
local keys = self:getKeys(1);
|
|
|
|
|
2022-01-06 18:57:42 +01:00
|
|
|
|
|
|
|
if (keys["start"].isPressed and self.canPause) then
|
|
|
|
if (not self.isPaused) then
|
|
|
|
if (not self.gui.screens["overlay"].isVisible) then
|
|
|
|
self.assets.sfx["mSelect"]:play()
|
|
|
|
self:pause()
|
|
|
|
end
|
2020-08-16 10:52:00 +02:00
|
|
|
else
|
2022-01-06 18:57:42 +01:00
|
|
|
self.assets.sfx["mBack"]:play()
|
|
|
|
self:unpause()
|
2020-08-16 10:52:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-06 18:57:42 +01:00
|
|
|
|
|
|
|
function PlayStyle:timerResponse(timer)
|
|
|
|
if (timer == "unPause") then
|
|
|
|
self.isPaused = false
|
|
|
|
self.world.isActive = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:pause()
|
|
|
|
self.gui:showScreen("overlay")
|
|
|
|
self.gui:showScreen("pauseScreen")
|
|
|
|
self.gui:playScreenTransform("overlay", "showBackgroundPause")
|
|
|
|
self.isPaused = true
|
|
|
|
self.world.isActive = false
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:unpause()
|
|
|
|
self.tweens:newTimer(0.2, "unPause")
|
|
|
|
self.gui:playScreenTransform("overlay", "hideBackgroundPause")
|
|
|
|
self.gui:hideScreen("overlay")
|
|
|
|
self.gui:hideScreen("pauseScreen")
|
|
|
|
end
|
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
function PlayStyle:startLevel()
|
2020-08-16 11:03:06 +02:00
|
|
|
self.haveStarted = true
|
2020-08-16 10:52:00 +02:00
|
|
|
self.world:loadMap()
|
|
|
|
--self.assets:playMusic()
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:restartLevel()
|
2022-01-06 18:57:42 +01:00
|
|
|
self:unpause()
|
2020-08-16 10:52:00 +02:00
|
|
|
self.world:reset()
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayStyle:exitLevel()
|
2021-08-15 16:26:05 +02:00
|
|
|
scenes.menus.title()
|
2020-08-16 10:52:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return PlayStyle
|