2021-04-19 18:04:29 +02:00
|
|
|
local BaseScreen = require "scenes.overworld.screens.parent"
|
|
|
|
local GameOver = BaseScreen:extend()
|
|
|
|
|
2021-05-05 11:41:25 +02:00
|
|
|
local TweenManager = require "birb.classes.time"
|
2021-04-19 18:04:29 +02:00
|
|
|
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
|
|
|
|
local tw, th = 128, 32
|
|
|
|
|
2021-05-05 08:30:32 +02:00
|
|
|
local defTransitions = require "birb.modules.transitions"
|
2021-04-19 18:04:29 +02:00
|
|
|
local ConfirmDialog = require "game.modules.confirmdialog"
|
|
|
|
|
|
|
|
function GameOver:new(scene)
|
|
|
|
GameOver.super.new(self, scene, "")
|
|
|
|
self.assets = scene.assets
|
|
|
|
self.turnSystem = scene.turns
|
|
|
|
|
|
|
|
self:setVariables()
|
|
|
|
|
|
|
|
self.continueBox = gui.newTextBox("assets/gui/dialogbox.png", tw, th)
|
|
|
|
|
|
|
|
self.tweens = TweenManager(self)
|
|
|
|
self:prepareAnimation()
|
|
|
|
end
|
|
|
|
|
|
|
|
function GameOver:setVariables()
|
|
|
|
-- Vignette Opacity
|
|
|
|
self.vignetteOpacity = 0
|
|
|
|
|
|
|
|
-- Battle FInished Label
|
|
|
|
self.labelOpacity = 0
|
|
|
|
local width, height = core.screen:getDimensions()
|
|
|
|
self.labelX = width/2
|
|
|
|
|
|
|
|
-- Infobox
|
|
|
|
self.tbSize = 0.6
|
|
|
|
self.tbOpacity = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function GameOver:prepareAnimation()
|
|
|
|
-- Label
|
|
|
|
self.tweens:newTween(0, 0.6, {labelOpacity=1}, 'inExpo')
|
|
|
|
self.tweens:newTween(0.9, 0.4, {labelX=4}, 'inExpo')
|
|
|
|
|
2021-08-15 20:37:12 +02:00
|
|
|
self.tweens:newTimer(1.8, "continue")
|
2021-04-19 18:04:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function GameOver:update(dt)
|
|
|
|
self.tweens:update(dt)
|
2021-08-15 20:37:12 +02:00
|
|
|
end
|
2021-04-19 18:04:29 +02:00
|
|
|
|
2021-08-15 20:37:12 +02:00
|
|
|
function GameOver:draw()
|
|
|
|
local width, height = core.screen:getDimensions()
|
|
|
|
self:drawVignette(width, height)
|
|
|
|
self:drawLabel(width/2, 48, self.labelX, self.labelOpacity)
|
|
|
|
end
|
2021-04-19 18:04:29 +02:00
|
|
|
|
2021-08-15 20:37:12 +02:00
|
|
|
function GameOver:timerResponse(timer)
|
|
|
|
if (timer == "continue") then
|
2021-04-19 18:04:29 +02:00
|
|
|
local confirm = ConfirmDialog(self.scene, "Do you want to return to title ? \nYou can also reload your latest save.",
|
|
|
|
function() self:returnToTitle() end, "Return to title",
|
|
|
|
function() self:loadLastSave() end, "Reload last save")
|
|
|
|
confirm.darken = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function GameOver:drawVignette(width, height)
|
|
|
|
love.graphics.setColor(0, 0, 0, self.vignetteOpacity)
|
|
|
|
|
|
|
|
love.graphics.rectangle("fill", 0, 0, width, height)
|
|
|
|
end
|
|
|
|
|
|
|
|
function GameOver:drawLabel(x, y, x2, opacity)
|
|
|
|
love.graphics.setColor(1, 1, 1, opacity)
|
|
|
|
|
|
|
|
self.assets.fonts["SA2font"]:print("GAME", x - x2, y, "right")
|
|
|
|
self.assets.fonts["SA2font"]:print("OVER", x + x2, y, "left")
|
|
|
|
end
|
|
|
|
|
|
|
|
function GameOver:returnToTitle()
|
2021-08-15 16:26:05 +02:00
|
|
|
core.screen:startTransition(defTransitions.default, defTransitions.circle, function() scenes.menus.title(true) end, 424/2, 240/2)
|
2021-04-19 18:04:29 +02:00
|
|
|
end
|
2021-08-15 20:37:12 +02:00
|
|
|
|
2021-04-19 18:04:29 +02:00
|
|
|
function GameOver:loadLastSave()
|
|
|
|
self.scene.tweens:newTween(0, 0.3, {borderPosition=0}, "inOutQuad")
|
|
|
|
core.screen:startTransition(defTransitions.default, defTransitions.default, function() game:reload() scenes.overworld() end, 424/2, 240/2)
|
|
|
|
end
|
|
|
|
|
|
|
|
return GameOver
|