Added Level Loading
This commit is contained in:
@ -1,18 +1,27 @@
|
||||
extends Control
|
||||
|
||||
signal startGame
|
||||
signal startGame(path)
|
||||
|
||||
var load_list = ["Back"]
|
||||
@export var level_folder = "res://Assets/Levels"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
var dir = DirAccess.open(level_folder)
|
||||
if dir:
|
||||
dir.list_dir_begin()
|
||||
var file_name = dir.get_next()
|
||||
while file_name != "":
|
||||
load_list.append(file_name)
|
||||
$ItemList.add_item(file_name.replace(".tscn", ""),null,false)
|
||||
file_name = dir.get_next()
|
||||
|
||||
func _on_exit_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_start_pressed():
|
||||
emit_signal("startGame")
|
||||
|
||||
emit_signal("startGame", "res://Assets/Levels/TestMapHospitalTextures.tscn")
|
||||
GlobalSettings.current_map = "res://Assets/Levels/TestMapHospitalTextures.tscn"
|
||||
|
||||
func _on_settings_pressed():
|
||||
pass # Replace with function body.
|
||||
@ -26,3 +35,6 @@ func _on_item_list_item_clicked(index, at_position, mouse_button_index):
|
||||
if index == 0:
|
||||
$ItemList.hide()
|
||||
$VBoxContainer.show()
|
||||
else:
|
||||
GlobalSettings.current_map = "res://Assets/Levels/" + load_list[index]
|
||||
emit_signal("startGame", GlobalSettings.current_map)
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
extends Node3D
|
||||
|
||||
var Default_Map = "res://Assets/Levels/test_map.tscn"
|
||||
var Test_Map = "res://Assets/Levels/TestMapHospitalTextures.tscn"
|
||||
|
||||
func openMap(map_location):
|
||||
var map_instance = load(map_location).instantiate()
|
||||
func openMap():
|
||||
print(GlobalSettings.current_map)
|
||||
var map_instance = load(GlobalSettings.current_map).instantiate()
|
||||
add_child(map_instance)
|
||||
|
||||
func _init():
|
||||
openMap(Default_Map)
|
||||
openMap()
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
extends Node
|
||||
|
||||
var game = preload("res://Assets/game.tscn").instantiate()
|
||||
|
||||
func _on_main_menu_start_game():
|
||||
|
||||
func _on_main_menu_start_game(path):
|
||||
var game = load("res://Assets/game.tscn").instantiate()
|
||||
self.remove_child($"Main Menu")
|
||||
self.add_child(game)
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
extends Node
|
||||
|
||||
var is_paused = false
|
||||
|
||||
var current_map = ""
|
||||
|
||||
Reference in New Issue
Block a user