2018-01-28 10:03:11 +01:00
|
|
|
extends Control
|
|
|
|
|
2022-08-25 22:26:31 +02:00
|
|
|
var town: Node3D = null
|
2018-01-28 10:03:11 +01:00
|
|
|
|
2023-01-05 16:50:17 +01:00
|
|
|
func _ready():
|
|
|
|
# Automatically focus the first item for gamepad accessibility.
|
2024-03-25 17:06:52 +01:00
|
|
|
$HBoxContainer/MiniVan.grab_focus.call_deferred()
|
2023-01-05 16:50:17 +01:00
|
|
|
|
2022-08-25 22:26:31 +02:00
|
|
|
func _process(_delta: float):
|
2022-03-28 02:19:09 +02:00
|
|
|
if Input.is_action_just_pressed(&"back"):
|
2022-08-25 22:26:31 +02:00
|
|
|
_on_back_pressed()
|
2018-01-28 10:03:11 +01:00
|
|
|
|
|
|
|
|
2023-01-05 16:50:17 +01:00
|
|
|
func _load_scene(car_scene: PackedScene):
|
|
|
|
var car: Node3D = car_scene.instantiate()
|
|
|
|
car.name = "car"
|
|
|
|
town = preload("res://town/town_scene.tscn").instantiate()
|
2022-08-25 22:26:31 +02:00
|
|
|
town.get_node(^"InstancePos").add_child(car)
|
2022-08-30 19:50:31 +02:00
|
|
|
town.get_node(^"Spedometer").car_body = car.get_child(0)
|
2024-03-25 17:06:52 +01:00
|
|
|
town.get_node(^"Back").pressed.connect(_on_back_pressed)
|
2022-08-25 22:26:31 +02:00
|
|
|
|
2018-01-28 10:03:11 +01:00
|
|
|
get_parent().add_child(town)
|
|
|
|
hide()
|
|
|
|
|
|
|
|
|
2022-08-25 22:26:31 +02:00
|
|
|
func _on_back_pressed():
|
2021-02-21 19:58:36 +01:00
|
|
|
if is_instance_valid(town):
|
|
|
|
# Currently in the town, go back to main menu.
|
|
|
|
town.queue_free()
|
|
|
|
show()
|
2023-01-05 16:50:17 +01:00
|
|
|
# Automatically focus the first item for gamepad accessibility.
|
2024-03-25 17:06:52 +01:00
|
|
|
$HBoxContainer/MiniVan.grab_focus.call_deferred()
|
2021-02-21 19:58:36 +01:00
|
|
|
else:
|
|
|
|
# In main menu, exit the game.
|
|
|
|
get_tree().quit()
|
2020-01-29 23:35:14 +01:00
|
|
|
|
|
|
|
|
2022-08-25 22:26:31 +02:00
|
|
|
func _on_mini_van_pressed():
|
2023-01-05 16:50:17 +01:00
|
|
|
_load_scene(preload("res://vehicles/car_base.tscn"))
|
2018-01-28 10:03:11 +01:00
|
|
|
|
|
|
|
|
2022-08-25 22:26:31 +02:00
|
|
|
func _on_trailer_truck_pressed():
|
2023-01-05 16:50:17 +01:00
|
|
|
_load_scene(preload("res://vehicles/trailer_truck.tscn"))
|
2018-01-28 10:03:11 +01:00
|
|
|
|
|
|
|
|
2022-08-25 22:26:31 +02:00
|
|
|
func _on_tow_truck_pressed():
|
2023-01-05 16:50:17 +01:00
|
|
|
_load_scene(preload("res://vehicles/tow_truck.tscn"))
|