diff --git a/GameModes/hubworld.tres b/GameModes/hubworld.tres new file mode 100644 index 0000000..7c4ea9f --- /dev/null +++ b/GameModes/hubworld.tres @@ -0,0 +1,37 @@ +[gd_resource type="Resource" script_class="gamemode" load_steps=2 format=3 uid="uid://bxcxqt7rmfvdw"] + +[ext_resource type="Script" path="res://gamemode.gd" id="1_bpthy"] + +[resource] +script = ExtResource("1_bpthy") +gamemode_name = "HUB" +win_conditions = null +survival_time = 160.0 +money_lost_multiplier = 0.5 +weapon_penalty = 0 +weapon_drop_percentage = 0.5 +walk_speed = 12.0 +jump_velocity = 5 +dash_speed = 40 +gravity = -9.8 +time_slowed_speed = 0.1 +stamina_regen = true +max_stamina = 100.0 +stamina_drain = 20.0 +air_dash_max = 1 +load_save = false +money_drop_multiplier = 1.0 +start_health = 10 +drop_chance_minimum = 0.1 +random_drops = false +ammo_drop_enabled = true +expected_ammo = { +"heavy": 25, +"light": 200, +"medium": 50, +"rocket": 3, +"shotgun": 20 +} +stamina_drop_enabled = true +health_drop_enabled = true +money_drop_enabled = true diff --git a/GameModes/nostaminaregen.tres b/GameModes/nostaminaregen.tres index a36dc83..03bed52 100644 --- a/GameModes/nostaminaregen.tres +++ b/GameModes/nostaminaregen.tres @@ -4,8 +4,8 @@ [resource] script = ExtResource("1_d71ib") -win_conditions = 0 gamemode_name = "no stamina regen, no health drops" +win_conditions = 0 survival_time = 160.0 walk_speed = 12.0 jump_velocity = 5 @@ -30,5 +30,5 @@ expected_ammo = { "shotgun": 20 } stamina_drop_enabled = true -health_drop_enabled = true +health_drop_enabled = false money_drop_enabled = true diff --git a/GameModes/standard.tres b/GameModes/standard.tres index cf26784..c208ac4 100644 --- a/GameModes/standard.tres +++ b/GameModes/standard.tres @@ -7,17 +7,20 @@ script = ExtResource("1_litni") gamemode_name = "Standard" win_conditions = 0 survival_time = 160.0 +money_lost_multiplier = 0.5 +weapon_penalty = 0 +weapon_drop_percentage = 0.5 walk_speed = 12.0 jump_velocity = 5 dash_speed = 40 gravity = -9.8 time_slowed_speed = 0.1 -stamina_regen = true +stamina_regen = false max_stamina = 100.0 stamina_drain = 20.0 air_dash_max = 1 -load_save = true -money = 0 +load_save = false +money_drop_multiplier = 1.0 start_health = 10 drop_chance_minimum = 0.1 random_drops = false diff --git a/assets/blockout_2.tscn b/assets/blockout_2.tscn index 38fb341..96ef3e1 100644 --- a/assets/blockout_2.tscn +++ b/assets/blockout_2.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=112 format=4 uid="uid://6agmt1hqlhww"] [ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_sbpvn"] -[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_fn4vb"] +[ext_resource type="Resource" uid="uid://dn3t7wcoumlm3" path="res://GameModes/standard.tres" id="2_cuqu0"] [ext_resource type="Texture2D" uid="uid://ckjcv72jcojjh" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_DIFF (Custom).jpg" id="3_3ov8a"] [ext_resource type="LightmapGIData" uid="uid://bwpvltmeo4cfl" path="res://assets/LevelBlockouts/blockout_2.lmbake" id="3_d2pxn"] [ext_resource type="Texture2D" uid="uid://d210plbmb7a2o" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_NORM (Custom).jpg" id="4_5u2rd"] @@ -898,12 +898,8 @@ _data = { [node name="BLOCKOUT2Test" type="Node3D" node_paths=PackedStringArray("player")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.016016, 0.0225029, -0.0192337) script = ExtResource("1_sbpvn") -load_save = false +gamemode = ExtResource("2_cuqu0") player = NodePath("Player") -money = 50 -start_health = 5 -gun_1 = ExtResource("2_fn4vb") -health_drop_enabled = false [node name="Player" parent="." instance=ExtResource("9_3usor")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.137423, 1.78365, 12.8627) diff --git a/assets/cleared_announce.tscn b/assets/cleared_announce.tscn deleted file mode 100644 index 9e004cf..0000000 --- a/assets/cleared_announce.tscn +++ /dev/null @@ -1,28 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://b3kmoledivusi"] - -[ext_resource type="FontFile" uid="uid://d2h2tjhxiv5wo" path="res://assets/fonts/White On Black.ttf" id="1_3u3rp"] -[ext_resource type="Script" path="res://scripts/dead_announce.gd" id="2_12exd"] - -[sub_resource type="LabelSettings" id="LabelSettings_ic2ps"] -font = ExtResource("1_3u3rp") -font_size = 500 - -[node name="PickupAnnounce" type="Label"] -offset_right = 3440.0 -offset_bottom = 1440.0 -size_flags_horizontal = 3 -size_flags_vertical = 6 -text = "CLEARED" -label_settings = SubResource("LabelSettings_ic2ps") -horizontal_alignment = 1 -vertical_alignment = 1 -script = ExtResource("2_12exd") - -[node name="ColorRect" type="ColorRect" parent="."] -visible = false -y_sort_enabled = true -layout_mode = 0 -offset_top = 1.0 -offset_right = 3840.0 -offset_bottom = 2161.0 -color = Color(0.615686, 0, 0.0980392, 0.356863) diff --git a/assets/level_sign.tscn b/assets/level_sign.tscn new file mode 100644 index 0000000..90d230f --- /dev/null +++ b/assets/level_sign.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=3 uid="uid://eujx0yilqqcp"] + +[ext_resource type="FontFile" uid="uid://d2h2tjhxiv5wo" path="res://assets/fonts/White On Black.ttf" id="1_uwkow"] +[ext_resource type="Script" path="res://scripts/level_sign.gd" id="1_vvlkm"] + +[node name="Level Sign" type="Node3D"] +script = ExtResource("1_vvlkm") + +[node name="Level Name" type="Label3D" parent="."] +transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0.142793, 0.875884, 0) +text = "Test" +font = ExtResource("1_uwkow") +font_size = 100 + +[node name="Gamemode" type="Label3D" parent="."] +transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0.142793, 0.200374, 0) +text = "Test" +font = ExtResource("1_uwkow") +font_size = 100 diff --git a/assets/player.tscn b/assets/player.tscn index 32f3982..45f056c 100644 --- a/assets/player.tscn +++ b/assets/player.tscn @@ -61,7 +61,7 @@ shader_parameter/noise = SubResource("NoiseTexture2D_0eorp") size = Vector3(3, 3.58057, 3) [sub_resource type="SphereShape3D" id="SphereShape3D_xfie3"] -radius = 7.0 +radius = 5.0 [sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_pxyjg"] random_pitch = 2.0 @@ -264,6 +264,7 @@ collision_layer = 0 collision_mask = 16 [node name="CollisionShape3D" type="CollisionShape3D" parent="pick_up_magnet"] +transform = Transform3D(1, -1.35287e-11, -5.82077e-11, 7.56017e-12, 1, 0, 0, 0, 1, 0.00132301, 0.00235856, -2.26706) shape = SubResource("SphereShape3D_xfie3") [node name="Audio" type="Node3D" parent="."] diff --git a/assets/scene_changer.tscn b/assets/scene_changer.tscn new file mode 100644 index 0000000..932c548 --- /dev/null +++ b/assets/scene_changer.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=5 format=3 uid="uid://dgapcuvg0gtmm"] + +[ext_resource type="Script" path="res://scripts/scene_changer.gd" id="1_7ngxb"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_mvtr6"] + +[sub_resource type="SphereMesh" id="SphereMesh_wfy04"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qd8ax"] +transparency = 1 +blend_mode = 1 +emission_enabled = true +emission = Color(0.223698, 0.336652, 0.628522, 1) +emission_energy_multiplier = 5.6 + +[node name="Scene Changer" type="Area3D"] +collision_layer = 4 +collision_mask = 4 +script = ExtResource("1_7ngxb") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("BoxShape3D_mvtr6") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +visible = false +mesh = SubResource("SphereMesh_wfy04") +surface_material_override/0 = SubResource("StandardMaterial3D_qd8ax") + +[node name="Start_Activation" type="Timer" parent="."] +wait_time = 0.5 +autostart = true + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] +[connection signal="timeout" from="Start_Activation" to="." method="_on_start_activation_timeout"] diff --git a/assets/stats.tscn b/assets/stats.tscn index 921873d..8e55206 100644 --- a/assets/stats.tscn +++ b/assets/stats.tscn @@ -7,24 +7,31 @@ script = ExtResource("1_q47is") [node name="Gamemode" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.66069, 0) +transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0.142793, 0.747273, 0) +text = "Test" +font = ExtResource("2_mtulh") +font_size = 100 + +[node name="High Score" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.396692, 0) text = "Test" font = ExtResource("2_mtulh") horizontal_alignment = 0 [node name="Kills" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.423311, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.137377, 0) text = "Test" font = ExtResource("2_mtulh") horizontal_alignment = 0 [node name="Deaths" type="Label3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.218421, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0675129, 0) text = "Test" font = ExtResource("2_mtulh") horizontal_alignment = 0 [node name="Shots Fired" type="Label3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.285934, 0) text = "Test" font = ExtResource("2_mtulh") horizontal_alignment = 0 diff --git a/demo/src/Player.gd b/demo/src/Player_demo.gd similarity index 100% rename from demo/src/Player.gd rename to demo/src/Player_demo.gd diff --git a/gamemode.gd b/gamemode.gd index 9ce122c..77acbab 100644 --- a/gamemode.gd +++ b/gamemode.gd @@ -5,18 +5,22 @@ class_name gamemode @export_enum("Kill 'em All","Extraction","Survival_Time") var win_conditions @export_group("Win Conditions") @export var survival_time : float = 160 #in seconds +@export_group("Penalties") +@export var money_lost_multiplier : float = .5 +@export_enum("Drop All Weapons","Drop Random","Drop None") var weapon_penalty = 0 +@export var weapon_drop_percentage : float = .5 @export_group("Player Movement") @export var walk_speed = 12.0 @export var jump_velocity = 5 @export var dash_speed = 40 @export var gravity : float = -9.8 @export var time_slowed_speed : float = .1 -@export var stamina_regen = true +@export var stamina_regen = false @export var max_stamina : float = 100 @export var stamina_drain : float = 20 @export var air_dash_max : int = 1 @export var load_save : = true -@export var money = 0 +@export var money_multiplier : float = 1.0 @export var start_health = 10 @export var gun_1 : Resource @export var gun_2 : Resource diff --git a/project.godot b/project.godot index da21824..fe80607 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="First Person Test" -run/main_scene="res://scenes/enemy_working_scene.tscn" +run/main_scene="res://scenes/HUBWORLD.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" @@ -58,6 +58,7 @@ persist="" breakable="" leak="will leak if damaged" item_pickup="" +hub_level="" [input] diff --git a/scenes/HUBEFE.tmp b/scenes/HUBEFE.tmp new file mode 100644 index 0000000..390b2b0 --- /dev/null +++ b/scenes/HUBEFE.tmp @@ -0,0 +1,85 @@ +[gd_scene load_steps=11 format=3 uid="uid://jdwpc622vmok"] + +[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_1bnbi"] +[ext_resource type="Resource" uid="uid://bxcxqt7rmfvdw" path="res://GameModes/hubworld.tres" id="2_62iy8"] +[ext_resource type="Material" uid="uid://b6hhomp4kcjvb" path="res://assets/materials/prototype/tadaoando.tres" id="3_hlejc"] +[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="4_04o4y"] +[ext_resource type="PackedScene" uid="uid://dgapcuvg0gtmm" path="res://assets/scene_changer.tscn" id="5_alya6"] +[ext_resource type="PackedScene" uid="uid://bessq6hl7qsh8" path="res://assets/stats.tscn" id="6_mkn70"] +[ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="7_2h1ea"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_s7e4t"] +sky_top_color = Color(0.623488, 0.812575, 0.900791, 1) +sky_horizon_color = Color(0.705872, 0.745394, 0.758448, 1) +ground_bottom_color = Color(0.5, 0.5, 0.5, 1) +ground_horizon_color = Color(0.705872, 0.745394, 0.758448, 1) + +[sub_resource type="Sky" id="Sky_kdw67"] +sky_material = SubResource("ProceduralSkyMaterial_s7e4t") + +[sub_resource type="Environment" id="Environment_r2hg6"] +background_mode = 2 +sky = SubResource("Sky_kdw67") +tonemap_mode = 2 +glow_enabled = true +fog_enabled = true +fog_density = 0.0015 + +[node name="HUB" type="Node3D"] +script = ExtResource("1_1bnbi") +gamemode = ExtResource("2_62iy8") + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_r2hg6") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(-0.78152, -0.330606, 0.52908, 0, 0.848048, 0.529919, -0.62388, 0.414143, -0.662767, 0, 0, 0) +shadow_enabled = true + +[node name="CSGBox3D" type="CSGBox3D" parent="."] +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(20, 0.113, 20) + +[node name="CSGBox3D2" type="CSGBox3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 18.9745, -373.706, -11.5779) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 760.743, 6.07715) + +[node name="CSGBox3D3" type="CSGBox3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 18.9289, -377.958, -0.0683279) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 769.246, 6.07715) + +[node name="CSGBox3D4" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 7.88029, -381.918, -8.74134) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 756.867, 6.07715) + +[node name="CSGBox3D5" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 26.4634, -378.874, -5.57522) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 771.124, 6.07715) + +[node name="CSGBox3D6" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 19.5101, 7.06388, -5.64323) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(18.9743, 2.36012, 19.9824) + +[node name="Player" parent="." instance=ExtResource("4_04o4y")] +transform = Transform3D(1, 0.000164476, 0.000583754, -0.000165075, 0.999999, 0.00104027, -0.000583585, -0.00104036, 0.999999, 0.818877, 1.17009, 3.09268) + +[node name="Scene Changer" parent="." instance=ExtResource("5_alya6")] +transform = Transform3D(22.6681, 0, 0, 0, 3.41912, 0, 0, 0, 6.68795, 16.4442, -50.9202, -5.67549) +scene_path = "res://scenes/enemy_working_scene.tscn" + +[node name="Stats" parent="." instance=ExtResource("6_mkn70")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.212402, 1.9891, -6.02898) + +[node name="PostProcessing" parent="." instance=ExtResource("7_2h1ea")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.84741, 0.0564995, -2.31308) diff --git a/scenes/HUBWORLD.tscn b/scenes/HUBWORLD.tscn new file mode 100644 index 0000000..61b42d8 --- /dev/null +++ b/scenes/HUBWORLD.tscn @@ -0,0 +1,85 @@ +[gd_scene load_steps=11 format=3 uid="uid://jdwpc622vmok"] + +[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_1bnbi"] +[ext_resource type="Resource" uid="uid://bxcxqt7rmfvdw" path="res://GameModes/hubworld.tres" id="2_62iy8"] +[ext_resource type="Material" uid="uid://b6hhomp4kcjvb" path="res://assets/materials/prototype/tadaoando.tres" id="3_hlejc"] +[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="4_04o4y"] +[ext_resource type="PackedScene" uid="uid://dgapcuvg0gtmm" path="res://assets/scene_changer.tscn" id="5_alya6"] +[ext_resource type="PackedScene" uid="uid://bessq6hl7qsh8" path="res://assets/stats.tscn" id="6_mkn70"] +[ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="7_2h1ea"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_s7e4t"] +sky_top_color = Color(0.623488, 0.812575, 0.900791, 1) +sky_horizon_color = Color(0.705872, 0.745394, 0.758448, 1) +ground_bottom_color = Color(0.5, 0.5, 0.5, 1) +ground_horizon_color = Color(0.705872, 0.745394, 0.758448, 1) + +[sub_resource type="Sky" id="Sky_kdw67"] +sky_material = SubResource("ProceduralSkyMaterial_s7e4t") + +[sub_resource type="Environment" id="Environment_r2hg6"] +background_mode = 2 +sky = SubResource("Sky_kdw67") +tonemap_mode = 2 +glow_enabled = true +fog_enabled = true +fog_density = 0.0015 + +[node name="HUB_1" type="Node3D" groups=["hub_level"]] +script = ExtResource("1_1bnbi") +gamemode = ExtResource("2_62iy8") + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_r2hg6") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(-0.78152, -0.330606, 0.52908, 0, 0.848048, 0.529919, -0.62388, 0.414143, -0.662767, 0, 0, 0) +shadow_enabled = true + +[node name="CSGBox3D" type="CSGBox3D" parent="."] +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(20, 0.113, 20) + +[node name="CSGBox3D2" type="CSGBox3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 18.9745, -373.706, -11.5779) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 760.743, 6.07715) + +[node name="CSGBox3D3" type="CSGBox3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 18.9289, -377.958, -0.0683279) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 769.246, 6.07715) + +[node name="CSGBox3D4" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 7.88029, -381.918, -8.74134) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 756.867, 6.07715) + +[node name="CSGBox3D5" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 26.4634, -378.874, -5.57522) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(21.6041, 771.124, 6.07715) + +[node name="CSGBox3D6" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 19.5101, 7.06388, -5.64323) +material_override = ExtResource("3_hlejc") +use_collision = true +size = Vector3(18.9743, 2.36012, 19.9824) + +[node name="Player" parent="." instance=ExtResource("4_04o4y")] +transform = Transform3D(1, 0.000164476, 0.000583754, -0.000165075, 0.999999, 0.00104027, -0.000583585, -0.00104036, 0.999999, 0.818877, 1.17009, 3.09268) + +[node name="Scene Changer" parent="." instance=ExtResource("5_alya6")] +transform = Transform3D(22.6681, 0, 0, 0, 3.41912, 0, 0, 0, 6.68795, 16.4442, -57.3609, -5.67549) +scene_path = "res://scenes/enemy_working_scene.tscn" + +[node name="Stats" parent="." instance=ExtResource("6_mkn70")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.212402, 1.9891, -6.02898) + +[node name="PostProcessing" parent="." instance=ExtResource("7_2h1ea")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.84741, 0.0564995, -2.31308) diff --git a/scenes/enemy_working_scene.tscn b/scenes/enemy_working_scene.tscn index 84e0b8b..fb7d278 100644 --- a/scenes/enemy_working_scene.tscn +++ b/scenes/enemy_working_scene.tscn @@ -1,7 +1,7 @@ -[gd_scene load_steps=24 format=3 uid="uid://dsnddbrlqkav2"] +[gd_scene load_steps=28 format=3 uid="uid://dsnddbrlqkav2"] [ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_laua1"] -[ext_resource type="Resource" uid="uid://65tl6q463gxl" path="res://GameModes/nostaminaregen.tres" id="2_xwjny"] +[ext_resource type="Resource" uid="uid://dn3t7wcoumlm3" path="res://GameModes/standard.tres" id="2_2umal"] [ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="4_a8lcp"] [ext_resource type="Script" path="res://scripts/room_manager.gd" id="5_ngmqi"] [ext_resource type="PackedScene" uid="uid://djr7vnr1hcx82" path="res://assets/spider2.tscn" id="6_qmuhr"] @@ -18,6 +18,9 @@ [ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="17_8q5j4"] [ext_resource type="PackedScene" uid="uid://bessq6hl7qsh8" path="res://assets/stats.tscn" id="18_e13cr"] [ext_resource type="PackedScene" uid="uid://hp4xn8oqdxnd" path="res://assets/machete_pickup.tscn" id="18_jev3u"] +[ext_resource type="Material" uid="uid://b6hhomp4kcjvb" path="res://assets/materials/prototype/tadaoando.tres" id="19_e7xg4"] +[ext_resource type="PackedScene" uid="uid://dgapcuvg0gtmm" path="res://assets/scene_changer.tscn" id="20_j4ook"] +[ext_resource type="Script" path="res://scripts/level_bounds.gd" id="21_uhac2"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_w6vpl"] sky_top_color = Color(0.623488, 0.812575, 0.900791, 1) @@ -25,16 +28,16 @@ sky_horizon_color = Color(0.705872, 0.745394, 0.758448, 1) ground_bottom_color = Color(0.5, 0.5, 0.5, 1) ground_horizon_color = Color(0.705872, 0.745394, 0.758448, 1) -[sub_resource type="Sky" id="Sky_kdw67"] +[sub_resource type="Sky" id="Sky_6g0ku"] sky_material = SubResource("ProceduralSkyMaterial_w6vpl") [sub_resource type="Environment" id="Environment_klp4b"] background_mode = 2 -sky = SubResource("Sky_kdw67") +sky = SubResource("Sky_6g0ku") tonemap_mode = 2 glow_enabled = true fog_enabled = true -fog_density = 0.002 +fog_density = 0.001 [sub_resource type="NavigationMesh" id="NavigationMesh_8aw3d"] vertices = PackedVector3Array(-24.6969, -4.637, -268.188, -24.6969, -4.637, -219.188, 24.5531, -4.637, -219.188, 24.5531, -4.637, -268.188, -24.6969, -30.137, -227.688, -24.6969, -30.137, -178.438, 24.5531, -30.137, -178.438, 24.5531, -30.137, -227.688, -24.6969, -71.387, -164.688, -24.6969, -71.387, -115.438, 24.5531, -71.387, -115.438, 24.5531, -71.387, -164.688, -24.6969, -71.387, -96.188, -24.6969, -71.387, -46.938, 24.5531, -71.387, -46.938, 24.5531, -71.387, -96.188, -13.1969, 0.112999, -35.938, -12.1969, 0.112999, -36.438, -12.1969, 0.112999, -41.688, -13.4469, 0.112999, -34.688, -19.4469, 0.112999, -28.188, -18.4469, 0.112999, -28.438, -37.1969, 0.112999, -41.688, -37.1969, 0.112999, -28.188, -10.9469, 0.112999, -35.938, 7.05309, 0.112999, -32.688, 8.30309, 0.112999, -33.688, 8.30309, 0.112999, -41.688, -3.19691, 0.112999, -29.438, 7.80309, 0.112999, -30.938, 7.05309, 0.112999, -31.688, 36.3031, 0.112999, -25.188, 36.5531, 0.112999, -24.188, 37.0531, 0.112999, -24.188, 37.0531, 0.112999, -41.688, 19.3031, 0.112999, -25.188, -10.9469, 0.112999, -23.188, -6.69691, 0.112999, -28.688, -6.69691, 0.112999, -29.438, -11.6969, 0.112999, -22.938, -7.44691, 4.863, -28.188, -6.69691, 4.863, -28.688, -6.94691, 4.863, -29.688, -10.1969, 4.863, -24.438, -8.69691, 4.863, -23.938, -7.69691, 4.863, -25.188, -6.94691, 4.863, -26.188, -17.4469, 4.863, -27.438, -11.1969, 4.863, -22.938, -12.9469, 4.863, -34.188, -17.6969, 4.863, -28.188, -11.4469, 9.863, -23.188, -6.94691, 9.863, -28.938, -6.94691, 9.863, -29.688, -12.9469, 9.863, -34.188, -17.6969, 9.863, -28.188, -17.4469, 9.863, -27.438, -3.19691, 0.112999, -28.688, -4.94691, 0.112999, -27.438, -9.94691, 0.112999, -20.688, -8.19691, 0.112999, -17.438, 2.30309, 0.112999, -17.438, 2.55309, 0.112999, -16.938, 12.5531, 0.112999, -27.438, -6.69691, 11.113, -27.938, -6.69691, 11.113, -27.438, -5.94691, 11.113, -27.438, -5.94691, 11.113, -27.938, -4.44691, 11.363, -29.438, -6.19691, 11.363, -30.438, -5.69691, 11.113, -28.938, -4.44691, 11.363, -28.938, -28.9469, 0.112999, -14.188, -28.4469, 0.112999, -10.188, -28.4469, 0.112999, -16.188, -37.1969, 0.112999, -14.188, -26.1969, 0.112999, -16.188, -18.9469, 0.112999, -25.688, -19.9469, 0.112999, -26.438, -19.9469, 0.112999, -27.688, 28.3031, 0.112999, -22.938, 22.0531, 0.112999, -22.938, 22.0531, 0.112999, -22.188, 26.8031, 0.112999, -16.438, 28.5531, 0.112999, -16.688, 21.3031, 0.112999, -21.438, 20.0531, 0.112999, -21.438, 26.8031, 0.112999, -8.68799, 2.55309, 0.112999, -8.93799, -7.69691, 11.113, -26.688, -7.69691, 11.113, -26.188, -7.19691, 11.113, -26.438, -7.19691, 11.113, -26.938, -8.44691, 11.113, -25.688, -8.44691, 11.113, -25.188, -7.94691, 11.113, -25.438, -7.94691, 11.113, -25.938, -10.4469, 0.112999, -19.938, -8.69691, 0.112999, -17.188, -8.69691, 0.112999, -8.68799, -11.6969, 0.112999, -19.938, -26.4469, 0.112999, -8.43799, -9.44691, 11.113, -24.438, -9.44691, 11.113, -23.938, -8.94691, 11.113, -24.188, -8.94691, 11.113, -24.688, 18.8031, 5.613, -24.188, 20.5531, 5.613, -22.438, 20.8031, 5.613, -23.938, 35.5531, 5.613, -23.938, 36.3031, 0.112999, -22.938, 37.0531, 0.112999, -16.688, -11.1969, 11.363, -21.938, -12.1969, 11.363, -21.938, -10.9469, 11.363, -20.938, -10.4469, 11.113, -22.188, -9.44691, 11.113, -22.938, -9.69691, 11.113, -23.938, -43.1969, 50.863, -17.188, -43.1969, 50.863, -8.68799, -33.9469, 50.863, -8.68799, -33.9469, 50.863, -17.188, -7.69691, 20.613, -16.438, -7.69691, 20.613, -7.93799, 1.55309, 20.613, -7.93799, 1.55309, 20.613, -16.438, -7.44691, 0.112999, -16.188, -7.44691, 0.112999, -8.18799, 1.30309, 0.112999, -8.18799, 1.30309, 0.112999, -16.188, 27.8031, 20.613, -15.688, 27.8031, 20.613, -7.43799, 37.0531, 20.613, -7.43799, 37.0531, 20.613, -15.688, 28.0531, 0.112999, -15.438, 28.0531, 0.112999, -7.68799, 36.8031, 0.112999, -7.68799, 36.8031, 0.112999, -15.438, -38.9469, 20.613, -13.188, -38.9469, 20.613, -8.93799, -34.1969, 20.613, -8.93799, -34.1969, 20.613, -13.188, -33.1969, 20.613, -7.68799, -38.9469, 20.613, -7.68799, -38.9469, 20.613, -4.68799, -29.6969, 20.613, -4.68799, -29.6969, 20.613, -13.188, -32.9469, 20.613, -13.188, -37.1969, 0.112999, -12.938, -37.1969, 0.112999, -4.93799, -29.9469, 0.112999, -4.93799, -29.9469, 0.112999, -12.938, -30.6969, 16.613, -11.188, -30.6969, 16.613, -10.188, -29.9469, 16.613, -10.188, -29.9469, 16.613, -11.188, -28.6969, 16.613, -11.188, -28.6969, 16.613, -10.188, -8.69691, 16.613, -10.188, -8.69691, 16.613, -11.188, -7.44691, 16.613, -11.188, -7.44691, 16.613, -10.188, 1.30309, 16.613, -10.188, 1.30309, 16.613, -11.188, 2.55309, 16.613, -11.188, 2.55309, 16.613, -10.188, 26.8031, 16.613, -10.188, 26.8031, 16.613, -11.188, 28.0531, 16.613, -11.188, 28.0531, 16.613, -10.188, 29.5531, 16.613, -10.188, 29.5531, 16.613, -11.188, -35.9469, 48.363, -9.68799, -35.9469, 48.363, -8.93799, -34.1969, 48.363, -8.93799, -34.1969, 48.363, -9.68799, -21.9469, 48.363, -9.68799, -32.9469, 48.363, -9.68799, -33.1969, 48.363, -7.68799, -23.9469, 48.363, 34.062, -21.9469, 48.363, 34.062, -35.9469, 48.363, 35.562, -24.1969, 48.363, 35.812, -35.9469, 48.363, -7.68799, -37.6969, 37.613, -9.43799, -37.6969, 37.613, -8.93799, -36.9469, 37.613, -8.93799, -36.9469, 37.613, -9.43799, 2.55309, 0.112999, -7.18799, 2.05309, 0.112999, -6.93799, 2.80309, 0.112999, -5.68799, 27.0531, 0.112999, -6.43799, 28.0531, 0.112999, -0.937988, 30.0531, 0.112999, -0.937988, 30.0531, 0.112999, -6.43799, 27.8031, 0.112999, -0.437988, -29.6969, 0.112999, 26.062, -18.6969, 0.112999, 26.062, -18.4469, 0.112999, 25.312, -29.6969, 0.112999, 17.062, -27.1969, 0.112999, 4.81201, -28.6969, 0.112999, 4.56201, -26.6969, 0.112999, 3.56201, -8.19691, 0.112999, 25.312, -7.94691, 0.112999, -6.93799, -8.69691, 0.112999, -7.18799, -37.6969, 37.613, -7.68799, -37.6969, 37.613, 19.562, -36.9469, 37.613, 19.562, -36.9469, 37.613, -7.68799, -7.44691, 0.112999, 30.562, 0.0530853, 0.112999, 30.562, 0.303085, 0.112999, 28.312, -7.44691, 0.112999, 25.562, 2.80309, 0.112999, 28.312, 37.0531, 0.112999, -0.937988, 37.0531, 0.112999, -6.43799, 27.8031, 0.112999, 9.06201, 10.8031, 0.112999, 28.312, -29.1969, 0.112999, 4.06201, -28.9469, 0.112999, -3.68799, -37.1969, 0.112999, -3.68799, -37.1969, 0.112999, 4.06201, 28.8031, 20.613, 0.0620117, 28.8031, 20.613, 8.56201, 38.0531, 20.613, 8.56201, 38.0531, 20.613, 0.0620117, 29.0531, 0.112999, 0.312012, 29.0531, 0.112999, 8.31201, 37.0531, 0.112999, 8.31201, 37.0531, 0.112999, 0.312012, -37.1969, 0.112999, 16.562, -29.9469, 0.112999, 16.562, 28.0531, 0.112999, 9.56201, 11.3031, 0.112999, 28.562, 11.3031, 0.112999, 37.062, 37.0531, 0.112999, 37.062, 37.0531, 0.112999, 9.56201, -41.1969, 12.363, 16.812, -39.4469, 12.363, 16.562, -43.4469, 12.363, 14.562, -43.9469, 12.363, 15.312, -33.1969, 20.613, 19.562, -32.9469, 20.613, 26.062, -30.6969, 20.613, 26.062, -30.6969, 20.613, 17.562, -39.9469, 20.613, 17.562, -39.9469, 20.613, 19.562, -32.6969, 12.363, 20.562, -30.9469, 12.363, 21.062, -30.9469, 12.363, 20.062, -33.1969, 12.363, 19.562, -36.1969, 12.363, 17.812, -38.1969, 12.363, 17.812, -34.9469, 12.363, 19.562, -37.1969, 0.112999, 17.812, -37.1969, 0.112999, 19.562, -32.9469, 0.112999, 19.812, -30.9469, 0.112999, 17.812, -32.9469, 0.112999, 25.812, -30.9469, 0.112999, 25.812, -43.1969, 43.613, 20.562, -43.1969, 43.613, 29.062, -33.9469, 43.613, 29.062, -33.9469, 43.613, 20.562, -39.9469, 20.613, 20.812, -39.9469, 20.613, 26.062, -34.1969, 20.613, 26.062, -34.1969, 20.613, 20.812, -37.6969, 37.613, 20.812, -37.6969, 37.613, 28.812, -36.9469, 37.613, 28.812, -36.9469, 37.613, 20.812, -37.1969, 0.112999, 20.812, -37.1969, 0.112999, 25.812, -34.1969, 0.112999, 25.812, -34.1969, 0.112999, 20.812, -29.6969, 12.363, 21.812, -18.6969, 12.363, 26.562, -18.6969, 12.363, 25.562, -29.6969, 12.363, 20.812, -16.4469, 0.112999, 37.062, -16.4469, 0.112999, 35.562, -18.6969, 0.112999, 35.312, -29.9469, 0.112999, 27.062, -32.9469, 0.112999, 27.062, -33.1969, 0.112999, 30.062, -37.1969, 0.112999, 30.062, -37.1969, 0.112999, 37.062, -17.6969, 20.613, 34.562, -16.1969, 20.613, 34.562, -15.9469, 20.613, 27.812, -17.6969, 20.613, 26.312, -8.44691, 20.613, 27.812, -8.44691, 20.613, 26.312, -17.4469, 0.112999, 26.562, -17.4469, 0.112999, 34.312, -8.69691, 0.112999, 34.312, -8.69691, 0.112999, 26.562, -16.1969, 12.363, 27.812, -14.1969, 12.363, 27.812, -15.6969, 12.363, 26.812, -17.4469, 12.363, 26.562, -17.4469, 12.363, 27.312, -37.1969, 0.112999, 27.062, -37.1969, 0.112999, 28.812, -34.1969, 0.112999, 28.812, -34.1969, 0.112999, 27.062, -15.1969, 50.863, 37.312, -13.1969, 50.863, 37.312, -12.9469, 50.863, 31.312, -15.1969, 50.863, 28.812, -5.94691, 50.863, 31.312, -5.94691, 50.863, 28.812, -14.9469, 20.613, 34.562, -13.1969, 20.613, 34.562, -12.9469, 20.613, 31.312, -14.9469, 20.613, 29.062, -8.44691, 20.613, 31.312, -8.44691, 20.613, 29.062, -8.69691, 12.363, 31.062, -8.69691, 12.363, 30.062, -9.44691, 12.363, 29.562, -12.9469, 12.363, 29.062, 1.05309, 20.613, 29.312, 1.05309, 20.613, 31.312, 10.3031, 20.613, 31.312, 10.3031, 20.613, 29.312, 1.30309, 0.112999, 29.562, 1.30309, 0.112999, 37.062, 10.0531, 0.112999, 37.062, 10.0531, 0.112999, 29.562, -7.69691, 0.112999, 35.562, 0.0530853, 0.112999, 37.062, -7.44691, 12.363, 30.562, -7.44691, 12.363, 31.312, -6.19691, 12.363, 31.312, -12.1969, 72.613, 32.312, -12.1969, 72.613, 40.812, 16.8031, 72.613, 40.812, 16.8031, 72.613, 32.312, -11.9469, 20.613, 32.562, -11.9469, 20.613, 34.562, -8.44691, 20.613, 34.562, -8.44691, 20.613, 32.562, -11.9469, 50.863, 32.562, -11.9469, 50.863, 37.312, -5.94691, 50.863, 37.312, -5.94691, 50.863, 32.562, 0.0530853, 12.363, 34.812, 0.0530853, 12.363, 33.812, -0.446915, 12.363, 33.562, -2.69691, 12.363, 32.562, -4.94691, 12.363, 32.562, 1.05309, 20.613, 32.562, 1.05309, 20.613, 37.812, 10.3031, 20.613, 37.812, 10.3031, 20.613, 32.562, 1.30309, 12.363, 34.562, 1.30309, 12.363, 35.562, 2.30309, 12.363, 36.062, 5.80309, 12.363, 37.562, 8.05309, 12.363, 37.562, -10.9469, 49.613, 43.312, -10.9469, 49.613, 41.812, -13.1969, 49.613, 41.562, -23.1969, 49.613, 43.312, -13.1969, 49.613, 38.312, -16.1969, 49.613, 38.062, -16.1969, 49.613, 35.062, -23.1969, 49.613, 35.062, -5.19691, 49.613, 38.312, -11.9469, 49.613, 38.312, -11.9469, 49.613, 40.562, 16.5531, 49.613, 40.562, 16.5531, 49.613, 35.062, -4.94691, 49.613, 35.062, 20.0531, 49.613, 35.062, 17.8031, 49.613, 35.062, 17.5531, 49.613, 41.812, 20.0531, 49.613, 43.312, -35.9469, 48.363, 43.312, -24.1969, 48.363, 43.312, 9.05309, 12.363, 38.812, 11.3031, 12.363, 39.812, 11.3031, 12.363, 38.812) @@ -43,9 +46,13 @@ polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1), PackedInt32Arr [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6yrih"] albedo_color = Color(0.300579, 0.462784, 0.249767, 1) +[sub_resource type="BoxShape3D" id="BoxShape3D_5m8am"] +size = Vector3(526.157, 900.916, 500) + [node name="EnemyWork" type="Node3D" node_paths=PackedStringArray("player")] script = ExtResource("1_laua1") -gamemode = ExtResource("2_xwjny") +map_name = "Wall Runnin" +gamemode = ExtResource("2_2umal") player = NodePath("Player") MAX_PARTICLES = 75 expected_ammo = { @@ -57,7 +64,7 @@ expected_ammo = { } [node name="Player" parent="." instance=ExtResource("4_a8lcp")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 26.4194, 1.40016, -29.1943) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 26.4194, 277.483, -34.6215) [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_klp4b") @@ -421,3 +428,52 @@ transform = Transform3D(-0.98212, 0, 0.188255, 0, 1, 0, -0.188255, 0, -0.98212, [node name="machete_pickup" parent="." instance=ExtResource("18_jev3u")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 19.5087, 0.327792, -29.9239) + +[node name="CSGBox3D2" type="CSGBox3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 28.2103, 410.907, -39.074) +material_override = ExtResource("19_e7xg4") +use_collision = true +size = Vector3(21.6041, 760.743, 6.07715) + +[node name="CSGBox3D3" type="CSGBox3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 28.1646, 406.656, -27.5644) +material_override = ExtResource("19_e7xg4") +use_collision = true +size = Vector3(21.6041, 769.246, 6.07715) + +[node name="CSGBox3D4" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 17.116, 402.696, -36.2374) +material_override = ExtResource("19_e7xg4") +use_collision = true +size = Vector3(21.6041, 756.867, 6.07715) + +[node name="CSGBox3D5" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 35.6991, 405.739, -33.0713) +material_override = ExtResource("19_e7xg4") +use_collision = true +size = Vector3(21.6041, 771.124, 6.07715) + +[node name="CSGBox3D6" type="CSGBox3D" parent="."] +transform = Transform3D(0.00661471, 0, -0.999978, 0, 1, 0, 0.999978, 0, 0.00661471, 28.7459, 791.677, -33.1393) +material_override = ExtResource("19_e7xg4") +use_collision = true +size = Vector3(18.9743, 2.36012, 19.9824) + +[node name="JumpPlatform3" parent="." instance=ExtResource("17_8q5j4")] +transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 27.2325, -0.170555, -32.4933) +jump_amount = 100 + +[node name="Scene Changer" parent="." instance=ExtResource("20_j4ook")] +transform = Transform3D(15.1486, 0, 0, 0, 405.877, 0, 0, 0, 9.59561, 29.1358, 544.113, -33.0379) +scene_path = "res://scenes/HUBWORLD.tscn" + +[node name="BOUNDS" type="Area3D" parent="."] +collision_layer = 2 +collision_mask = 2 +script = ExtResource("21_uhac2") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="BOUNDS"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 13.0786, 347.404, -39.4503) +shape = SubResource("BoxShape3D_5m8am") + +[connection signal="body_exited" from="BOUNDS" to="BOUNDS" method="_on_body_exited"] diff --git a/scripts/LevelManager.gd b/scripts/LevelManager.gd index b4311ca..3272030 100644 --- a/scripts/LevelManager.gd +++ b/scripts/LevelManager.gd @@ -1,5 +1,7 @@ extends Node3D +class_name map +@export var map_name : String = "Map Name" @export var gamemode : gamemode @export var player : Node @export var MAX_PARTICLES = 100 @@ -13,20 +15,14 @@ extends Node3D @onready var item_pickup = preload("res://assets/item_pickup.tscn") @onready var crown = preload("res://assets/crown.tscn") var dead_player = preload("res://assets/dead_cam.tscn") -const CLEARED_ANNOUNCE = preload("res://assets/cleared_announce.tscn") const DEAD_ANNOUNCE = preload("res://assets/dead_announce.tscn") var level_name var paused = false -var health -var money var pickups = [] -var held_guns = [] -var ammo_current = [0] -var ammo_reserve = [0] + var keys = [] var guns_dict = {} -var current_gun_index var particle_number = 0 var enemy_hiveminds = [] var remaining_enemies @@ -40,13 +36,10 @@ var engine_time_scale_cache : float = 1.0 # Called when the node enters the scene tree for the first time. func _ready(): level_name = self.get_name() - print("LEVEL NAME ",level_name) #connect to signals SignalBus.enemy_count_changed.connect(enemy_count) - health = gamemode.start_health - money = gamemode.money - + GameGlobals.health = gamemode.start_health #LOAD DATA SaveLoad.load_persistent_data() @@ -83,7 +76,7 @@ func _ready(): enemy_count() func refresh_scene(): - health = gamemode.start_health + GameGlobals.health = gamemode.start_health respawn_position = player.camera.global_position respawn_cam_rotation = player.global_transform.basis @@ -91,18 +84,18 @@ func refresh_scene(): if player: #Set up starting guns and ammo if gamemode.gun_1 != null: - held_guns = [gamemode.gun_1] - var instance_gun = held_guns[0].instantiate() + GameGlobals.held_guns = [gamemode.gun_1] + var instance_gun = GameGlobals.held_guns[0].instantiate() player.add_ammo(true,instance_gun.gun_name,instance_gun.ammo_type,instance_gun.max_ammo,instance_gun.start_mags) if gamemode.gun_2 != null: - held_guns.append(gamemode.gun_2) - var instance_gun_2 = held_guns[1].instantiate() + GameGlobals.held_guns.append(gamemode.gun_2) + var instance_gun_2 = GameGlobals.held_guns[1].instantiate() player.add_ammo(true,instance_gun_2.gun_name,instance_gun_2.ammo_type,instance_gun_2.max_ammo,instance_gun_2.start_mags) # Spawn first gun if gamemode.gun_1 != null: - current_gun_index = 0 + GameGlobals.current_gun_index = 0 gun_spawn(0) @@ -114,15 +107,15 @@ func _process(_delta): func gun_spawn(index): #loop around if scrolling past available guns - if index > held_guns.size() - 1: + if index > GameGlobals.held_guns.size() - 1: index = 0 elif index < 0: - index = held_guns.size() - 1 + index = GameGlobals.held_guns.size() - 1 - current_gun_index = index + GameGlobals.current_gun_index = index - if held_guns != []: - var instance_gun = held_guns[index].instantiate() + if GameGlobals.held_guns != []: + var instance_gun = GameGlobals.held_guns[index].instantiate() instance_gun.global_transform.origin = player.weapon_spawner.position player.gun = instance_gun player.def_weapon_holder_pos = player.weapon_holder.position @@ -142,13 +135,12 @@ func enemy_count(): cleared() func cleared(): - var clearedmsg = CLEARED_ANNOUNCE.instantiate() - get_parent().add_child(clearedmsg) - await get_tree().create_timer(1).timeout - clearedmsg.queue_free() + pass func die(): #record stats + GameGlobals.money_penalty() + GameGlobals.weapon_penalty() if SaveLoad.player_deaths: SaveLoad.player_deaths += 1 else: @@ -184,14 +176,14 @@ func pickup_spawn(randomized): pickup_type = randi_range(0,3) #if item type is ammo, pick random ammo if pickup_type == 0: - var player_ammo = player.ammo_reserve.keys() + var player_ammo = GameGlobals.ammo_reserve.keys() ammo_type = int(player_ammo.pick_random()) #random value of pickup value = randi_range(1,50) else: var health_weight if gamemode.health_drop_enabled: - health_weight = (1.0 - (health / gamemode.start_health)) + drop_chance_minimum + health_weight = (1.0 - (GameGlobals.health / gamemode.start_health)) + drop_chance_minimum else: health_weight = 0 var stamina_weight @@ -201,7 +193,7 @@ func pickup_spawn(randomized): stamina_weight = 0 var money_weight if money_drop_enabled: - money_weight = (1.0 - clamp(float(money) / float(500),0,1)) + drop_chance_minimum #fix this logic later once the economy makes sense + money_weight = (1.0 - clamp(float(GameGlobals.money) / float(500),0,1)) + drop_chance_minimum #fix this logic later once the economy makes sense else: money_weight = 0 var ammo_weight @@ -212,19 +204,19 @@ func pickup_spawn(randomized): # weight ammo player owns against expected ammo values if ammo_drop_enabled: - for i in player.ammo_reserve.keys(): + for i in GameGlobals.ammo_reserve.keys(): var i_weight match int(i): 0: - i_weight = 1.0 - clamp(float(player.ammo_reserve[str(i)]) / float(expected_ammo["light"]),0,1) + i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["light"]),0,1) 1: - i_weight = 1.0 - clamp(float(player.ammo_reserve[str(i)]) / float(expected_ammo["medium"]),0,1) + i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["medium"]),0,1) 2: - i_weight = 1.0 - clamp(float(player.ammo_reserve[str(i)]) / float(expected_ammo["heavy"]),0,1) + i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["heavy"]),0,1) 3: - i_weight = 1.0 - clamp(float(player.ammo_reserve[str(i)]) / float(expected_ammo["shotgun"]),0,1) + i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["shotgun"]),0,1) 4: - i_weight = 1.0 - clamp(float(player.ammo_reserve[str(i)]) / float(expected_ammo["rocket"]),0,1) + i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["rocket"]),0,1) 5: i_weight = 0 if i_weight > ammo_weight: diff --git a/scripts/game_globals.gd b/scripts/game_globals.gd index adcb186..d2c7701 100644 --- a/scripts/game_globals.gd +++ b/scripts/game_globals.gd @@ -1,3 +1,40 @@ extends Node var game_loaded = false +var high_score = 0 +var money = 0 +var health +var held_guns = [] +var current_gun_index +var gun_ammo = {} +var ammo_reserve = {} + +func _ready() -> void: + SignalBus.money_changed.connect(money_update) + +func money_update(): + if money > high_score: + high_score = money + +func money_penalty(): + var level_control = get_tree().current_scene + + #Save High Scores + if money >= high_score: + high_score = money + + #Do money penalty + money = money * level_control.gamemode.money_lost_multiplier + +func weapon_penalty(): + var level_control = get_tree().current_scene + + match level_control.gamemode.weapon_penalty: + 0: #Drop All + GameGlobals.held_guns = [] + 1: #Drop Percentage + var weapons_lost = GameGlobals.held_guns.size() * level_control.gamemode.weapon_drop_percentage + for weapon in weapons_lost: + GameGlobals.held_guns.erase(GameGlobals.held_guns.pick_random()) + 2: #Do Nothing + pass diff --git a/scripts/gun.gd b/scripts/gun.gd index 0cc51d7..5b2cd40 100644 --- a/scripts/gun.gd +++ b/scripts/gun.gd @@ -75,17 +75,17 @@ func _process(_delta): func reload_finished(): - if player.ammo_reserve[str(ammo_type)] >= max_ammo: - player.gun_ammo[gun_name] += max_ammo - player.ammo_reserve[str(ammo_type)] -= max_ammo + if GameGlobals.ammo_reserve[str(ammo_type)] >= max_ammo: + GameGlobals.gun_ammo[gun_name] += max_ammo + GameGlobals.ammo_reserve[str(ammo_type)] -= max_ammo else: - player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)] - player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)] + GameGlobals.gun_ammo[gun_name] += GameGlobals.ammo_reserve[str(ammo_type)] + GameGlobals.ammo_reserve[str(ammo_type)] -= GameGlobals.ammo_reserve[str(ammo_type)] func shoot(delta): - if player.gun_ammo[gun_name] > 0 and cycle_count > 0: + if GameGlobals.gun_ammo[gun_name] > 0 and cycle_count > 0: if !anim_player.is_playing(): - player.gun_ammo[gun_name] -= 1 + GameGlobals.gun_ammo[gun_name] -= 1 #audio and anims audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt) audio_fire.play() @@ -108,15 +108,15 @@ func shoot(delta): audio_empty.play() func reload(): - if player.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and player.ammo_reserve[str(ammo_type)] > 0: + if GameGlobals.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and GameGlobals.ammo_reserve[str(ammo_type)] > 0: #player.reloading = true anim_player.play("reload") audio_reload.play() if anim_player.is_playing() and anim_player.current_animation == "reload": - if player.gun_ammo[gun_name] == 0: - player.gun_ammo[gun_name] = 0 + if GameGlobals.gun_ammo[gun_name] == 0: + GameGlobals.gun_ammo[gun_name] = 0 else: - player.gun_ammo[gun_name] = 1 + GameGlobals.gun_ammo[gun_name] = 1 func spawn_mag(): var instance_mag = mag.instantiate() diff --git a/scripts/hud.gd b/scripts/hud.gd index 1df8a4f..2063240 100644 --- a/scripts/hud.gd +++ b/scripts/hud.gd @@ -84,20 +84,20 @@ func _process(delta: float) -> void: gun_info.visible = true #HEALTH - health_bar.value = level_control.health - if level_control.health <= 2: + health_bar.value = GameGlobals.health + if GameGlobals.health <= 2: change_color(health_bar,RED_COLOR,10,delta) health_bar.position = health_bar_start_pos + shake_element(15) - elif level_control.health < ((level_control.gamemode.start_health / 2) + 1): + elif GameGlobals.health < ((level_control.gamemode.start_health / 2) + 1): change_color(health_bar,ORANGE_COLOR,10,delta) else: change_color(health_bar,FULL_WHITE,10,delta) #MONEY - if money_count < level_control.money: + if money_count < int(GameGlobals.money): money_count += 1 change_color(money,GREEN_COLOR,10,delta) - elif money_count > level_control.money: + elif money_count > int(GameGlobals.money): change_color(money,RED_COLOR,10,delta) money_count -= 1 else: @@ -111,12 +111,12 @@ func _process(delta: float) -> void: current_stam_bar.value = player.remaining_stamina if player.gun != null: - if player.gun_ammo.has(player.gun.gun_name): - ammo_current.text = str(player.gun_ammo[player.gun.gun_name]).pad_zeros(2) - lerp_color(ammo_current,RED_COLOR,FULL_WHITE,player.gun_ammo[player.gun.gun_name],player.gun.max_ammo,.5) - if player.ammo_reserve.has(str(player.gun.ammo_type)): - ammo_reserve.text = str(player.ammo_reserve[str(player.gun.ammo_type)]).pad_zeros(3) - lerp_color(ammo_reserve,RED_COLOR,FULL_WHITE,player.ammo_reserve[str(player.gun.ammo_type)],player.gun.max_ammo*2,.5) + if GameGlobals.gun_ammo.has(player.gun.gun_name): + ammo_current.text = str(GameGlobals.gun_ammo[player.gun.gun_name]).pad_zeros(2) + lerp_color(ammo_current,RED_COLOR,FULL_WHITE,GameGlobals.gun_ammo[player.gun.gun_name],player.gun.max_ammo,.5) + if GameGlobals.ammo_reserve.has(str(player.gun.ammo_type)): + ammo_reserve.text = str(GameGlobals.ammo_reserve[str(player.gun.ammo_type)]).pad_zeros(3) + lerp_color(ammo_reserve,RED_COLOR,FULL_WHITE,GameGlobals.ammo_reserve[str(player.gun.ammo_type)],player.gun.max_ammo*2,.5) else: fade_in_out(ammo_current,1,false,10,delta) fade_in_out(ammo_reserve,1,false,10,delta) diff --git a/scripts/item_pickup_v2.gd b/scripts/item_pickup_v2.gd index 8727a04..925c6b9 100644 --- a/scripts/item_pickup_v2.gd +++ b/scripts/item_pickup_v2.gd @@ -24,7 +24,7 @@ var ammo_type @onready var money: Node3D = $Meshes/money -var magnetable = false +var magnetable = true var pickupable = false var pick_up = false var rand_amt diff --git a/scripts/level_bounds.gd b/scripts/level_bounds.gd index abb96d4..e743d27 100644 --- a/scripts/level_bounds.gd +++ b/scripts/level_bounds.gd @@ -1,21 +1,13 @@ extends Area3D -@onready var level_control = get_tree().current_scene +var player_exit = false -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. +func _ready() -> void: + SignalBus.player_exiting_tree.connect(player_exit_check) +func player_exit_check(): + player_exit = true -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - - -func _on_area_exited(area): - pass #level_control.die() - - - -func _on_body_shape_exited(body_rid, body, body_shape_index, local_shape_index): - level_control.die() +func _on_body_exited(body: Node3D) -> void: + if !player_exit: + get_tree().current_scene.die() diff --git a/scripts/level_sign.gd b/scripts/level_sign.gd new file mode 100644 index 0000000..d4554c9 --- /dev/null +++ b/scripts/level_sign.gd @@ -0,0 +1,11 @@ +extends Node3D + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/scripts/player.gd b/scripts/player.gd index 051c59c..ff248f8 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -73,8 +73,6 @@ var instance_bullet var instance_casing var instance_mag var reloading = false -var gun_ammo = {} -var ammo_reserve = {} var bullet_damage var def_weapon_holder_pos : Vector3 var weapon_holder_start_rot @@ -314,8 +312,8 @@ func _physics_process(delta): camera.fov = lerp(camera.fov, target_fov, delta * 8) # Health Indicator - var health_opacity = 1.5 - level_control.health / level_control.gamemode.start_health - if level_control.health < (level_control.gamemode.start_health/2): + var health_opacity = 1.5 - GameGlobals.health / level_control.gamemode.start_health + if GameGlobals.health < (level_control.gamemode.start_health/2): health_indicator.color = lerp(Color(0.471, 0, 0, 0), Color(0.471, 0, 0, .25),health_opacity) else: health_indicator.color = Color(0.471, 0, 0, 0) @@ -414,8 +412,8 @@ func _physics_process(delta): if gun != null: if !gun.anim_player.is_playing(): if held_item == null: - if level_control.held_guns.size() > 1: - weapon_select(level_control.current_gun_index + 1) + if GameGlobals.held_guns.size() > 1: + weapon_select(GameGlobals.current_gun_index + 1) else: moveable_holder.rotation.y += deg_to_rad(45) else: @@ -427,8 +425,8 @@ func _physics_process(delta): if gun != null: if !gun.anim_player.is_playing(): if held_item == null: - if level_control.held_guns.size() > 1: - weapon_select(level_control.current_gun_index - 1) + if GameGlobals.held_guns.size() > 1: + weapon_select(GameGlobals.current_gun_index - 1) else: moveable_holder.rotation.y -= deg_to_rad(45) else: @@ -439,7 +437,7 @@ func _physics_process(delta): if Input.is_action_just_pressed("numb_" + str(i)): if gun != null: if !gun.anim_player.is_playing(): - if i-1 != level_control.current_gun_index and i <= level_control.held_guns.size(): + if i-1 != GameGlobals.current_gun_index and i <= GameGlobals.held_guns.size(): weapon_select((i - 1)) if Input.is_action_just_pressed("holster"): @@ -455,7 +453,7 @@ func _physics_process(delta): Engine.time_scale = .01 elif Input.is_action_just_released("weapon_select"): var selection = weapon_select_menu.close() - if selection != null and selection != level_control.current_gun_index : + if selection != null and selection != GameGlobals.current_gun_index : weapon_select(selection) Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) gamespeed_controlled = false @@ -487,9 +485,9 @@ func _physics_process(delta): animation_player.play("punch") if Input.is_action_just_pressed("kill_self"): - level_control.health = 0 + GameGlobals.health = 0 - if level_control.health <= 0: + if GameGlobals.health <= 0: level_control.die() focus_on_target() @@ -660,7 +658,7 @@ func holster_gun(holster): if holster: gun_is_holstered = true if gun != null: - holstered_gun_id = level_control.current_gun_index + holstered_gun_id = GameGlobals.current_gun_index gun.anim_player.play("swap_out") else: gun_is_holstered = false @@ -669,20 +667,20 @@ func holster_gun(holster): func add_ammo(new_gun,gun_name,ammo_type,max_ammo,start_mags): if new_gun: - gun_ammo[gun_name] = max_ammo + GameGlobals.gun_ammo[gun_name] = max_ammo - if ammo_reserve.has(str(ammo_type)): - ammo_reserve[str(ammo_type)] += start_mags * max_ammo + if GameGlobals.ammo_reserve.has(str(ammo_type)): + GameGlobals.ammo_reserve[str(ammo_type)] += start_mags * max_ammo else: #if melee weapon don't do max ammo calc if ammo_type == 5: - ammo_reserve[str(ammo_type)] = 0 + GameGlobals.ammo_reserve[str(ammo_type)] = 0 #otherwise calculate starting ammo else: - ammo_reserve[str(ammo_type)] = start_mags * max_ammo + GameGlobals.ammo_reserve[str(ammo_type)] = start_mags * max_ammo - print("GUN AMMO ",gun_ammo) - print("RESERVE AMMO ", ammo_reserve) + print("GUN AMMO ",GameGlobals.gun_ammo) + print("RESERVE AMMO ", GameGlobals.ammo_reserve) ## MISC @@ -712,16 +710,17 @@ func pickup_apply(type,ammo_type,value): match type: 0: #AMMO - if ammo_reserve.has(str(ammo_type)): - ammo_reserve[str(ammo_type)] += value + if GameGlobals.ammo_reserve.has(str(ammo_type)): + GameGlobals.ammo_reserve[str(ammo_type)] += value else: - ammo_reserve[str(ammo_type)] = value + GameGlobals.ammo_reserve[str(ammo_type)] = value 1: #STAMINA remaining_stamina = clamp(remaining_stamina + value,0,100) 2: #HEALTH - level_control.health = clamp(level_control.health + value,0,level_control.gamemode.start_health) + GameGlobals.health = clamp(GameGlobals.health + value,0,level_control.gamemode.start_health) 3: #MONEY - level_control.money += value + GameGlobals.money += value * level_control.gamemode.money_multiplier + SignalBus.emit_signal("money_changed") func focus_on_target(): @@ -793,7 +792,7 @@ func toggle_hud(hud_on): func hit(damage, fired_by, target_type): SignalBus.emit_signal("player_hit") - level_control.health -= damage + GameGlobals.health -= damage level_control.last_hit = fired_by level_control.target_type = target_type recoil.add_recoil(Vector3(.5,.1,.1),10,10) @@ -815,7 +814,5 @@ func save(): "rot_z" : rotation.z, "crouched" : crouched, "flashlight_on" : flashlight_on, - "gun_ammo" : gun_ammo, - "ammo_reserve" : ammo_reserve } return save_dict diff --git a/scripts/rocket_launcher.gd b/scripts/rocket_launcher.gd index 95c5b6a..8d4be58 100644 --- a/scripts/rocket_launcher.gd +++ b/scripts/rocket_launcher.gd @@ -68,20 +68,20 @@ func _process(_delta): func reload_finished(): - if player.ammo_reserve[str(ammo_type)] >= max_ammo: - player.gun_ammo[gun_name] += max_ammo - player.ammo_reserve[str(ammo_type)] -= max_ammo + if GameGlobals.ammo_reserve[str(ammo_type)] >= max_ammo: + GameGlobals.gun_ammo[gun_name] += max_ammo + GameGlobals.ammo_reserve[str(ammo_type)] -= max_ammo else: - player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)] - player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)] + GameGlobals.gun_ammo[gun_name] += GameGlobals.ammo_reserve[str(ammo_type)] + GameGlobals.ammo_reserve[str(ammo_type)] -= GameGlobals.ammo_reserve[str(ammo_type)] func shoot(delta): - if player.gun_ammo[gun_name] > 0 and cycle_count > 0: + if GameGlobals.gun_ammo[gun_name] > 0 and cycle_count > 0: if !anim_player.is_playing(): - player.gun_ammo[gun_name] -= 1 + GameGlobals.gun_ammo[gun_name] -= 1 #RECOIL --- fix later to happen over a period of time #(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION) audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt) @@ -107,15 +107,15 @@ func shoot(delta): audio_empty.play() func reload(): - if player.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and player.ammo_reserve[str(ammo_type)] > 0: + if GameGlobals.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and GameGlobals.ammo_reserve[str(ammo_type)] > 0: #player.reloading = true anim_player.play("reload") audio_reload.play() if anim_player.is_playing() and anim_player.current_animation == "reload": - if player.gun_ammo[gun_name] == 0: - player.gun_ammo[gun_name] = 0 + if GameGlobals.gun_ammo[gun_name] == 0: + GameGlobals.gun_ammo[gun_name] = 0 else: - player.gun_ammo[gun_name] = 1 + GameGlobals.gun_ammo[gun_name] = 1 func spawn_mag(): var instance_mag = mag.instantiate() diff --git a/scripts/save_load.gd b/scripts/save_load.gd index ca87a48..22d6840 100644 --- a/scripts/save_load.gd +++ b/scripts/save_load.gd @@ -12,8 +12,7 @@ var data_cleared var player_loc var player_rot var player_health -var player_money -var held_guns +var player_velocity_cache var current_gun var current_ammo var reserve_ammo @@ -30,27 +29,56 @@ func _ready() -> void: enemies_killed = 0 func save_persistent_data(): + var level_control = get_tree().current_scene + var player = level_control.player var file = FileAccess.open(persistent_save_path, FileAccess.WRITE) print("LAST HIT PATH " + str(last_hit_path)) file.store_var(last_hit_path) + file.store_var(player.velocity) + file.store_var(GameGlobals.money) + file.store_var(GameGlobals.health) + file.store_var(GameGlobals.high_score) file.store_var(player_deaths) file.store_var(enemies_killed) file.store_var(shots_fired) + var held_guns = save_resource_path(GameGlobals.held_guns) + file.store_var(held_guns) + file.store_var(GameGlobals.gun_ammo) + file.store_var(GameGlobals.ammo_reserve) + file.store_var(GameGlobals.current_gun_index) file.store_var(data_cleared) file.close() func load_persistent_data(): + var level_control = get_tree().current_scene + var player = level_control.player if FileAccess.file_exists(persistent_save_path): var file = FileAccess.open(persistent_save_path, FileAccess.READ) last_hit_path = file.get_var() print("CROWN PARENT : " + str(last_hit_path)) - player_deaths = file.get_var() + player_velocity_cache = file.get_var() + GameGlobals.money = set_nulls_zero(file.get_var()) + print("MONEY : ", GameGlobals.money) + GameGlobals.health = file.get_var() + print("HEALTH : ", GameGlobals.health) + GameGlobals.high_score = file.get_var() + print("HIGH SCORE : ",GameGlobals.high_score) + player_deaths = set_nulls_zero(file.get_var()) print("PLAYER DEATHS : " + str(player_deaths)) - enemies_killed = file.get_var() + enemies_killed = set_nulls_zero(file.get_var()) print("ENEMIES KILLED : " + str(enemies_killed)) - shots_fired = file.get_var() + shots_fired = set_nulls_zero(file.get_var()) print("SHOTS FIRED ",shots_fired) + + var held_guns_encoded = file.get_var() + GameGlobals.held_guns = load_resource_path(held_guns_encoded) + GameGlobals.gun_ammo = file.get_var() + GameGlobals.ammo_reserve = file.get_var() + GameGlobals.current_gun_index = file.get_var() + if GameGlobals.current_gun_index != null: + get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index) + data_cleared = file.get_var() file.close() else: @@ -70,18 +98,6 @@ func save_game_data(level_name): data_cleared = false player_loc = player.global_position player_rot = player.global_rotation - player_health = level_control.health - player_money = level_control.money - held_guns = save_resource_path(level_control.held_guns) - current_gun = level_control.current_gun_index - current_ammo = player.gun_ammo - reserve_ammo = player.ammo_reserve - - #SAVE DATA - file.store_var(player_health) - file.store_var(player_money) - file.store_var(held_guns) - file.store_var(current_gun) #save enemies var objects = get_tree().get_nodes_in_group("persist") @@ -111,6 +127,7 @@ func clear_persistent_data(): file.store_var(null) file.store_var(null) file.store_var(null) + file.store_var(null) print("PERSISTENT DATA CLEARED") file.close() @@ -131,11 +148,6 @@ func load_save_game_data(level_name): #GET DATA if !data_cleared: - player_health = file.get_var() - player_money = file.get_var() - var held_guns_encoded = file.get_var() - held_guns = load_resource_path(held_guns_encoded) - current_gun = file.get_var() var current_nodes = get_tree().get_nodes_in_group("persist") for i in current_nodes: if i.is_in_group("enemy"): @@ -167,17 +179,7 @@ func load_save_game_data(level_name): if i == "filename" or i == "pos_x" or i == "pos_y" or i == "pos_z": continue new_object.set(i,node_data[i]) - - - #APPLY DATA - level_control.health = player_health - level_control.money = player_money - level_control.held_guns = held_guns - if player.gun: - player.gun.queue_free() - if current_gun != null: - level_control.gun_spawn(current_gun) - + file.close() await get_tree().create_timer(1).timeout #need to fix this SignalBus.emit_signal("game_loaded") @@ -191,6 +193,12 @@ func data_validate(file,variable): else: return null +func set_nulls_zero(variable): + if variable == null: + return 0 + else: + return variable + func null_data_check(variable,amount): #checks if value is null, adds the number to variable if variable == null: variable = amount @@ -209,11 +217,14 @@ func save_resource_path(array): return final_array func load_resource_path(array): - var final_array = [] - for i in array: - var i_loaded = load(i) - final_array.append(i_loaded) - return final_array + if array != null: + var final_array = [] + for i in array: + var i_loaded = load(i) + final_array.append(i_loaded) + return final_array + else: + return [] func shot_fired(): shots_fired += 1 #null_data_check(shots_fired, 1) diff --git a/scripts/scene_changer.gd b/scripts/scene_changer.gd new file mode 100644 index 0000000..35fb320 --- /dev/null +++ b/scripts/scene_changer.gd @@ -0,0 +1,30 @@ +extends Area3D + +@export var scene_path : String +@export var scene_name : String +@export var gamemode : gamemode +@export var scene_thumbnail : Texture2D + +var active = false + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_body_entered(body: Node3D) -> void: + if active: + if get_tree().current_scene.gamemode.load_save == true: + SaveLoad.save_game_data(get_tree().current_scene.get_name()) + SaveLoad.save_persistent_data() + SignalBus.emit_signal("player_exiting_tree") + get_tree().change_scene_to_file(scene_path) + + +func _on_start_activation_timeout() -> void: + active = true diff --git a/scripts/signal_bus.gd b/scripts/signal_bus.gd index 1fa5c5f..b212cb9 100644 --- a/scripts/signal_bus.gd +++ b/scripts/signal_bus.gd @@ -6,6 +6,8 @@ signal enemy_count_changed() signal game_loaded() ##PLAYER +signal money_changed() +signal player_exiting_tree() signal player_hit() signal shot_fired() signal enemy_hit() diff --git a/scripts/stat_display.gd b/scripts/stat_display.gd index ae9825e..f73bd3d 100644 --- a/scripts/stat_display.gd +++ b/scripts/stat_display.gd @@ -4,6 +4,7 @@ extends Node3D @onready var kills: Label3D = $Kills @onready var deaths: Label3D = $Deaths @onready var shots_fired: Label3D = $"Shots Fired" +@onready var high_score: Label3D = $"High Score" @onready var level_control = get_tree().current_scene @@ -15,6 +16,7 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: gamemode.text = str(level_control.gamemode.gamemode_name) + high_score.text = str("HIGH SCORE : ",GameGlobals.high_score) kills.text = "Kills : " + str(SaveLoad.enemies_killed) deaths.text = "Deaths : " + str(SaveLoad.player_deaths) shots_fired.text = "Shots Fired : " + str(SaveLoad.shots_fired) diff --git a/scripts/vendingmahcine.gd b/scripts/vendingmahcine.gd index da2a36a..56209ed 100644 --- a/scripts/vendingmahcine.gd +++ b/scripts/vendingmahcine.gd @@ -22,8 +22,8 @@ func _ready(): func interact(): if active == true: - if level_control.money >= item_price: - level_control.money -= item_price + if GameGlobals.money >= item_price: + GameGlobals.money -= item_price anim_player.play("vend") price_label.text = "vending..." else: diff --git a/scripts/weapon_pickup.gd b/scripts/weapon_pickup.gd index 887f865..16c62c8 100644 --- a/scripts/weapon_pickup.gd +++ b/scripts/weapon_pickup.gd @@ -18,18 +18,16 @@ func _process(delta): pass func picked_up(): - for i in level_control.held_guns: + for i in GameGlobals.held_guns: if i == gun_resource: gun_already_held = true if !gun_already_held: var gun_info = gun_resource.instantiate() level_control.player.add_ammo(true,gun_info.gun_name,gun_info.ammo_type,gun_info.max_ammo,gun_info.start_mags) - level_control.held_guns.append(gun_resource) + GameGlobals.held_guns.append(gun_resource) var instance_gun = gun_resource.instantiate() - level_control.ammo_current.append(instance_gun.max_ammo) - level_control.ammo_reserve.append(instance_gun.max_ammo * instance_gun.start_mags) - var weapon_id = level_control.held_guns.size() - 1 + var weapon_id = GameGlobals.held_guns.size() - 1 if level_control.player.gun != null: level_control.player.gun.anim_player.play("swap_out") level_control.gun_spawn(weapon_id) diff --git a/scripts/weapon_select.gd b/scripts/weapon_select.gd index 382e5b6..e128447 100644 --- a/scripts/weapon_select.gd +++ b/scripts/weapon_select.gd @@ -120,7 +120,7 @@ func _draw(): ) func update_weapon_list(): - options = level_control.held_guns + options = GameGlobals.held_guns func joypad_select(): var joy_out = Vector2.ZERO