Updated levels and added map selection logic
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
extends Node3D
|
||||
|
||||
var selected_drone: PackedScene
|
||||
var camera_array: Array[Camera3D] = []
|
||||
var current_camera: int = 0
|
||||
var game_started: bool = false
|
||||
var is_paused: bool = false
|
||||
var controller_mode: String = "JoyController"
|
||||
var selected_map: PackedScene
|
||||
var drone_instance: Drone
|
||||
var reset_point: Marker3D
|
||||
|
||||
@export var camera_array: Array[Camera3D] = []
|
||||
@export var current_camera: int = 0
|
||||
@export var game_started: bool = false
|
||||
@export var is_paused: bool = false
|
||||
@export var controller_mode: String = "JoyController"
|
||||
|
||||
func _ready():
|
||||
selected_drone = load("res://core/drone/drone.tscn")
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
@@ -20,4 +27,18 @@ func _process(_delta):
|
||||
|
||||
|
||||
func start_game():
|
||||
game_started = true
|
||||
if selected_map != null:
|
||||
var map_instance = selected_map.instantiate()
|
||||
get_tree().root.get_node("Main").add_child(map_instance)
|
||||
_spawn_drone()
|
||||
game_started = true
|
||||
else:
|
||||
print("ERROR: selected_map is null")
|
||||
|
||||
|
||||
func _spawn_drone():
|
||||
if selected_drone != null:
|
||||
drone_instance = selected_drone.instantiate()
|
||||
get_tree().root.get_node("Main/ResetPoint/").add_child(drone_instance)
|
||||
else:
|
||||
print("ERROR: selected_drone is null")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
@export var zoom_curve: Curve
|
||||
@export var drone: RigidBody3D
|
||||
@export var child_camera: Camera3D
|
||||
|
||||
var dist_to_drone: float = 0.0
|
||||
@@ -12,9 +11,10 @@ func _ready():
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
look_at(drone.global_position)
|
||||
|
||||
dist_to_drone = global_position.distance_to(drone.global_position)
|
||||
|
||||
child_camera.fov = zoom_curve.sample((dist_to_drone-1)/89)
|
||||
|
||||
if GameManager.drone_instance != null:
|
||||
look_at(GameManager.drone_instance.global_position)
|
||||
|
||||
dist_to_drone = global_position.distance_to(GameManager.drone_instance.global_position)
|
||||
|
||||
child_camera.fov = zoom_curve.sample((dist_to_drone-1)/89)
|
||||
|
||||
|
||||
7
core/scripts/main.gd
Normal file
7
core/scripts/main.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends Node3D
|
||||
|
||||
@export var reset_point: Marker3D
|
||||
|
||||
|
||||
func _ready():
|
||||
GameManager.reset_point = reset_point
|
||||
@@ -5,6 +5,7 @@ extends Control
|
||||
@export var controller_mode_button: CheckButton
|
||||
@export var joy_controller_label: Label
|
||||
@export var fpv_remote_label: Label
|
||||
@export var map_selection_menu: Control
|
||||
|
||||
|
||||
func _ready():
|
||||
@@ -16,7 +17,7 @@ func _ready():
|
||||
|
||||
func _on_start_button_pressed():
|
||||
hide()
|
||||
GameManager.start_game()
|
||||
map_selection_menu.show()
|
||||
|
||||
|
||||
func _on_quit_button_pressed():
|
||||
|
||||
43
core/scripts/map_selection.gd
Normal file
43
core/scripts/map_selection.gd
Normal file
@@ -0,0 +1,43 @@
|
||||
extends Control
|
||||
|
||||
@export var construction_site_button: Button
|
||||
@export var run_down_building_button: Button
|
||||
@export var abstract_button: Button
|
||||
@export var start_button: Button
|
||||
@export var construction_site_scene: PackedScene
|
||||
@export var run_down_building_scene: PackedScene
|
||||
@export var abstract_scene: PackedScene
|
||||
var selected_map_key: int = 0
|
||||
|
||||
|
||||
func _ready():
|
||||
construction_site_button.pressed.connect(_on_construction_site_button_pressed)
|
||||
run_down_building_button.pressed.connect(_on_run_down_building_button_pressed)
|
||||
abstract_button.pressed.connect(_on_abstract_button_pressed)
|
||||
start_button.pressed.connect(_on_start_button_pressed)
|
||||
self.visibility_changed.connect(_on_visibility_changed)
|
||||
|
||||
|
||||
func _on_construction_site_button_pressed():
|
||||
selected_map_key = 1
|
||||
GameManager.selected_map = construction_site_scene
|
||||
|
||||
|
||||
func _on_run_down_building_button_pressed():
|
||||
selected_map_key = 2
|
||||
GameManager.selected_map = run_down_building_scene
|
||||
|
||||
|
||||
func _on_abstract_button_pressed():
|
||||
selected_map_key = 3
|
||||
GameManager.selected_map = abstract_scene
|
||||
|
||||
|
||||
func _on_start_button_pressed():
|
||||
GameManager.start_game()
|
||||
hide()
|
||||
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
if visible:
|
||||
construction_site_button.grab_focus()
|
||||
Reference in New Issue
Block a user