Files
gaim/tutorial.gd
2026-07-29 11:34:28 +02:00

121 lines
3.1 KiB
GDScript

extends Node3D
@onready var label = $CanvasLayer/Panel/Label
@onready var player = $"../Player"
@onready var balloons = $"../Objects/Balloons"
var current_step = 0
var time_start = 0.0
var current_time_passed = 0.0
# Track which directions were used
var walked = {
"ui_left": false,
"ui_right": false,
"ui_up": false,
"ui_down": false
}
# Track which directions were used
var turned = {
"cam_right": false,
"cam_left": false
}
var steps = [
"TUTORIAL_STEP_0",
"TUTORIAL_STEP_1",
"TUTORIAL_STEP_2",
"TUTORIAL_STEP_3",
"TUTORIAL_STEP_4",
"TUTORIAL_STEP_5",
"TUTORIAL_STEP_6",
]
func _ready():
time_start = Time.get_unix_time_from_system()
update_label()
$CanvasLayer/SubViewportContainer/SubViewport/helper/AnimationPlayer.play('happy')
func _process(delta):
check_time()
match current_step:
0:
check_walk_directions()
1:
if Input.is_action_just_pressed("ui_accept"):
#$"../Objects/Balloons".position.y = 6.0
next_step()
2:
if Input.is_action_just_pressed("throw"):
next_step()
3:
if balloons.get_child_count() < 3:
next_step()
4:
if Input.is_action_just_pressed("grab") and player.grabbed_item:
next_step()
5:
if Input.is_action_just_pressed("drop"):
next_step()
6:
if player.dialogueActive:
next_step()
func check_walk_directions():
for action in walked.keys():
if Input.is_action_just_pressed(action):
walked[action] = true
if walked.values().all(func(v): return v):
$"../Objects/Bridges/walls_tutorial/walls_to_bridge".queue_free()
$"../Objects/Chip0/block".position.y = 0.0
$"../Objects/arrows/help1".position.y = 4.892
next_step()
func check_camera_turned():
for action in turned.keys():
if Input.is_action_just_pressed(action):
turned[action] = true
if turned.values().all(func(v): return v):
next_step()
func next_step():
current_step += 1
time_start = Time.get_unix_time_from_system()
$AnimationPlayer.play('RESET')
$CanvasLayer/Panel.get_theme_stylebox('panel').border_color = Color('cccccc')
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_left = 5
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_right = 5
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_top = 5
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_bottom = 5
$CanvasLayer/Panel.size.y = 150
update_label()
func update_label():
if current_step < steps.size():
label.text = tr(steps[current_step])
await get_tree().process_frame
var text_size = label.get_minimum_size()
$CanvasLayer/Panel.custom_minimum_size = text_size + Vector2(40, 40)
else:
label.text = ""
queue_free()
func check_time() -> void:
current_time_passed = Time.get_unix_time_from_system() - time_start
if current_time_passed > 15.0:
pulse_panel()
func pulse_panel() -> void:
$CanvasLayer/Panel.get_theme_stylebox('panel').border_color = Color('30e7f2')
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_left = 8
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_right = 8
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_top = 8
$CanvasLayer/Panel.get_theme_stylebox('panel').border_width_bottom = 8
$AnimationPlayer.play('pulse')