From 7c47381d86435b99df5345e2f311519b456c573a Mon Sep 17 00:00:00 2001 From: ncusimano Date: Sun, 20 Aug 2023 16:43:13 -0600 Subject: [PATCH] Spawner Added On top of skyscraper :) --- godot/CameraTest.tscn | 6 +++++- godot/Level/Island.tscn | 14 +++++++++----- godot/Models/grape_man.tscn | 12 +++--------- godot/player.tscn | 2 +- godot/spawner.gd | 30 ++++++++++++++++++++++++++++++ godot/spawner.tscn | 10 ++++++++++ 6 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 godot/spawner.gd create mode 100644 godot/spawner.tscn diff --git a/godot/CameraTest.tscn b/godot/CameraTest.tscn index fc9da98..02fbd56 100644 --- a/godot/CameraTest.tscn +++ b/godot/CameraTest.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://cdm267rtmop75"] +[gd_scene load_steps=7 format=3 uid="uid://cdm267rtmop75"] [ext_resource type="PackedScene" uid="uid://c4s6y758n77lw" path="res://villager_shared.tscn" id="1_6uu34"] [ext_resource type="PackedScene" uid="uid://7utef1nnena8" path="res://player.tscn" id="1_jbc4n"] [ext_resource type="PackedScene" uid="uid://e0s4phx2jiit" path="res://cultist.tscn" id="3_renxb"] +[ext_resource type="PackedScene" uid="uid://d0uw7ykhb1cx8" path="res://spawner.tscn" id="4_ib8u6"] [sub_resource type="CylinderMesh" id="CylinderMesh_c2b6h"] top_radius = 80.23 @@ -32,3 +33,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.87818, 2, 0.191837) [node name="Player" parent="." instance=ExtResource("1_jbc4n")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.140476, 0.999999, 1.27725) + +[node name="Node3D" parent="." instance=ExtResource("4_ib8u6")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 3) diff --git a/godot/Level/Island.tscn b/godot/Level/Island.tscn index 64023ef..9f48542 100644 --- a/godot/Level/Island.tscn +++ b/godot/Level/Island.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=33 format=3 uid="uid://3d51hjh2st8a"] +[gd_scene load_steps=34 format=3 uid="uid://3d51hjh2st8a"] [ext_resource type="PackedScene" uid="uid://d2d4uv7o5gx5p" path="res://Level/World/screen_shader.tscn" id="1_huyen"] [ext_resource type="PackedScene" uid="uid://d3ccrfjpg4hbv" path="res://Models/palm_curved.tscn" id="3_bth2b"] @@ -22,12 +22,13 @@ [ext_resource type="PackedScene" uid="uid://c4s6y758n77lw" path="res://villager_shared.tscn" id="24_ddfvk"] [ext_resource type="PackedScene" uid="uid://b3aus2kigf8xt" path="res://Models/beach_decor/cooler.tscn" id="24_sl7ne"] [ext_resource type="PackedScene" uid="uid://cft26nug7kyqb" path="res://ambient_light_1.tscn" id="25_novxt"] -[ext_resource type="PackedScene" uid="uid://ukful430mmkn" path="res://color_cube.tscn" id="25_rm0cr"] -[ext_resource type="PackedScene" uid="uid://d2pvg0f5jtpve" path="res://slime_kill_box.tscn" id="27_cjxk6"] +[ext_resource type="PackedScene" path="res://color_cube.tscn" id="25_rm0cr"] +[ext_resource type="PackedScene" path="res://slime_kill_box.tscn" id="27_cjxk6"] [ext_resource type="PackedScene" uid="uid://bw3k2c75qavce" path="res://Models/beach_decor/bucket.tscn" id="27_f3p1i"] -[ext_resource type="PackedScene" uid="uid://6ycop5t3nra5" path="res://Level/World/DayNightEnvironment.tscn" id="27_jutn4"] +[ext_resource type="PackedScene" path="res://Level/World/DayNightEnvironment.tscn" id="27_jutn4"] [ext_resource type="PackedScene" uid="uid://g4gmc0pwlak1" path="res://Models/buildings/fence.tscn" id="28_prydb"] -[ext_resource type="PackedScene" uid="uid://ckbba1bs71tl" path="res://crate.tscn" id="28_x0lrj"] +[ext_resource type="PackedScene" path="res://crate.tscn" id="28_x0lrj"] +[ext_resource type="PackedScene" uid="uid://d0uw7ykhb1cx8" path="res://spawner.tscn" id="29_etvc6"] [sub_resource type="Animation" id="Animation_jpnyu"] resource_name = "waves" @@ -491,6 +492,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.75088, 2.39766, -4.28161) [node name="Crate4" parent="." instance=ExtResource("28_x0lrj")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.31447, 2.55588, -2.13044) +[node name="Node3D" parent="." instance=ExtResource("29_etvc6")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.41845, 9.26863, -2.62281) + [connection signal="finished" from="Music" to="Music" method="_on_finished"] [connection signal="timeout" from="Music/Transition" to="Music" method="_on_transition_timer_timeout"] [connection signal="timeout" from="Music/Tween" to="Music" method="_on_tween_timer_timeout"] diff --git a/godot/Models/grape_man.tscn b/godot/Models/grape_man.tscn index 759ad10..017e66a 100644 --- a/godot/Models/grape_man.tscn +++ b/godot/Models/grape_man.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=42 format=3 uid="uid://bgoo1lbt28na"] +[gd_scene load_steps=41 format=3 uid="uid://bgoo1lbt28na"] [ext_resource type="PackedScene" uid="uid://bhanbx2dyhv2d" path="res://Models/grape_man.glb" id="1_fh5yr"] [ext_resource type="Script" path="res://Models/grape_man.gd" id="2_ksje8"] @@ -6,7 +6,6 @@ [ext_resource type="AudioStream" uid="uid://baocyd0p3jcku" path="res://Sounds/pickup_grunt.ogg" id="4_nvurj"] [ext_resource type="AudioStream" uid="uid://b80t5xqckjoqk" path="res://Sounds/heartychuckle.ogg" id="5_b32re"] [ext_resource type="AudioStream" uid="uid://0mhkf1ls1wcn" path="res://Sounds/sadsound.ogg" id="6_qe4bi"] -[ext_resource type="AudioStream" uid="uid://bmocmgq06o6f5" path="res://Sounds/footstep.ogg" id="7_b2ik0"] [sub_resource type="AnimationNodeAdd2" id="AnimationNodeAdd2_a0vxm"] filters = ["rig/Skeleton3D:forearm.L", "rig/Skeleton3D:forearm.R", "rig/Skeleton3D:head", "rig/Skeleton3D:upper_arm.L", "rig/Skeleton3D:upper_arm.R"] @@ -155,7 +154,7 @@ transform = Transform3D(0.065, 0, 0, 0, 0.065, 0, 0, 0, 0.065, 0, 0, 0) script = ExtResource("2_ksje8") [node name="Skeleton3D" parent="rig" index="0"] -bones/0/rotation = Quaternion(0.0733902, 0, 0, 0.997303) +bones/0/rotation = Quaternion(0.0684942, 0, 0, 0.997652) bones/1/rotation = Quaternion(-0.0891896, 1.18734e-07, -1.06322e-08, 0.996015) bones/2/rotation = Quaternion(0.0133933, -1.19199e-07, 1.5966e-09, 0.99991) bones/3/rotation = Quaternion(-0.00997737, 0.100365, -0.694951, 0.711948) @@ -170,7 +169,6 @@ bones/15/rotation = Quaternion(0.105246, -0.0039338, 0.0113526, 0.994374) [node name="OmniLight3D" type="OmniLight3D" parent="." index="2"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.289473, 8.26292, 4.26359) -light_energy = 0.5 [node name="AnimationTree" type="AnimationTree" parent="." index="3"] tree_root = SubResource("AnimationNodeStateMachine_6mfdu") @@ -193,9 +191,5 @@ stream = ExtResource("5_b32re") [node name="sad" type="AudioStreamPlayer" parent="." index="7"] stream = ExtResource("6_qe4bi") -[node name="soundboard" type="AudioStreamPlayer" parent="." index="8"] +[node name="woohoo" type="AudioStreamPlayer" parent="." index="8"] stream = ExtResource("6_qe4bi") - -[node name="footstep" type="AudioStreamPlayer" parent="." index="9"] -stream = ExtResource("7_b2ik0") -volume_db = -10.0 diff --git a/godot/player.tscn b/godot/player.tscn index 55e8271..cff76ff 100644 --- a/godot/player.tscn +++ b/godot/player.tscn @@ -25,7 +25,7 @@ shape = SubResource("CapsuleShape3D_kb4ms") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.389874, 0) [node name="PlayerCam" type="Camera3D" parent="CameraMount"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.930216) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.643936) fov = 50.0 [node name="Holster" type="Node3D" parent="."] diff --git a/godot/spawner.gd b/godot/spawner.gd new file mode 100644 index 0000000..ac68b03 --- /dev/null +++ b/godot/spawner.gd @@ -0,0 +1,30 @@ +extends Node3D + +var rng = RandomNumberGenerator.new() +var spawnableItems: Array + +# Called when the node enters the scene tree for the first time. +func _ready(): + $SpawnTimer.wait_time = 10 + $SpawnTimer.one_shot = true + + spawnableItems.append(load("res://cultist.tscn")) + spawnableItems.append(load("res://villager_shared.tscn")) + + $SpawnTimer.start() + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _on_spawn_timer_timeout(): + var item_to_spawn = rng.randi_range(0, spawnableItems.size() - 1) + var spawned_item = spawnableItems[item_to_spawn].instantiate() + get_parent_node_3d().add_child(spawned_item) + + spawned_item.set_global_position(global_transform.origin) + spawned_item.set_velocity(Vector3(rng.randf_range(0, 3), rng.randf_range(1, 3), rng.randf_range(0, 3))) + + # Start the timer again at a random rate. + $SpawnTimer.wait_time = rng.randi_range(120, 300) + $SpawnTimer.start() diff --git a/godot/spawner.tscn b/godot/spawner.tscn new file mode 100644 index 0000000..788b1ea --- /dev/null +++ b/godot/spawner.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://d0uw7ykhb1cx8"] + +[ext_resource type="Script" path="res://spawner.gd" id="1_xameb"] + +[node name="Spawner" type="Node3D"] +script = ExtResource("1_xameb") + +[node name="SpawnTimer" type="Timer" parent="."] + +[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"]