2020-08-07 11:17:10 +02:00
|
|
|
local VictoryScreen = Object:extend()
|
|
|
|
|
2021-05-05 11:41:25 +02:00
|
|
|
local TweenManager = require "birb.classes.time"
|
2021-08-15 17:41:39 +02:00
|
|
|
local ConfirmDialog = require "game.modules.confirmdialog"
|
2020-08-07 11:17:10 +02:00
|
|
|
|
2021-08-15 17:41:39 +02:00
|
|
|
local defTransitions = require "birb.modules.transitions"
|
|
|
|
local radTransitions = require "game.modules.transitions"
|
2020-08-07 11:17:10 +02:00
|
|
|
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
|
|
|
|
local tw, th = 128, 32
|
|
|
|
|
|
|
|
function VictoryScreen:new(scene)
|
|
|
|
self.scene = 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 VictoryScreen: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 VictoryScreen:prepareAnimation()
|
|
|
|
-- Vignette
|
|
|
|
self.tweens:newTween(0, 0.6, {vignetteOpacity=0.75}, 'inExpo')
|
|
|
|
|
|
|
|
-- Label
|
|
|
|
self.tweens:newTween(0, 0.6, {labelOpacity=1}, 'inExpo')
|
|
|
|
self.tweens:newTween(0.9, 0.4, {labelX=4}, 'inExpo')
|
|
|
|
|
|
|
|
-- Infobox
|
|
|
|
self.tweens:newTween(1.4, 0.4, {tbSize=1, tbOpacity=1}, 'inExpo')
|
|
|
|
|
2021-08-15 17:41:39 +02:00
|
|
|
self.tweens:newTimer(1.8, "continue")
|
2020-08-07 11:17:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function VictoryScreen:update(dt)
|
|
|
|
self.tweens:update(dt)
|
|
|
|
|
|
|
|
if (self.continue) then
|
|
|
|
local keys = self.scene:getKeys(1)
|
|
|
|
if (keys["left"].isPressed) then
|
|
|
|
self.continueValue = -1
|
|
|
|
end
|
|
|
|
if (keys["right"].isPressed) then
|
|
|
|
self.continueValue = 1
|
|
|
|
end
|
|
|
|
if (keys["A"].isPressed) then
|
|
|
|
--placeholder, pour l'instant on retourne juste au menu
|
2021-08-15 16:26:05 +02:00
|
|
|
scenes.menus.main()
|
2020-08-07 11:17:10 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function VictoryScreen:draw()
|
|
|
|
local width, height = core.screen:getDimensions()
|
|
|
|
self:drawVignette(width, height)
|
|
|
|
self:drawLabel(width/2, height/4, self.labelX, self.labelOpacity)
|
2021-08-15 17:41:39 +02:00
|
|
|
end
|
2020-08-07 11:17:10 +02:00
|
|
|
|
2021-08-15 17:41:39 +02:00
|
|
|
function VictoryScreen:timerResponse(timer)
|
|
|
|
if (timer == "continue") then
|
|
|
|
local confirm = ConfirmDialog(self.scene, "Do you want to continue ?",
|
|
|
|
function() self:toOverworld() end, "Yes",
|
|
|
|
function() self:toTitleScreen() end, "No")
|
|
|
|
confirm.darken = false
|
|
|
|
end
|
2020-08-07 11:17:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function VictoryScreen:drawVignette(width, height)
|
|
|
|
love.graphics.setColor(0, 0, 0, self.vignetteOpacity)
|
|
|
|
|
|
|
|
love.graphics.rectangle("fill", 0, 0, width, height)
|
|
|
|
end
|
|
|
|
|
2021-08-15 17:41:39 +02:00
|
|
|
function VictoryScreen:toOverworld()
|
|
|
|
core.screen:startTransition(radTransitions.borders, defTransitions.default, function()
|
|
|
|
game:reload()
|
|
|
|
scenes.overworld()
|
|
|
|
end, 424/2, 240/2)
|
|
|
|
end
|
|
|
|
|
|
|
|
function VictoryScreen:toTitleScreen()
|
|
|
|
core.screen:startTransition(radTransitions.borders, radTransitions.borders, function() scenes.menus.title(false) end, 424/2, 240/2)
|
|
|
|
end
|
|
|
|
|
2020-08-07 11:17:10 +02:00
|
|
|
function VictoryScreen:drawLabel(x, y, x2, opacity)
|
|
|
|
love.graphics.setColor(1, 1, 1, opacity)
|
|
|
|
|
|
|
|
local w, h = self.assets.images["game"]:getDimensions()
|
|
|
|
self.assets.images["game"]:draw(x - x2, y, 0, 1, 1, w, h/2)
|
|
|
|
self.assets.images["over"]:draw(x + x2, y, 0, 1, 1, 0, h/2)
|
|
|
|
end
|
|
|
|
|
|
|
|
return VictoryScreen
|