261 lines
8.3 KiB
GDScript
261 lines
8.3 KiB
GDScript
extends Node3D
|
|
|
|
const count_battery_boxes = 4
|
|
var currently_charged_battery_boxes := 0
|
|
signal show_door
|
|
@onready var aliens = $"npcs/aliens"
|
|
@onready var batteries = $"Objects/Balloons_A2"
|
|
@onready var chatbot: Control = $npcs/helpers/Chatbot
|
|
var aliens_start_count: int
|
|
var batteries_start_count: int
|
|
var helper_collected = false
|
|
var not_congratulated_1 = true
|
|
var not_congratulated_2 = true
|
|
var release_generators = false
|
|
var popped_balloons := 0
|
|
var current_task := 0
|
|
var current_text: String
|
|
var rabbit_activated = false
|
|
var audio_playing = true
|
|
@onready var checkpoints = [$startpoint,
|
|
$Objects/pressure_blocks/PressureBlock_A1,
|
|
$Objects/pressure_blocks/PressureBlock_A2,
|
|
$Objects/pressure_blocks/PressureBlock_A3,
|
|
$Objects/pressure_blocks/PressureBlock_A3_1,
|
|
]
|
|
@onready var generators = $Objects/generators
|
|
|
|
func _ready() -> void:
|
|
aliens_start_count = aliens.get_child_count()
|
|
batteries_start_count = batteries.get_child_count()
|
|
|
|
func _process(delta: float) -> void:
|
|
if Global.chatbot_opened:
|
|
return
|
|
if Input.is_action_just_pressed("Screenshot"):
|
|
take_screenshot()
|
|
if Input.is_action_just_pressed("fast_forward"):
|
|
current_task = (current_task + 1 ) % len(checkpoints)
|
|
print(current_task, checkpoints[current_task].position)
|
|
$Player.position = checkpoints[current_task].position + Vector3(0.0, 0.5, 0.0)
|
|
if Input.is_action_just_pressed("rewind"):
|
|
current_task = (current_task - 1 ) % len(checkpoints)
|
|
$Player.position = checkpoints[current_task].position
|
|
if Input.is_action_just_pressed("inventory"):
|
|
if current_task == 3:
|
|
$Player.toggle_inventory()
|
|
if current_task == 4 and Input.is_action_just_pressed("keypad"):
|
|
reset_music_volume()
|
|
$Keypad.visible = true
|
|
$Hilfestellung/CanvasLayer.visible = false
|
|
$Player.set_mode('aim')
|
|
|
|
if not_congratulated_1 and aliens.get_child_count() <= aliens_start_count-5:
|
|
not_congratulated_1 = false
|
|
show_congratulations("TASK1_CONGRATS", "TOPIC_AI_DEFS")
|
|
|
|
|
|
func show_congratulations(text, text_2) -> void:
|
|
print(text)
|
|
$Player/helper/helper.celebrate()
|
|
$Hilfestellung/CanvasLayer.visible = false
|
|
$Congratulations/CanvasLayer/Panel/Label.text = tr(text)
|
|
$Congratulations/CanvasLayer.visible = true
|
|
$Congratulations/CanvasLayer/Panel/Label_repeat.text = tr("CONGRATS_REPEAT") % tr(text_2)
|
|
await get_tree().create_timer(5.0).timeout
|
|
$Player/helper/helper.stop_anim()
|
|
$Congratulations/CanvasLayer.visible = false
|
|
|
|
func openLinkinBrowser(link):
|
|
OS.shell_open(link)
|
|
|
|
func openAIActinBrowser():
|
|
openLinkinBrowser("https://eur-lex.europa.eu/legal-content/DE/TXT/?uri=CELEX:32024R1689")
|
|
|
|
func openDSGVOinBrowser():
|
|
openLinkinBrowser("https://dsgvo-gesetz.de/")
|
|
|
|
func _on_openChatBot():
|
|
$Hilfestellung/CanvasLayer.visible = false
|
|
$HUD.visible = false
|
|
quiet_down_music()
|
|
|
|
|
|
|
|
func _on_battery_box_removed_battery() -> void:
|
|
currently_charged_battery_boxes -= 1
|
|
print(currently_charged_battery_boxes)
|
|
|
|
|
|
func _on_show_door() -> void:
|
|
print('showing door')
|
|
$Objects/spaceship/Door.visible = true
|
|
$Objects/spaceship/Door.position.y = 0.012
|
|
$Objects/spaceship/door_cover/CollisionShape3D.disabled = true
|
|
|
|
|
|
func _on_door_body_entered(body: Node3D) -> void:
|
|
if $Objects/spaceship/Door.visible:
|
|
DialogueState.currentTask = 5
|
|
Transition.change_scene("res://quiz.tscn")
|
|
|
|
|
|
func _on_pressure_block_a3_activated() -> void:
|
|
quiet_down_music()
|
|
$Objects/pressure_blocks/PressureBlock_A3.current_weight = 10.0
|
|
DialogueManager.show_chosen_dialogue_balloon(load($Objects/pressure_blocks/PressureBlock_A3.text_on_activation), "/game_balloons/game_balloon_v_2.tscn", "start")
|
|
|
|
|
|
func _on_pressure_block_a_1_activated() -> void:
|
|
current_task = 1
|
|
DialogueState.currentTask = 1
|
|
current_text = tr("HINT_TALK_ALIENS")
|
|
$Hinweistexte/CanvasLayer/Panel/Label.text = tr("HINT_ALIENS")
|
|
$Hinweistexte/CanvasLayer.visible = true
|
|
if $Tutorial:
|
|
$Tutorial.queue_free()
|
|
if $Objects/Bridges/walls_tutorial:
|
|
$Objects/Bridges/walls_tutorial.queue_free()
|
|
if $Objects/Chip0/block:
|
|
$Objects/Chip0/block.queue_free()
|
|
|
|
|
|
func _on_pressure_block_a_2_activated() -> void:
|
|
current_task = 2
|
|
current_text = tr("HINT_THROW_CONTROLS")
|
|
$Hinweistexte/CanvasLayer/Panel/Label.text = tr("HINT_THROW_ZONE")
|
|
$Hinweistexte/CanvasLayer.visible = true
|
|
|
|
|
|
func _on_pressure_block_deactivated() -> void:
|
|
$Hinweistexte/CanvasLayer.visible = false
|
|
$Hilfestellung/CanvasLayer/Panel/Label.text = current_text
|
|
$Hilfestellung/CanvasLayer.visible = true
|
|
|
|
|
|
func _on_pressure_block_a_3_1_activated() -> void:
|
|
reset_music_volume()
|
|
current_task = 3
|
|
DialogueState.currentTask = 3
|
|
current_text = tr("HINT_BATTERY_CONTROLS")
|
|
$Objects/pressure_blocks/PressureBlock_A3_1.current_weight = 10.0
|
|
$AnimationPlayer.play("start_ordering_game")
|
|
_on_pressure_block_deactivated()
|
|
|
|
|
|
func _on_balloon_tree_exited() -> void:
|
|
popped_balloons += 1
|
|
if popped_balloons == Global.TOTAL_BALLOONS_A2 and current_task == 2:
|
|
not_congratulated_2 = false
|
|
DialogueState.batteriesFlag = true
|
|
show_congratulations("TASK2_CONGRATS", "TOPIC_AI_SYSTEMS")
|
|
$Objects/arrows/after_throw.visible = true
|
|
$Objects/Fences/no_arrows/barrier_throw.position.x = 4.0
|
|
$Hilfestellung/CanvasLayer/Panel/Label.text = tr("HINT_COLLECT_BATTERIES")
|
|
$Hilfestellung/CanvasLayer.visible = true
|
|
|
|
|
|
func _on_pressure_block_a_4_activated() -> void:
|
|
quiet_down_music()
|
|
current_task = 4
|
|
DialogueState.currentTask = 4
|
|
DialogueState.personalDataFlag = true
|
|
$Objects/spaceship/keypad.visible = true
|
|
current_text = tr("HINT_START_KEYPAD")
|
|
$Hilfestellung/CanvasLayer.visible = true
|
|
$Objects/pressure_blocks/PressureBlock_A4.current_weight = 10.0
|
|
DialogueManager.show_chosen_dialogue_balloon(load($Objects/pressure_blocks/PressureBlock_A4.text_on_activation), "/game_balloons/game_balloon_v_2.tscn", "start")
|
|
_on_pressure_block_deactivated()
|
|
|
|
|
|
func _on_keypad_game_finished() -> void:
|
|
$Keypad.visible = false
|
|
$Objects/spaceship/keypad.visible = false
|
|
$Hilfestellung/CanvasLayer/Panel/Label.text = tr("HINT_ENTER_SHIP")
|
|
$Hilfestellung/CanvasLayer.visible = true
|
|
show_door.emit()
|
|
|
|
|
|
func _on_battery_3_battery_collected() -> void:
|
|
$Player/helper.visible = true
|
|
#TODO implement if helper should replace battery 3 (since it's also a chatbot)
|
|
|
|
|
|
func _on_animation_player_animation_finished(anim_name: StringName) -> void:
|
|
if anim_name == "collect_helper_part1":
|
|
$Player/AnimationPlayer2.play("collect_helper_part2")
|
|
if anim_name == 'follow_rabbit':
|
|
$AnimationPlayer.play('rotate_label')
|
|
if anim_name == "ordering_finished":
|
|
generators.queue_free()
|
|
show_congratulations("TASK3_CONGRATS", "TOPIC_AI_RISKS")
|
|
$Objects/pressure_blocks/PressureBlock_A4.position = Vector3(-87.26, 3.787, 209.9)
|
|
|
|
|
|
func _on_helper_corner_dialogue_finished() -> void:
|
|
if not helper_collected:
|
|
$AnimationPlayer.play("collect_helper_part1")
|
|
$npcs/helpers/helper_corner/CollisionShape3D.disabled = true
|
|
helper_collected = true
|
|
$Objects/chip1/star.queue_free()
|
|
|
|
|
|
func _on_battery_box_fully_charged() -> void:
|
|
currently_charged_battery_boxes += 1
|
|
print('currently charged boxes: ', currently_charged_battery_boxes)
|
|
if currently_charged_battery_boxes == count_battery_boxes:
|
|
print('all boxes are full')
|
|
await get_tree().create_timer(1.5).timeout
|
|
$AnimationPlayer.play("ordering_finished")
|
|
$Objects/Chip0/Arrows_A4.visible = true
|
|
|
|
|
|
func _on_player_inventory_opened() -> void:
|
|
$Hilfestellung/CanvasLayer.visible = false
|
|
$HUD.visible = false
|
|
|
|
|
|
func _on_player_inventory_closed() -> void:
|
|
$Hilfestellung/CanvasLayer.visible = true
|
|
$HUD.visible = true
|
|
|
|
|
|
func _on_balloon_popped(balloon: Balloon) -> void:
|
|
$Player/helper/helper.play_small_celebration()
|
|
|
|
|
|
func _on_chatbot_closing_chatbot() -> void:
|
|
if current_task > 0:
|
|
$HUD.visible = true
|
|
$Hilfestellung/CanvasLayer.visible = true
|
|
reset_music_volume()
|
|
|
|
func take_screenshot():
|
|
print('taking screenshot')
|
|
var image = get_viewport().get_texture().get_image()
|
|
image.save_png("user://screenshot"+Time.get_datetime_string_from_system()+".png")
|
|
|
|
|
|
func _on_start_rabbit_body_entered(body: Node3D) -> void:
|
|
if not rabbit_activated:
|
|
$AnimationPlayer.play('follow_rabbit')
|
|
rabbit_activated = true
|
|
|
|
func quiet_down_music() -> void:
|
|
$AudioStreamPlayer.volume_db = -20.0
|
|
|
|
func reset_music_volume() -> void:
|
|
$AudioStreamPlayer.volume_db = -10.0
|
|
|
|
func toggle_music() -> void:
|
|
if not audio_playing:
|
|
audio_playing = true
|
|
$AudioStreamPlayer.play()
|
|
else:
|
|
$AudioStreamPlayer.stop()
|
|
audio_playing = false
|
|
|
|
|
|
func _on_audio_stream_player_finished() -> void:
|
|
$AudioStreamPlayer.play()
|