This repository has been archived on 2023-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
Boups/Scenes/Scripts/Desktop.gd

98 lines
2.8 KiB
GDScript3
Raw Normal View History

extends Node
onready var villain = $"Villain/AnimatedSprite"
onready var villain_animations = $"Villain"
onready var mainMusic = $"MainMusic"
onready var eyeMusic = $"EyeMusic"
onready var alert = $"Alert"
2023-02-26 18:31:57 +01:00
onready var directory = $"Directory"
2023-02-26 20:02:24 +01:00
onready var terminal = $"Terminal"
var rng = RandomNumberGenerator.new()
2023-02-26 18:31:57 +01:00
const texture_file = preload("res://Assets/dossier/1.png")
2023-02-26 20:37:46 +01:00
const texture_terminal = preload("res://Assets/dossier/2.png") #à modifier
2023-02-26 18:31:57 +01:00
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
2023-02-26 20:02:24 +01:00
var icon = terminal.get_node("Sprite")
var window = terminal.get_node("Screen")
var button_window = window.get_node("Button2")
var name_term = terminal.get_node("Label")
var scale_icon = 0.35
2023-02-26 20:37:46 +01:00
2023-02-26 17:39:03 +01:00
rng.randomize()
2023-02-26 20:02:24 +01:00
var nbDossier = rng.randi_range(4, 10)
2023-02-26 17:39:03 +01:00
for i in range(nbDossier):
2023-02-26 18:31:57 +01:00
var dossier = directory.duplicate()
# Une chance sur 2 d'avoir une icône
if rng.randi_range(0, 1) == 0:
# Text (icon)
2023-02-26 20:02:24 +01:00
icon = directory.get_node("Sprite")
window = directory.get_node("Screen")
button_window = window.get_node("Button2")
var name_icon = directory.get_node("Label")
2023-02-26 18:31:57 +01:00
name_icon.text = "Fichier"
# Texture (icon)
icon.scale = Vector2(scale_icon, scale_icon)
icon.texture = texture_file
# Background (window)
window.get_node("Window").visible = false
window.get_node("Window2").visible = true
2023-02-26 20:02:24 +01:00
window.get_node("Window3").visible = false
2023-02-26 19:09:57 +01:00
# Change button visibility
button_window.visible = false
2023-02-26 18:31:57 +01:00
2023-02-26 20:37:46 +01:00
var posY = i % 4
var posX = i / 4
if posX == 0:
posY += 1
2023-02-26 18:31:57 +01:00
button_window.focus_mode = Button.FOCUS_NONE
2023-02-26 20:37:46 +01:00
dossier.position = Vector2(
dossier.position.x + (150 * posX), dossier.position.y + 150 * (posY)
)
2023-02-26 17:39:03 +01:00
dossier.set_z_index(dossier.get_z_index() + 10 * (i + 1))
add_child(dossier)
2023-02-26 20:37:46 +01:00
2023-02-26 20:02:24 +01:00
icon = terminal.get_node("Sprite")
window = terminal.get_node("Screen")
name_term.text = "Terminal"
scale_icon = 0.05
icon.scale = Vector2(scale_icon, scale_icon)
icon.texture = texture_terminal
# Background (window)
window.get_node("Window").visible = false
window.get_node("Window2").visible = false
window.get_node("Window3").visible = true
2023-02-26 20:37:46 +01:00
# Change button visibility
2023-02-26 20:02:24 +01:00
button_window.visible = false
2023-02-26 20:37:46 +01:00
button_window.focus_mode = Button.FOCUS_NONE
2023-02-26 17:39:03 +01:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta) -> void:
2023-02-26 17:39:03 +01:00
if villain.animation == villain_animations.animations[-1]:
mainMusic.set_volume_db(-80)
eyeMusic.set_volume_db(0)
if alert.is_playing():
alert.stop()
elif villain.animation == villain_animations.animations[1]:
if !alert.is_playing():
alert.play()
else:
mainMusic.set_volume_db(0)
eyeMusic.set_volume_db(-80)
2023-02-26 19:09:57 +01:00
var end = true
for i in self.get_children():
if "Directory" in i.name:
if i.visible:
end = false
if end:
mainMusic.set_volume_db(-80)
eyeMusic.set_volume_db(-80)
2023-02-26 20:50:11 +01:00
get_tree().change_scene("res://Scenes/victory.tscn")