menu and level select ready
This commit is contained in:
parent
311c0395ab
commit
f470efbe1f
10 changed files with 61 additions and 11 deletions
|
|
@ -3,7 +3,7 @@
|
|||
[ext_resource type="Script" path="res://Commands/command_block.gd" id="1_ra6j6"]
|
||||
[ext_resource type="Script" path="res://Commands/tool.gd" id="3_lrl7m"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cywoj"]
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tjj4k"]
|
||||
emission = Color(1, 1, 1, 1)
|
||||
subsurf_scatter_strength = 1.0
|
||||
uv1_scale = Vector3(3, 2, 1)
|
||||
|
|
@ -23,7 +23,7 @@ mesh = NodePath("MeshInstance3D")
|
|||
collider = NodePath("CollisionShape3D3")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
material_override = SubResource("StandardMaterial3D_cywoj")
|
||||
material_override = SubResource("StandardMaterial3D_tjj4k")
|
||||
mesh = SubResource("BoxMesh_572kf")
|
||||
script = ExtResource("3_lrl7m")
|
||||
|
||||
|
|
|
|||
7
Levels/Level 1.tscn
Normal file
7
Levels/Level 1.tscn
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://c6vhdhaji73sn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bojbawyoy11i4" path="res://Levels/StartingRoom.tscn" id="1_qmnx5"]
|
||||
|
||||
[node name="Level1" type="Node3D"]
|
||||
|
||||
[node name="ChronoManager" parent="." instance=ExtResource("1_qmnx5")]
|
||||
|
|
@ -294,3 +294,4 @@ shape = SubResource("BoxShape3D_jvb5m")
|
|||
[connection signal="broadcast" from="." to="Player" method="_on_chrono_manager_broadcast"]
|
||||
[connection signal="tick" from="." to="Player" method="_on_chrono_manager_tick"]
|
||||
[connection signal="object_clicked" from="Player" to="." method="_on_player_object_clicked"]
|
||||
[connection signal="body_entered" from="EndZone/Area3D" to="." method="_on_area_3d_body_entered"]
|
||||
|
|
|
|||
|
|
@ -170,3 +170,8 @@ func open_termimal():
|
|||
func _on_player_object_clicked(object):
|
||||
if(object.name == "StartButton"):
|
||||
start_room()
|
||||
|
||||
|
||||
func _on_area_3d_body_entered(body):
|
||||
if body.name == "Player":
|
||||
GameManager.load_next_level()
|
||||
|
|
|
|||
5
Scripts/level_res.gd
Normal file
5
Scripts/level_res.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extends Resource
|
||||
class_name LevelRes
|
||||
|
||||
@export var level_path : String
|
||||
@export var level_name : String
|
||||
|
|
@ -5,9 +5,16 @@ var credits_shown : bool = false
|
|||
@export var level_node : Control
|
||||
@export var credits_node : Control
|
||||
@export var credits_button : Button
|
||||
@export var levels_vbox : VBoxContainer
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
for level_num in GameManager.levels.size():
|
||||
var new_button : Button = Button.new()
|
||||
new_button.text = "Level " + str(level_num) + " : " + GameManager.levels[level_num].level_name
|
||||
new_button.pressed.connect(func(): pick_level(GameManager.levels[level_num].level_name))
|
||||
levels_vbox.add_child(new_button)
|
||||
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
|
|
@ -23,6 +30,11 @@ func _process(delta):
|
|||
credits_button.text = "Credits"
|
||||
|
||||
|
||||
func pick_level(picked_level:String):
|
||||
for level in GameManager.levels:
|
||||
if level.level_name == picked_level:
|
||||
get_tree().change_scene_to_file(level.level_path)
|
||||
|
||||
func _on_credits_button_pressed():
|
||||
credits_shown = !credits_shown
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
extends Node
|
||||
|
||||
@export var levels : Array[String] = [
|
||||
""
|
||||
]
|
||||
@export var levels : Array[LevelRes]
|
||||
@export var menu_scene_path : String
|
||||
@export var sandbox_scene_path : String
|
||||
var current_level = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
|
@ -16,7 +16,8 @@ func _process(delta):
|
|||
|
||||
func load_next_level():
|
||||
if current_level+1 < levels.size():
|
||||
get_tree().change_scene_to_file(levels[current_level+1])
|
||||
get_tree().change_scene_to_file(levels[current_level+1].level_path)
|
||||
else:
|
||||
#ending screen
|
||||
print("end of game reached!")
|
||||
get_tree().change_scene_to_file(menu_scene_path)
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,6 +1,20 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://d387n4cp3duhn"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d387n4cp3duhn"]
|
||||
|
||||
[ext_resource type="Script" path="res://game_manager.gd" id="1_rsuf4"]
|
||||
[ext_resource type="Script" path="res://Scripts/level_res.gd" id="2_w2hey"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rp7k0"]
|
||||
script = ExtResource("2_w2hey")
|
||||
level_path = "res://Levels/StartingRoom.tscn"
|
||||
level_name = "Test Room"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vs5fw"]
|
||||
script = ExtResource("2_w2hey")
|
||||
level_path = "res://Levels/Level 1.tscn"
|
||||
level_name = "A Small Hop"
|
||||
|
||||
[node name="GameManager" type="Node"]
|
||||
script = ExtResource("1_rsuf4")
|
||||
levels = Array[ExtResource("2_w2hey")]([SubResource("Resource_rp7k0"), SubResource("Resource_vs5fw")])
|
||||
menu_scene_path = "res://Scripts/menu.gd"
|
||||
sandbox_scene_path = "res://Levels/StartingRoom.tscn"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ font_color = Color(0.631665, 0.267098, 1, 1)
|
|||
outline_size = 15
|
||||
outline_color = Color(1, 0.446282, 0.988369, 1)
|
||||
|
||||
[node name="Menu" type="Control" node_paths=PackedStringArray("level_node", "credits_node", "credits_button")]
|
||||
[node name="Menu" type="Control" node_paths=PackedStringArray("level_node", "credits_node", "credits_button", "levels_vbox")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -19,6 +19,7 @@ script = ExtResource("1_igukb")
|
|||
level_node = NodePath("MarginContainer/VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer")
|
||||
credits_node = NodePath("MarginContainer/VBoxContainer/PanelContainer/ScrollContainer/MarginContainer/CreditsPage")
|
||||
credits_button = NodePath("MarginContainer/VBoxContainer/HBoxContainer/CreditsButton")
|
||||
levels_vbox = NodePath("MarginContainer/VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
|
|
@ -55,27 +56,31 @@ layout_mode = 2
|
|||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/PanelContainer/ScrollContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Button" type="Button" parent="MarginContainer/VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Level 1 - Name"
|
||||
|
||||
[node name="Button2" type="Button" parent="MarginContainer/VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Level 1 - Name"
|
||||
|
||||
[node name="Button3" type="Button" parent="MarginContainer/VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Level 1 - Name"
|
||||
|
||||
[node name="Button4" type="Button" parent="MarginContainer/VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Level 1 - Name"
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/PanelContainer/ScrollContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ config/icon="res://icon.svg"
|
|||
|
||||
[autoload]
|
||||
|
||||
GameManager="*res://game_manager.gd"
|
||||
GameManager="*res://game_manager.tscn"
|
||||
|
||||
[editor]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue