2025-06-28 18:53:35 +02:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
@export_file("*.tscn") var golé: String
|
|
|
|
@export_file("*.tscn") var next_level: String
|
|
|
|
|
|
|
|
@export var base_mode: GUIDEMappingContext
|
|
|
|
|
|
|
|
@export var vies = 3
|
|
|
|
|
2025-06-29 09:40:40 +02:00
|
|
|
@onready var lights: Node2D = $Lights
|
|
|
|
|
|
|
|
@onready var wrong_hack: Interactible = %WrongHack
|
|
|
|
@onready var right_hack: Interactible = %RightHack
|
|
|
|
|
|
|
|
@onready var wrong_door: Interactible = $GetOutDoors/WrongDoor
|
|
|
|
@onready var right_door: Interactible = $GetOutDoors/RightDoor
|
|
|
|
|
|
|
|
@onready var timer_between_vo: Timer = $TimerBetweenVO
|
|
|
|
var is_interjection_next = false
|
|
|
|
var current_info: int = 0
|
2025-06-29 14:33:23 +02:00
|
|
|
var is_over = false
|
|
|
|
var currently_playing: AudioStreamPlayer2D
|
2025-06-29 09:40:40 +02:00
|
|
|
|
2025-06-29 14:58:36 +02:00
|
|
|
@onready var vo_light_off: AudioStreamPlayer2D = $Hack/VOLightOff
|
2025-06-29 09:40:40 +02:00
|
|
|
@onready var vo_prise_tiree: AudioStreamPlayer2D = $Hack/VOPriseTiree
|
|
|
|
@onready var vo_interjection: AudioStreamPlayer2D = $Hack/VOInterjection
|
|
|
|
@onready var interact: AudioStreamPlayer2D = $Player/Interact
|
|
|
|
@onready var vo_trop_proche: AudioStreamPlayer2D = $Hack/VOTropProche
|
|
|
|
@onready var vo_player_1: AudioStreamPlayer2D = $Hack/VOPlayer1
|
|
|
|
@onready var vo_player_2: AudioStreamPlayer2D = $Hack/VOPlayer2
|
|
|
|
@onready var vo_player_3: AudioStreamPlayer2D = $Hack/VOPlayer3
|
|
|
|
@onready var vo_player_4: AudioStreamPlayer2D = $Hack/VOPlayer4
|
|
|
|
@onready var vo_player_5: AudioStreamPlayer2D = $Hack/VOPlayer5
|
|
|
|
@onready var vo_player_6: AudioStreamPlayer2D = $Hack/VOPlayer6
|
|
|
|
@onready var vo_player_7: AudioStreamPlayer2D = $Hack/VOPlayer7
|
|
|
|
@onready var vo_player_8: AudioStreamPlayer2D = $Hack/VOPlayer8
|
|
|
|
@onready var vo_player_9: AudioStreamPlayer2D = $Hack/VOPlayer9
|
|
|
|
@onready var vo_player_10: AudioStreamPlayer2D = $Hack/VOPlayer10
|
|
|
|
var vo_players: Array[AudioStreamPlayer2D] = []
|
2025-06-28 18:53:35 +02:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready() -> void:
|
|
|
|
GUIDE.enable_mapping_context(base_mode)
|
2025-06-29 09:40:40 +02:00
|
|
|
wrong_hack.activate()
|
|
|
|
right_hack.deactivate()
|
|
|
|
wrong_door.activate()
|
|
|
|
right_door.deactivate()
|
2025-06-28 18:53:35 +02:00
|
|
|
|
2025-06-29 09:40:40 +02:00
|
|
|
vo_players.append(vo_player_1)
|
|
|
|
vo_players.append(vo_player_2)
|
|
|
|
vo_players.append(vo_player_3)
|
|
|
|
vo_players.append(vo_player_4)
|
|
|
|
vo_players.append(vo_player_5)
|
|
|
|
vo_players.append(vo_player_6)
|
|
|
|
vo_players.append(vo_player_7)
|
|
|
|
vo_players.append(vo_player_8)
|
|
|
|
vo_players.append(vo_player_9)
|
|
|
|
vo_players.append(vo_player_10)
|
2025-06-28 18:53:35 +02:00
|
|
|
|
2025-06-29 14:33:23 +02:00
|
|
|
currently_playing = vo_players[current_info]
|
|
|
|
vo_players[current_info].play()
|
|
|
|
current_info += 1
|
|
|
|
|
2025-06-29 09:40:40 +02:00
|
|
|
|
|
|
|
func _on_prise_interacted(event_id: String) -> void:
|
|
|
|
wrong_hack.deactivate()
|
|
|
|
right_hack.activate()
|
|
|
|
for light in lights.get_children():
|
|
|
|
light.visible = false
|
2025-06-29 14:58:36 +02:00
|
|
|
|
|
|
|
if currently_playing != null and currently_playing.playing:
|
|
|
|
currently_playing.stop()
|
|
|
|
|
|
|
|
interact.play()
|
|
|
|
vo_light_off.play()
|
|
|
|
currently_playing = vo_light_off
|
2025-06-29 09:40:40 +02:00
|
|
|
|
|
|
|
func made_mistake() -> void:
|
2025-06-28 18:53:35 +02:00
|
|
|
vies -= 1
|
|
|
|
if vies == 0:
|
|
|
|
SceneLoader.load_scene(golé)
|
|
|
|
|
2025-06-29 09:40:40 +02:00
|
|
|
func _on_failed_hack(event_id: String) -> void:
|
2025-06-29 14:33:23 +02:00
|
|
|
if currently_playing != null and currently_playing.playing:
|
|
|
|
currently_playing.stop()
|
2025-06-29 09:40:40 +02:00
|
|
|
made_mistake()
|
|
|
|
interact.play()
|
|
|
|
vo_trop_proche.play()
|
2025-06-29 14:33:23 +02:00
|
|
|
currently_playing = vo_trop_proche
|
2025-06-29 09:40:40 +02:00
|
|
|
|
|
|
|
func _on_successful_hack(event_id: String) -> void:
|
2025-06-29 14:33:23 +02:00
|
|
|
if currently_playing != null and currently_playing.playing:
|
|
|
|
currently_playing.stop()
|
2025-06-29 09:40:40 +02:00
|
|
|
right_door.activate()
|
|
|
|
wrong_door.deactivate()
|
|
|
|
interact.play()
|
|
|
|
vo_prise_tiree.play()
|
2025-06-29 14:33:23 +02:00
|
|
|
currently_playing = vo_prise_tiree
|
2025-06-29 09:40:40 +02:00
|
|
|
right_door.visible = true
|
|
|
|
|
|
|
|
func _on_interactible_triggered(event_id: String) -> void:
|
|
|
|
made_mistake()
|
|
|
|
interact.play()
|
2025-06-28 18:53:35 +02:00
|
|
|
|
|
|
|
func _on_wrong_door_event_triggered(event_id: String) -> void:
|
|
|
|
SceneLoader.load_scene(golé)
|
|
|
|
|
|
|
|
func _on_right_door_event_triggered(event_id: String) -> void:
|
|
|
|
SceneLoader.load_scene(next_level) # Replace with function body.
|
2025-06-29 09:40:40 +02:00
|
|
|
|
|
|
|
func _on_timer_between_vo_timeout() -> void:
|
2025-06-29 14:33:23 +02:00
|
|
|
if currently_playing != null and currently_playing.playing:
|
2025-06-29 09:40:40 +02:00
|
|
|
return
|
2025-06-29 14:33:23 +02:00
|
|
|
|
|
|
|
if is_over:
|
|
|
|
vo_interjection.play()
|
2025-06-29 09:40:40 +02:00
|
|
|
|
|
|
|
if current_info >= len(vo_players):
|
2025-06-29 14:33:23 +02:00
|
|
|
is_over = true
|
2025-06-29 09:40:40 +02:00
|
|
|
return
|
2025-06-29 14:33:23 +02:00
|
|
|
|
|
|
|
currently_playing = vo_players[current_info]
|
2025-06-29 09:40:40 +02:00
|
|
|
vo_players[current_info].play()
|
|
|
|
current_info += 1
|
2025-06-29 14:33:23 +02:00
|
|
|
|
|
|
|
func _on_vo_trop_proche_finished() -> void:
|
|
|
|
pass
|