27 lines
792 B
GDScript3
27 lines
792 B
GDScript3
![]() |
extends Control
|
||
|
|
||
|
@export var fadeDuration: float = 0.5
|
||
|
@export var fadeMax: float = 0.65
|
||
|
|
||
|
@onready var backdrop: ColorRect = $ColorRect
|
||
|
@onready var result: RichTextLabel = $Result
|
||
|
@onready var data: Data = $/root/Root/Data
|
||
|
|
||
|
var timer: float = 0
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready():
|
||
|
data.player.connect("died", displayResult)
|
||
|
data.opponent.connect("died", displayResult)
|
||
|
|
||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
func _process(delta):
|
||
|
if (!data.playing):
|
||
|
timer = clampf(0, 1, timer + (delta / fadeDuration))
|
||
|
backdrop.color.a = lerpf(0, fadeMax, timer)
|
||
|
|
||
|
func displayResult(victory: bool):
|
||
|
if (victory): result.text = "[center]Victory[/center]"
|
||
|
else: result.text = "[center]Defeat[/center]"
|
||
|
result.show()
|