mirror of
https://github.com/kodzukye/omens-ascent.git
synced 2026-08-10 05:13:10 +00:00
44 lines
1.1 KiB
GDScript
44 lines
1.1 KiB
GDScript
class_name Outro
|
|
extends Node
|
|
|
|
const DIALOGS: Array[String] = [
|
|
"Well done hero!",
|
|
"You saved us all!",
|
|
"...",
|
|
"Thank you for playing my game!"
|
|
]
|
|
|
|
const CHAR_DELAY: float = 0.04
|
|
const LINE_PAUSE: float = 2.0
|
|
|
|
var _full_text: String = ""
|
|
|
|
@onready var log_label: RichTextLabel = $CanvasLayer/Label
|
|
@onready var background: ColorRect = $CanvasLayer/Background
|
|
@onready var fade_out: ColorRect = $CanvasLayer/FadeOut
|
|
|
|
func _ready() -> void:
|
|
log_label.text = ""
|
|
_play_sequence()
|
|
AudioManager.play_ambiance("act1_section1")
|
|
|
|
func _play_sequence() -> void:
|
|
for line in DIALOGS:
|
|
await _type_line(line)
|
|
await get_tree().create_timer(LINE_PAUSE).timeout
|
|
_full_text += "\n"
|
|
|
|
# Fade out
|
|
var tween: Tween = create_tween()
|
|
tween.tween_property(fade_out, "color:a", 1.0, 1.2)
|
|
await tween.finished
|
|
if OS.get_name() == "Web":
|
|
JavaScriptBridge.eval("document.querySelector('canvas').focus()")
|
|
SceneManager.change_scene("res://scenes/components/credits.tscn")
|
|
|
|
func _type_line(line: String) -> void:
|
|
for i in line.length():
|
|
_full_text += line[i]
|
|
log_label.text = _full_text
|
|
await get_tree().create_timer(CHAR_DELAY).timeout
|