katheterkompass/main.gd

52 lines
1.4 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends Control
@onready var intro_sound: AudioStreamPlayer2D = $IntroSoundPlayer
@onready var wrong_order_sound: AudioStreamPlayer2D = $WrongOrderSoundPlayer
@onready var wrong_place_sound: AudioStreamPlayer2D = $WrongPlaceSoundPlayer
@onready var end_sound: AudioStreamPlayer2D = $EndSoundPlayer
var interaction_locked := true
var organ_order := [
"brain", # Hirn
"esophagus", # Speiseröhre
"stomach", # Magen
"intestine", # Darm
"kidney", # Nieren
"bubble" # Blase
]
var current_organ_index := 0
func _ready() -> void:
intro_sound.play()
intro_sound.finished.connect(_on_intro_finished)
func _on_intro_finished() -> void:
print("🏁 Intro abgeschlossen Interaktionen erlaubt")
interaction_locked = false
func is_correct_organ(organ_name: String) -> bool:
return organ_name == organ_order[current_organ_index]
#return true # Für Debug
func advance_organ_order() -> void:
current_organ_index += 1
if current_organ_index >= organ_order.size():
_play_end_sound()
func play_wrong_order_sound() -> void:
AudioManager.stop_all_audio_players()
if wrong_order_sound:
wrong_order_sound.play()
func play_wrong_place_sound() -> void:
AudioManager.stop_all_audio_players()
if wrong_place_sound:
wrong_place_sound.play()
func _play_end_sound() -> void:
print("🎉 Alle Organe gesetzt Abschluss-Sound wird abgespielt!")
AudioManager.stop_all_audio_players()
if end_sound:
end_sound.play()