104 lines
3 KiB
Lua
104 lines
3 KiB
Lua
local BaseScreen = require "scenes.overworld.screens.parent"
|
|
local GameOver = BaseScreen:extend()
|
|
|
|
local TweenManager = require "birb.classes.time"
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
local tw, th = 128, 32
|
|
local ConfirmDialog = require "game.modules.confirmdialog"
|
|
|
|
|
|
local defTransitions = require "birb.modules.transitions"
|
|
local radTransitions = require "game.modules.transitions"
|
|
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
|
|
|
|
self.continue = false
|
|
self.continueValue = -1
|
|
end
|
|
|
|
function GameOver:prepareAnimation()
|
|
-- Label
|
|
self.tweens:newTween(0, 0.6, {labelOpacity=1}, 'inExpo')
|
|
self.tweens:newTween(0.9, 0.4, {labelX=4}, 'inExpo')
|
|
|
|
self.tweens:newSwitch(1.8, {"continue"})
|
|
end
|
|
|
|
function GameOver:update(dt)
|
|
self.tweens:update(dt)
|
|
|
|
if (self.continue) then
|
|
self.continue = false
|
|
|
|
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:draw()
|
|
local width, height = core.screen:getDimensions()
|
|
self:drawLabel(width/2, 48, self.labelX, self.labelOpacity)
|
|
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:drawContinueBox(x, y, continueValue, size, opacity)
|
|
love.graphics.setColor(1, 1, 1, opacity)
|
|
love.graphics.draw(self.continueBox, x, y, 0, size, size, tw/2, th/2)
|
|
local text = "continue"
|
|
if (continueValue == 1) then
|
|
text = "quit"
|
|
end
|
|
self.assets.images["arrow"]:draw(x - continueValue*64, y, math.rad(-90) * continueValue, continueValue, 1, 13, 13)
|
|
self.assets.fonts["SA2font"]:print(text, x, y-13, "center")
|
|
end
|
|
|
|
function GameOver:returnToTitle()
|
|
core.screen:startTransition(defTransitions.default, defTransitions.circle, function() scenes.menus.title(true) end, 424/2, 240/2)
|
|
end
|
|
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
|