diff --git a/assets/chest_spawner.tscn b/assets/chest_spawner.tscn deleted file mode 100644 index b9326c6..0000000 --- a/assets/chest_spawner.tscn +++ /dev/null @@ -1,20 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://db7xqf12sayj0"] - -[sub_resource type="BoxMesh" id="BoxMesh_nbeyo"] - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3gsvj"] - -[sub_resource type="CylinderMesh" id="CylinderMesh_cbsxv"] -top_radius = 0.1 -bottom_radius = 0.1 -height = 1.0 - -[node name="ChestSpawner" type="Node3D" groups=["chest_spawner"]] - -[node name="MeshInstance3D" type="MeshInstance3D" parent="."] -mesh = SubResource("BoxMesh_nbeyo") -surface_material_override/0 = SubResource("StandardMaterial3D_3gsvj") - -[node name="MeshInstance3D2" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 1.01635) -mesh = SubResource("CylinderMesh_cbsxv") diff --git a/assets/die_particles.tscn b/assets/die_particles.tscn index 6a6e516..eb33ca6 100644 --- a/assets/die_particles.tscn +++ b/assets/die_particles.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" uid="uid://bdecyikiye08i" path="res://scripts/die_particles.gd" id="1_frf2k"] [ext_resource type="AudioStream" uid="uid://wd061pl0d7rl" path="res://assets/Audio/deep-low-explosion-SBA-300054677.wav" id="2_ddmln"] -[ext_resource type="Texture2D" uid="uid://dmyn4eq2r12ue" path="res://assets/Models/spider1.albedoRAW.png" id="3_81mhs"] +[ext_resource type="Texture2D" uid="uid://c6nvp1khihvhj" path="res://assets/Models/spider1.albedoRAW.png" id="3_81mhs"] [ext_resource type="Texture2D" uid="uid://dqhke14ulten2" path="res://assets/Models/spider1.roughnessRAW.png" id="4_ahnbu"] [ext_resource type="Texture2D" uid="uid://b4s3w1qnqcmgq" path="res://assets/Models/spider1.gunbarrel.albedo.png" id="4_pb8pm"] [ext_resource type="Texture2D" uid="uid://d4l5wf34qdvli" path="res://assets/Models/spider1.turret.png" id="5_hogev"] diff --git a/levels/LevelModels/Hub1.blend b/levels/LevelModels/Hub1.blend index 666853d..b662eeb 100644 Binary files a/levels/LevelModels/Hub1.blend and b/levels/LevelModels/Hub1.blend differ diff --git a/levels/LevelModels/Hub1.blend1 b/levels/LevelModels/Hub1.blend1 index 9b22c26..666853d 100644 Binary files a/levels/LevelModels/Hub1.blend1 and b/levels/LevelModels/Hub1.blend1 differ diff --git a/scenes/highwire.tscn b/scenes/highwire.tscn index d97ad02..70e3a20 100644 --- a/scenes/highwire.tscn +++ b/scenes/highwire.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=21 format=3 uid="uid://uo43j7bomkf3"] +[gd_scene load_steps=22 format=3 uid="uid://uo43j7bomkf3"] +[ext_resource type="Script" uid="uid://pm8n67yhip1p" path="res://scripts/sublevel.gd" id="1_e6kt2"] [ext_resource type="PackedScene" uid="uid://cwy8iv8nlwqrc" path="res://assets/realtime_day_night_cycle.tscn" id="3_uc3ig"] [ext_resource type="Script" uid="uid://12l74jckdnpl" path="res://scripts/room_manager.gd" id="4_iqtg8"] [ext_resource type="PackedScene" uid="uid://djr7vnr1hcx82" path="res://assets/spider2.tscn" id="5_vb31s"] @@ -10,8 +11,8 @@ [ext_resource type="PackedScene" uid="uid://24slv0pyxcd5" path="res://assets/level_bounds.tscn" id="16_8ulfh"] [ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="17_6thjn"] [ext_resource type="PackedScene" uid="uid://dc0fxhbw6x1h3" path="res://tube_top.tscn" id="17_57hjo"] +[ext_resource type="PackedScene" uid="uid://c5t4uqihf8q0i" path="res://scripts/chest_spawner.tscn" id="17_e6kt2"] [ext_resource type="PackedScene" uid="uid://dt4t2a48204v1" path="res://assets/spikes_1.tscn" id="17_hpnr5"] -[ext_resource type="PackedScene" uid="uid://db7xqf12sayj0" path="res://assets/chest_spawner.tscn" id="17_mw655"] [ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="18_1ool5"] [ext_resource type="PackedScene" uid="uid://c0vc26f4warsi" path="res://scripts/cloud_spawner.tscn" id="18_e6kt2"] [ext_resource type="PackedScene" uid="uid://do6gt53xr2l23" path="res://assets/garbage_bin.tscn" id="18_r6s5q"] @@ -29,6 +30,7 @@ albedo_color = Color(0.300579, 0.462784, 0.249767, 1) size = Vector3(722.834, 289.347, 420.508) [node name="Highwire" type="Node3D"] +script = ExtResource("1_e6kt2") [node name="Realtime Day Night Cycle" parent="." instance=ExtResource("3_uc3ig")] transform = Transform3D(0.510503, -0.00501647, 0.859861, 0.00982605, 0.999952, 1.08313e-09, -0.85982, 0.00844904, 0.510527, -41.021, 0, 40.533) @@ -299,21 +301,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.9072, -0.1705, 12.0777) [node name="Spikes 5" parent="." instance=ExtResource("17_hpnr5")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -203.179, -0.1705, 11.0759) -[node name="ChestSpawner" parent="." instance=ExtResource("17_mw655")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -197.055, 28.7598, -23.1374) - -[node name="ChestSpawner2" parent="." instance=ExtResource("17_mw655")] -transform = Transform3D(0.326146, 0, 0.94532, 0, 1, 0, -0.94532, 0, 0.326146, -245.963, 17.0575, -26.9477) - -[node name="ChestSpawner3" parent="." instance=ExtResource("17_mw655")] -transform = Transform3D(0.419579, 0, 0.907719, 0, 1, 0, -0.907719, 0, 0.419579, -237.2, 1.26645, -39.3357) - -[node name="ChestSpawner4" parent="." instance=ExtResource("17_mw655")] -transform = Transform3D(0.419579, 0, 0.907719, 0, 1, 0, -0.907719, 0, 0.419579, -237.2, 1.26645, -70.919) - -[node name="ChestSpawner5" parent="." instance=ExtResource("17_mw655")] -transform = Transform3D(0.419579, 0, 0.907719, 0, 1, 0, -0.907719, 0, 0.419579, -237.2, 1.26645, -98.4264) - [node name="GarbageBin" parent="." instance=ExtResource("18_r6s5q")] transform = Transform3D(-0.714729, 0, -0.699401, 0, 1, 0, 0.699401, 0, -0.714729, -4.96806, -0.170516, 18.2021) @@ -352,3 +339,23 @@ size = Vector3(102.386, 146.752, 579.126) [node name="Cloudspawn6" parent="." instance=ExtResource("18_e6kt2")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -567.32, 59.7442, -47.1966) size = Vector3(102.386, 146.752, 579.126) + +[node name="ChestSpawner" parent="." instance=ExtResource("17_e6kt2")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -230.434, 17.394, -66.4599) +size = Vector3(39, 4.19531, 120.959) + +[node name="ChestSpawner2" parent="." instance=ExtResource("17_e6kt2")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -198.325, 27.2852, -20.5712) +size = Vector3(21.75, 2.03613, 19.1631) + +[node name="ChestSpawner3" parent="." instance=ExtResource("17_e6kt2")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -237.215, 1.4657, -104.908) +size = Vector3(21.75, 2.03613, 19.1631) + +[node name="ChestSpawner4" parent="." instance=ExtResource("17_e6kt2")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -237.215, 1.83144, -68.4389) +size = Vector3(21.75, 2.03613, 19.1631) + +[node name="ChestSpawner5" parent="." instance=ExtResource("17_e6kt2")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -237.215, 1.62245, -39.3783) +size = Vector3(21.75, 2.03613, 19.1631) diff --git a/scripts/HelperFuncs.gd b/scripts/HelperFuncs.gd index 48540f1..ccaf7ee 100644 --- a/scripts/HelperFuncs.gd +++ b/scripts/HelperFuncs.gd @@ -66,3 +66,8 @@ func checksum(check_data): checksum_final = hash(checksum_final) return checksum_final + +func clear_spawned_objects(): + #clear spawned objects + for node in get_tree().get_nodes_in_group("spawned"): + node.queue_free() diff --git a/scripts/LevelManager.gd b/scripts/LevelManager.gd index b955fa4..6cffc43 100644 --- a/scripts/LevelManager.gd +++ b/scripts/LevelManager.gd @@ -61,36 +61,15 @@ func _ready(): refresh_scene() spawn_crown() - #global randomize function - randomize() - - #clear spawned in objects - for node in get_tree().get_nodes_in_group("spawned"): - node.queue_free() + HelperFuncs.clear_spawned_objects() #find enemy hiveminds for node in get_tree().get_nodes_in_group("enemy_hivemind"): enemy_hiveminds.append(node) #count starting enemies enemy_count() - - chest_spawners = get_tree().get_nodes_in_group("chest_spawner") - if chest_spawners.size() > 0: - for i in chest_spawners: - i.visible = false - - var number_chests = randi_range(1,gamemode.max_number_of_chests) - - while number_chests > 0: - var chest_loc = chest_spawners.pick_random() - var instance_chest = CHEST_1.instantiate() - print("SPAWNING CHEST AT : ",chest_loc.name) - add_child(instance_chest) - instance_chest.basis = chest_loc.basis - instance_chest.global_position = chest_loc.global_position - instance_chest.global_rotation = chest_loc.global_rotation - number_chests -= 1 + spawn_chests() func refresh_scene(): @@ -108,6 +87,24 @@ func spawn_crown(): if crown_target.is_in_group("enemy"): crown_target.loot_amount = 10 +func spawn_chests(): + chest_spawners = get_tree().get_nodes_in_group("chest_spawner") + if chest_spawners.size() > 0: + for i in chest_spawners: + i.visible = false + + var number_chests = randi_range(1,gamemode.max_number_of_chests) + + while number_chests > 0: + var chest_loc = chest_spawners.pick_random() + var instance_chest = CHEST_1.instantiate() + print("SPAWNING CHEST AT : ",chest_loc.name) + add_child(instance_chest) + instance_chest.basis = chest_loc.basis + instance_chest.global_position = chest_loc.global_position + instance_chest.global_rotation = chest_loc.global_rotation + number_chests -= 1 + func gun_spawn(index): #loop around if scrolling past available guns diff --git a/scripts/chest_1.gd b/scripts/chest_1.gd index 5ff4bd5..0f34c6f 100644 --- a/scripts/chest_1.gd +++ b/scripts/chest_1.gd @@ -22,11 +22,6 @@ func _ready() -> void: GameGlobals.chests_spawned += 1 serial_label.text = "#" + str(serial_number).pad_zeros(4) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - func hit(dam): health -= dam if !open and health <= 0: diff --git a/scripts/chest_spawner.tscn b/scripts/chest_spawner.tscn new file mode 100644 index 0000000..6d95c24 --- /dev/null +++ b/scripts/chest_spawner.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://c5t4uqihf8q0i"] + +[ext_resource type="Script" uid="uid://fs6qd8efarl7" path="res://scripts/csg_spawner.gd" id="1_l7ryb"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_hthjk"] +transparency = 1 +shading_mode = 0 +albedo_color = Color(1, 1, 1, 0) + +[node name="ChestSpawner" type="CSGBox3D" groups=["chest_spawner"]] +material = SubResource("StandardMaterial3D_hthjk") +script = ExtResource("1_l7ryb") diff --git a/scripts/cloudSpawner.gd b/scripts/cloudSpawner.gd index 40ab9cf..77d4425 100644 --- a/scripts/cloudSpawner.gd +++ b/scripts/cloudSpawner.gd @@ -1,4 +1,4 @@ -extends CSGBox3D +extends CSGSpawner @export var number_of_clouds : int = 50 @export var cloud = preload("res://cloud1.tscn") @@ -10,10 +10,7 @@ func spawn_clouds(): while number_of_clouds >= 0: number_of_clouds -= 1 - var x : float = randf_range(size.x / 2, -size.x /2) - var y : float = randf_range(size.y/ 2, -size.y /2) - var z : float = randf_range(size.z / 2, -size.z /2) - var spawn_pos = Vector3(x,y,z) + var spawn_pos = random_box_pos() var cloud = cloud.instantiate() add_child(cloud) diff --git a/scripts/csg_spawner.gd b/scripts/csg_spawner.gd new file mode 100644 index 0000000..8f9ee3b --- /dev/null +++ b/scripts/csg_spawner.gd @@ -0,0 +1,8 @@ +extends CSGBox3D +class_name CSGSpawner + +func random_box_pos(): + var x : float = randf_range(size.x / 2, -size.x /2) + var y : float = randf_range(size.y/ 2, -size.y /2) + var z : float = randf_range(size.z / 2, -size.z /2) + return Vector3(x,y,z) diff --git a/scripts/csg_spawner.gd.uid b/scripts/csg_spawner.gd.uid new file mode 100644 index 0000000..66e31a7 --- /dev/null +++ b/scripts/csg_spawner.gd.uid @@ -0,0 +1 @@ +uid://fs6qd8efarl7 diff --git a/scripts/scene_changer.gd b/scripts/scene_changer.gd index ad616ad..19bc9b0 100644 --- a/scripts/scene_changer.gd +++ b/scripts/scene_changer.gd @@ -26,14 +26,10 @@ func _on_body_entered(body: Node3D) -> void: entered = true if active and entered: + HelperFuncs.clear_spawned_objects() var spawned_stuff = scene_holder.get_children() for i in spawned_stuff: i.queue_free() -func clear_spawned_objects(): - for i in get_tree().current_scene: - if i.is_in_group("spawned"): - i.queue_free() - func _on_start_activation_timeout() -> void: active = true diff --git a/scripts/sublevel.gd b/scripts/sublevel.gd new file mode 100644 index 0000000..e2b0ded --- /dev/null +++ b/scripts/sublevel.gd @@ -0,0 +1,24 @@ +extends Node3D + +const CHEST_1 = preload("res://chest1.tscn") + +func _ready() -> void: + spawn_chests() + +func spawn_chests(): + var chest_spawners = get_tree().get_nodes_in_group("chest_spawner") + + + if chest_spawners.size() > 0: + for i in chest_spawners: + i.visible = false + + var number_chests = 3 + + while number_chests > 0: + var chest_loc = chest_spawners.pick_random() + var instance_chest = CHEST_1.instantiate() + get_tree().current_scene.add_child(instance_chest) + instance_chest.global_position = chest_loc.global_position + chest_loc.random_box_pos() + print("CHEST SPAWNED AT : ",instance_chest.global_position) + number_chests -= 1 diff --git a/scripts/sublevel.gd.uid b/scripts/sublevel.gd.uid new file mode 100644 index 0000000..43126a5 --- /dev/null +++ b/scripts/sublevel.gd.uid @@ -0,0 +1 @@ +uid://pm8n67yhip1p