2023-10-10 21:46:15 -04:00
|
|
|
extends Node2D
|
|
|
|
|
2023-10-11 04:21:07 -04:00
|
|
|
var length: int = 0
|
|
|
|
var time: int = 0
|
|
|
|
var countdown: float = 0
|
2023-10-11 10:10:54 -04:00
|
|
|
@onready var player := $Player
|
2023-10-10 21:46:15 -04:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2023-10-11 04:21:07 -04:00
|
|
|
length = $Music.stream.get_length()
|
2023-10-11 06:19:47 -04:00
|
|
|
player.set_time(str(length))
|
2023-10-10 21:46:15 -04:00
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
2023-10-11 04:21:07 -04:00
|
|
|
countdown += delta
|
|
|
|
if countdown > 1:
|
|
|
|
countdown -= 1
|
|
|
|
time = $Music.get_playback_position()
|
2023-10-11 06:19:47 -04:00
|
|
|
player.set_time(str(length - time - 1))
|
2023-10-10 21:46:15 -04:00
|
|
|
|
|
|
|
func win_screen():
|
2023-10-11 04:21:07 -04:00
|
|
|
var enemy = $Enemy
|
|
|
|
var end = load("res://Scenes/ending.tscn").instantiate()
|
2023-10-11 10:37:23 -04:00
|
|
|
end.remainingTime = str(length - time - 1)
|
2023-10-11 09:52:48 -04:00
|
|
|
end.totalBlud = player.totalBludGenerated
|
|
|
|
end.army = player.allSpawnedMonsters
|
2023-10-11 04:21:07 -04:00
|
|
|
end.killcount = enemy.killcount
|
|
|
|
end.level = enemy.level
|
|
|
|
end.exp = enemy.experience
|
2023-10-11 10:42:37 -04:00
|
|
|
end.message = "The holy knight Fabio is defeated, Evil has won and your magic staff is safe."
|
2023-10-11 12:17:01 -04:00
|
|
|
end.maxBludGen = player.maxBludGen
|
2023-10-11 04:21:07 -04:00
|
|
|
self.queue_free()
|
|
|
|
get_tree().root.add_child(end)
|
|
|
|
|
|
|
|
func lose_screen():
|
|
|
|
var enemy = $Enemy
|
|
|
|
var end = load("res://Scenes/ending.tscn").instantiate()
|
2023-10-11 09:52:48 -04:00
|
|
|
end.totalBlud = player.totalBludGenerated
|
|
|
|
end.army = player.allSpawnedMonsters
|
2023-10-11 04:21:07 -04:00
|
|
|
end.killcount = enemy.killcount
|
|
|
|
end.level = enemy.level
|
|
|
|
end.exp = enemy.experience
|
|
|
|
end.is_win = false
|
2023-10-11 10:42:37 -04:00
|
|
|
end.message = "The holy knight Fabio destroyed you army of evil and left with your magic staff..."
|
2023-10-11 12:17:01 -04:00
|
|
|
end.maxBludGen = player.maxBludGen
|
2023-10-11 04:21:07 -04:00
|
|
|
self.queue_free()
|
|
|
|
get_tree().root.add_child(end)
|
|
|
|
|
|
|
|
func _on_music_finished():
|
|
|
|
lose_screen()
|