substantial work on saving and loading and hub mechanic
This commit is contained in:
37
GameModes/hubworld.tres
Normal file
37
GameModes/hubworld.tres
Normal file
@@ -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
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_d71ib")
|
script = ExtResource("1_d71ib")
|
||||||
win_conditions = 0
|
|
||||||
gamemode_name = "no stamina regen, no health drops"
|
gamemode_name = "no stamina regen, no health drops"
|
||||||
|
win_conditions = 0
|
||||||
survival_time = 160.0
|
survival_time = 160.0
|
||||||
walk_speed = 12.0
|
walk_speed = 12.0
|
||||||
jump_velocity = 5
|
jump_velocity = 5
|
||||||
@@ -30,5 +30,5 @@ expected_ammo = {
|
|||||||
"shotgun": 20
|
"shotgun": 20
|
||||||
}
|
}
|
||||||
stamina_drop_enabled = true
|
stamina_drop_enabled = true
|
||||||
health_drop_enabled = true
|
health_drop_enabled = false
|
||||||
money_drop_enabled = true
|
money_drop_enabled = true
|
||||||
|
|||||||
@@ -7,17 +7,20 @@ script = ExtResource("1_litni")
|
|||||||
gamemode_name = "Standard"
|
gamemode_name = "Standard"
|
||||||
win_conditions = 0
|
win_conditions = 0
|
||||||
survival_time = 160.0
|
survival_time = 160.0
|
||||||
|
money_lost_multiplier = 0.5
|
||||||
|
weapon_penalty = 0
|
||||||
|
weapon_drop_percentage = 0.5
|
||||||
walk_speed = 12.0
|
walk_speed = 12.0
|
||||||
jump_velocity = 5
|
jump_velocity = 5
|
||||||
dash_speed = 40
|
dash_speed = 40
|
||||||
gravity = -9.8
|
gravity = -9.8
|
||||||
time_slowed_speed = 0.1
|
time_slowed_speed = 0.1
|
||||||
stamina_regen = true
|
stamina_regen = false
|
||||||
max_stamina = 100.0
|
max_stamina = 100.0
|
||||||
stamina_drain = 20.0
|
stamina_drain = 20.0
|
||||||
air_dash_max = 1
|
air_dash_max = 1
|
||||||
load_save = true
|
load_save = false
|
||||||
money = 0
|
money_drop_multiplier = 1.0
|
||||||
start_health = 10
|
start_health = 10
|
||||||
drop_chance_minimum = 0.1
|
drop_chance_minimum = 0.1
|
||||||
random_drops = false
|
random_drops = false
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[gd_scene load_steps=112 format=4 uid="uid://6agmt1hqlhww"]
|
[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="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="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="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"]
|
[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")]
|
[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)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.016016, 0.0225029, -0.0192337)
|
||||||
script = ExtResource("1_sbpvn")
|
script = ExtResource("1_sbpvn")
|
||||||
load_save = false
|
gamemode = ExtResource("2_cuqu0")
|
||||||
player = NodePath("Player")
|
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")]
|
[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)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.137423, 1.78365, 12.8627)
|
||||||
|
|||||||
@@ -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)
|
|
||||||
19
assets/level_sign.tscn
Normal file
19
assets/level_sign.tscn
Normal file
@@ -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
|
||||||
@@ -61,7 +61,7 @@ shader_parameter/noise = SubResource("NoiseTexture2D_0eorp")
|
|||||||
size = Vector3(3, 3.58057, 3)
|
size = Vector3(3, 3.58057, 3)
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_xfie3"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_xfie3"]
|
||||||
radius = 7.0
|
radius = 5.0
|
||||||
|
|
||||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_pxyjg"]
|
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_pxyjg"]
|
||||||
random_pitch = 2.0
|
random_pitch = 2.0
|
||||||
@@ -264,6 +264,7 @@ collision_layer = 0
|
|||||||
collision_mask = 16
|
collision_mask = 16
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="pick_up_magnet"]
|
[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")
|
shape = SubResource("SphereShape3D_xfie3")
|
||||||
|
|
||||||
[node name="Audio" type="Node3D" parent="."]
|
[node name="Audio" type="Node3D" parent="."]
|
||||||
|
|||||||
34
assets/scene_changer.tscn
Normal file
34
assets/scene_changer.tscn
Normal file
@@ -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"]
|
||||||
@@ -7,24 +7,31 @@
|
|||||||
script = ExtResource("1_q47is")
|
script = ExtResource("1_q47is")
|
||||||
|
|
||||||
[node name="Gamemode" type="Label3D" parent="."]
|
[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"
|
text = "Test"
|
||||||
font = ExtResource("2_mtulh")
|
font = ExtResource("2_mtulh")
|
||||||
horizontal_alignment = 0
|
horizontal_alignment = 0
|
||||||
|
|
||||||
[node name="Kills" type="Label3D" parent="."]
|
[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"
|
text = "Test"
|
||||||
font = ExtResource("2_mtulh")
|
font = ExtResource("2_mtulh")
|
||||||
horizontal_alignment = 0
|
horizontal_alignment = 0
|
||||||
|
|
||||||
[node name="Deaths" type="Label3D" parent="."]
|
[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"
|
text = "Test"
|
||||||
font = ExtResource("2_mtulh")
|
font = ExtResource("2_mtulh")
|
||||||
horizontal_alignment = 0
|
horizontal_alignment = 0
|
||||||
|
|
||||||
[node name="Shots Fired" type="Label3D" parent="."]
|
[node name="Shots Fired" type="Label3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.285934, 0)
|
||||||
text = "Test"
|
text = "Test"
|
||||||
font = ExtResource("2_mtulh")
|
font = ExtResource("2_mtulh")
|
||||||
horizontal_alignment = 0
|
horizontal_alignment = 0
|
||||||
|
|||||||
@@ -5,18 +5,22 @@ class_name gamemode
|
|||||||
@export_enum("Kill 'em All","Extraction","Survival_Time") var win_conditions
|
@export_enum("Kill 'em All","Extraction","Survival_Time") var win_conditions
|
||||||
@export_group("Win Conditions")
|
@export_group("Win Conditions")
|
||||||
@export var survival_time : float = 160 #in seconds
|
@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_group("Player Movement")
|
||||||
@export var walk_speed = 12.0
|
@export var walk_speed = 12.0
|
||||||
@export var jump_velocity = 5
|
@export var jump_velocity = 5
|
||||||
@export var dash_speed = 40
|
@export var dash_speed = 40
|
||||||
@export var gravity : float = -9.8
|
@export var gravity : float = -9.8
|
||||||
@export var time_slowed_speed : float = .1
|
@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 max_stamina : float = 100
|
||||||
@export var stamina_drain : float = 20
|
@export var stamina_drain : float = 20
|
||||||
@export var air_dash_max : int = 1
|
@export var air_dash_max : int = 1
|
||||||
@export var load_save : = true
|
@export var load_save : = true
|
||||||
@export var money = 0
|
@export var money_multiplier : float = 1.0
|
||||||
@export var start_health = 10
|
@export var start_health = 10
|
||||||
@export var gun_1 : Resource
|
@export var gun_1 : Resource
|
||||||
@export var gun_2 : Resource
|
@export var gun_2 : Resource
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="First Person Test"
|
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/features=PackedStringArray("4.3", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ persist=""
|
|||||||
breakable=""
|
breakable=""
|
||||||
leak="will leak if damaged"
|
leak="will leak if damaged"
|
||||||
item_pickup=""
|
item_pickup=""
|
||||||
|
hub_level=""
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
|||||||
85
scenes/HUBEFE.tmp
Normal file
85
scenes/HUBEFE.tmp
Normal file
@@ -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)
|
||||||
85
scenes/HUBWORLD.tscn
Normal file
85
scenes/HUBWORLD.tscn
Normal file
@@ -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)
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,7 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
class_name map
|
||||||
|
|
||||||
|
@export var map_name : String = "Map Name"
|
||||||
@export var gamemode : gamemode
|
@export var gamemode : gamemode
|
||||||
@export var player : Node
|
@export var player : Node
|
||||||
@export var MAX_PARTICLES = 100
|
@export var MAX_PARTICLES = 100
|
||||||
@@ -13,20 +15,14 @@ extends Node3D
|
|||||||
@onready var item_pickup = preload("res://assets/item_pickup.tscn")
|
@onready var item_pickup = preload("res://assets/item_pickup.tscn")
|
||||||
@onready var crown = preload("res://assets/crown.tscn")
|
@onready var crown = preload("res://assets/crown.tscn")
|
||||||
var dead_player = preload("res://assets/dead_cam.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")
|
const DEAD_ANNOUNCE = preload("res://assets/dead_announce.tscn")
|
||||||
|
|
||||||
var level_name
|
var level_name
|
||||||
var paused = false
|
var paused = false
|
||||||
var health
|
|
||||||
var money
|
|
||||||
var pickups = []
|
var pickups = []
|
||||||
var held_guns = []
|
|
||||||
var ammo_current = [0]
|
|
||||||
var ammo_reserve = [0]
|
|
||||||
var keys = []
|
var keys = []
|
||||||
var guns_dict = {}
|
var guns_dict = {}
|
||||||
var current_gun_index
|
|
||||||
var particle_number = 0
|
var particle_number = 0
|
||||||
var enemy_hiveminds = []
|
var enemy_hiveminds = []
|
||||||
var remaining_enemies
|
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.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
level_name = self.get_name()
|
level_name = self.get_name()
|
||||||
print("LEVEL NAME ",level_name)
|
|
||||||
#connect to signals
|
#connect to signals
|
||||||
SignalBus.enemy_count_changed.connect(enemy_count)
|
SignalBus.enemy_count_changed.connect(enemy_count)
|
||||||
|
|
||||||
health = gamemode.start_health
|
GameGlobals.health = gamemode.start_health
|
||||||
money = gamemode.money
|
|
||||||
|
|
||||||
|
|
||||||
#LOAD DATA
|
#LOAD DATA
|
||||||
SaveLoad.load_persistent_data()
|
SaveLoad.load_persistent_data()
|
||||||
@@ -83,7 +76,7 @@ func _ready():
|
|||||||
enemy_count()
|
enemy_count()
|
||||||
|
|
||||||
func refresh_scene():
|
func refresh_scene():
|
||||||
health = gamemode.start_health
|
GameGlobals.health = gamemode.start_health
|
||||||
|
|
||||||
respawn_position = player.camera.global_position
|
respawn_position = player.camera.global_position
|
||||||
respawn_cam_rotation = player.global_transform.basis
|
respawn_cam_rotation = player.global_transform.basis
|
||||||
@@ -91,18 +84,18 @@ func refresh_scene():
|
|||||||
if player:
|
if player:
|
||||||
#Set up starting guns and ammo
|
#Set up starting guns and ammo
|
||||||
if gamemode.gun_1 != null:
|
if gamemode.gun_1 != null:
|
||||||
held_guns = [gamemode.gun_1]
|
GameGlobals.held_guns = [gamemode.gun_1]
|
||||||
var instance_gun = held_guns[0].instantiate()
|
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)
|
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:
|
if gamemode.gun_2 != null:
|
||||||
held_guns.append(gamemode.gun_2)
|
GameGlobals.held_guns.append(gamemode.gun_2)
|
||||||
var instance_gun_2 = held_guns[1].instantiate()
|
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)
|
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
|
# Spawn first gun
|
||||||
if gamemode.gun_1 != null:
|
if gamemode.gun_1 != null:
|
||||||
current_gun_index = 0
|
GameGlobals.current_gun_index = 0
|
||||||
gun_spawn(0)
|
gun_spawn(0)
|
||||||
|
|
||||||
|
|
||||||
@@ -114,15 +107,15 @@ func _process(_delta):
|
|||||||
func gun_spawn(index):
|
func gun_spawn(index):
|
||||||
|
|
||||||
#loop around if scrolling past available guns
|
#loop around if scrolling past available guns
|
||||||
if index > held_guns.size() - 1:
|
if index > GameGlobals.held_guns.size() - 1:
|
||||||
index = 0
|
index = 0
|
||||||
elif 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 != []:
|
if GameGlobals.held_guns != []:
|
||||||
var instance_gun = held_guns[index].instantiate()
|
var instance_gun = GameGlobals.held_guns[index].instantiate()
|
||||||
instance_gun.global_transform.origin = player.weapon_spawner.position
|
instance_gun.global_transform.origin = player.weapon_spawner.position
|
||||||
player.gun = instance_gun
|
player.gun = instance_gun
|
||||||
player.def_weapon_holder_pos = player.weapon_holder.position
|
player.def_weapon_holder_pos = player.weapon_holder.position
|
||||||
@@ -142,13 +135,12 @@ func enemy_count():
|
|||||||
cleared()
|
cleared()
|
||||||
|
|
||||||
func cleared():
|
func cleared():
|
||||||
var clearedmsg = CLEARED_ANNOUNCE.instantiate()
|
pass
|
||||||
get_parent().add_child(clearedmsg)
|
|
||||||
await get_tree().create_timer(1).timeout
|
|
||||||
clearedmsg.queue_free()
|
|
||||||
|
|
||||||
func die():
|
func die():
|
||||||
#record stats
|
#record stats
|
||||||
|
GameGlobals.money_penalty()
|
||||||
|
GameGlobals.weapon_penalty()
|
||||||
if SaveLoad.player_deaths:
|
if SaveLoad.player_deaths:
|
||||||
SaveLoad.player_deaths += 1
|
SaveLoad.player_deaths += 1
|
||||||
else:
|
else:
|
||||||
@@ -184,14 +176,14 @@ func pickup_spawn(randomized):
|
|||||||
pickup_type = randi_range(0,3)
|
pickup_type = randi_range(0,3)
|
||||||
#if item type is ammo, pick random ammo
|
#if item type is ammo, pick random ammo
|
||||||
if pickup_type == 0:
|
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())
|
ammo_type = int(player_ammo.pick_random())
|
||||||
#random value of pickup
|
#random value of pickup
|
||||||
value = randi_range(1,50)
|
value = randi_range(1,50)
|
||||||
else:
|
else:
|
||||||
var health_weight
|
var health_weight
|
||||||
if gamemode.health_drop_enabled:
|
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:
|
else:
|
||||||
health_weight = 0
|
health_weight = 0
|
||||||
var stamina_weight
|
var stamina_weight
|
||||||
@@ -201,7 +193,7 @@ func pickup_spawn(randomized):
|
|||||||
stamina_weight = 0
|
stamina_weight = 0
|
||||||
var money_weight
|
var money_weight
|
||||||
if money_drop_enabled:
|
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:
|
else:
|
||||||
money_weight = 0
|
money_weight = 0
|
||||||
var ammo_weight
|
var ammo_weight
|
||||||
@@ -212,19 +204,19 @@ func pickup_spawn(randomized):
|
|||||||
|
|
||||||
# weight ammo player owns against expected ammo values
|
# weight ammo player owns against expected ammo values
|
||||||
if ammo_drop_enabled:
|
if ammo_drop_enabled:
|
||||||
for i in player.ammo_reserve.keys():
|
for i in GameGlobals.ammo_reserve.keys():
|
||||||
var i_weight
|
var i_weight
|
||||||
match int(i):
|
match int(i):
|
||||||
0:
|
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:
|
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:
|
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:
|
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:
|
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:
|
5:
|
||||||
i_weight = 0
|
i_weight = 0
|
||||||
if i_weight > ammo_weight:
|
if i_weight > ammo_weight:
|
||||||
|
|||||||
@@ -1,3 +1,40 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var game_loaded = false
|
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
|
||||||
|
|||||||
@@ -75,17 +75,17 @@ func _process(_delta):
|
|||||||
|
|
||||||
|
|
||||||
func reload_finished():
|
func reload_finished():
|
||||||
if player.ammo_reserve[str(ammo_type)] >= max_ammo:
|
if GameGlobals.ammo_reserve[str(ammo_type)] >= max_ammo:
|
||||||
player.gun_ammo[gun_name] += max_ammo
|
GameGlobals.gun_ammo[gun_name] += max_ammo
|
||||||
player.ammo_reserve[str(ammo_type)] -= max_ammo
|
GameGlobals.ammo_reserve[str(ammo_type)] -= max_ammo
|
||||||
else:
|
else:
|
||||||
player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)]
|
GameGlobals.gun_ammo[gun_name] += GameGlobals.ammo_reserve[str(ammo_type)]
|
||||||
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
|
GameGlobals.ammo_reserve[str(ammo_type)] -= GameGlobals.ammo_reserve[str(ammo_type)]
|
||||||
|
|
||||||
func shoot(delta):
|
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():
|
if !anim_player.is_playing():
|
||||||
player.gun_ammo[gun_name] -= 1
|
GameGlobals.gun_ammo[gun_name] -= 1
|
||||||
#audio and anims
|
#audio and anims
|
||||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||||
audio_fire.play()
|
audio_fire.play()
|
||||||
@@ -108,15 +108,15 @@ func shoot(delta):
|
|||||||
audio_empty.play()
|
audio_empty.play()
|
||||||
|
|
||||||
func reload():
|
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
|
#player.reloading = true
|
||||||
anim_player.play("reload")
|
anim_player.play("reload")
|
||||||
audio_reload.play()
|
audio_reload.play()
|
||||||
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||||
if player.gun_ammo[gun_name] == 0:
|
if GameGlobals.gun_ammo[gun_name] == 0:
|
||||||
player.gun_ammo[gun_name] = 0
|
GameGlobals.gun_ammo[gun_name] = 0
|
||||||
else:
|
else:
|
||||||
player.gun_ammo[gun_name] = 1
|
GameGlobals.gun_ammo[gun_name] = 1
|
||||||
|
|
||||||
func spawn_mag():
|
func spawn_mag():
|
||||||
var instance_mag = mag.instantiate()
|
var instance_mag = mag.instantiate()
|
||||||
|
|||||||
@@ -84,20 +84,20 @@ func _process(delta: float) -> void:
|
|||||||
gun_info.visible = true
|
gun_info.visible = true
|
||||||
|
|
||||||
#HEALTH
|
#HEALTH
|
||||||
health_bar.value = level_control.health
|
health_bar.value = GameGlobals.health
|
||||||
if level_control.health <= 2:
|
if GameGlobals.health <= 2:
|
||||||
change_color(health_bar,RED_COLOR,10,delta)
|
change_color(health_bar,RED_COLOR,10,delta)
|
||||||
health_bar.position = health_bar_start_pos + shake_element(15)
|
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)
|
change_color(health_bar,ORANGE_COLOR,10,delta)
|
||||||
else:
|
else:
|
||||||
change_color(health_bar,FULL_WHITE,10,delta)
|
change_color(health_bar,FULL_WHITE,10,delta)
|
||||||
|
|
||||||
#MONEY
|
#MONEY
|
||||||
if money_count < level_control.money:
|
if money_count < int(GameGlobals.money):
|
||||||
money_count += 1
|
money_count += 1
|
||||||
change_color(money,GREEN_COLOR,10,delta)
|
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)
|
change_color(money,RED_COLOR,10,delta)
|
||||||
money_count -= 1
|
money_count -= 1
|
||||||
else:
|
else:
|
||||||
@@ -111,12 +111,12 @@ func _process(delta: float) -> void:
|
|||||||
current_stam_bar.value = player.remaining_stamina
|
current_stam_bar.value = player.remaining_stamina
|
||||||
|
|
||||||
if player.gun != null:
|
if player.gun != null:
|
||||||
if player.gun_ammo.has(player.gun.gun_name):
|
if GameGlobals.gun_ammo.has(player.gun.gun_name):
|
||||||
ammo_current.text = str(player.gun_ammo[player.gun.gun_name]).pad_zeros(2)
|
ammo_current.text = str(GameGlobals.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)
|
lerp_color(ammo_current,RED_COLOR,FULL_WHITE,GameGlobals.gun_ammo[player.gun.gun_name],player.gun.max_ammo,.5)
|
||||||
if player.ammo_reserve.has(str(player.gun.ammo_type)):
|
if GameGlobals.ammo_reserve.has(str(player.gun.ammo_type)):
|
||||||
ammo_reserve.text = str(player.ammo_reserve[str(player.gun.ammo_type)]).pad_zeros(3)
|
ammo_reserve.text = str(GameGlobals.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)
|
lerp_color(ammo_reserve,RED_COLOR,FULL_WHITE,GameGlobals.ammo_reserve[str(player.gun.ammo_type)],player.gun.max_ammo*2,.5)
|
||||||
else:
|
else:
|
||||||
fade_in_out(ammo_current,1,false,10,delta)
|
fade_in_out(ammo_current,1,false,10,delta)
|
||||||
fade_in_out(ammo_reserve,1,false,10,delta)
|
fade_in_out(ammo_reserve,1,false,10,delta)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ var ammo_type
|
|||||||
@onready var money: Node3D = $Meshes/money
|
@onready var money: Node3D = $Meshes/money
|
||||||
|
|
||||||
|
|
||||||
var magnetable = false
|
var magnetable = true
|
||||||
var pickupable = false
|
var pickupable = false
|
||||||
var pick_up = false
|
var pick_up = false
|
||||||
var rand_amt
|
var rand_amt
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
extends Area3D
|
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() -> void:
|
||||||
func _ready():
|
SignalBus.player_exiting_tree.connect(player_exit_check)
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
func player_exit_check():
|
||||||
|
player_exit = true
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
func _on_body_exited(body: Node3D) -> void:
|
||||||
func _process(delta):
|
if !player_exit:
|
||||||
pass
|
get_tree().current_scene.die()
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
||||||
|
|||||||
11
scripts/level_sign.gd
Normal file
11
scripts/level_sign.gd
Normal file
@@ -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
|
||||||
@@ -73,8 +73,6 @@ var instance_bullet
|
|||||||
var instance_casing
|
var instance_casing
|
||||||
var instance_mag
|
var instance_mag
|
||||||
var reloading = false
|
var reloading = false
|
||||||
var gun_ammo = {}
|
|
||||||
var ammo_reserve = {}
|
|
||||||
var bullet_damage
|
var bullet_damage
|
||||||
var def_weapon_holder_pos : Vector3
|
var def_weapon_holder_pos : Vector3
|
||||||
var weapon_holder_start_rot
|
var weapon_holder_start_rot
|
||||||
@@ -314,8 +312,8 @@ func _physics_process(delta):
|
|||||||
camera.fov = lerp(camera.fov, target_fov, delta * 8)
|
camera.fov = lerp(camera.fov, target_fov, delta * 8)
|
||||||
|
|
||||||
# Health Indicator
|
# Health Indicator
|
||||||
var health_opacity = 1.5 - level_control.health / level_control.gamemode.start_health
|
var health_opacity = 1.5 - GameGlobals.health / level_control.gamemode.start_health
|
||||||
if level_control.health < (level_control.gamemode.start_health/2):
|
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)
|
health_indicator.color = lerp(Color(0.471, 0, 0, 0), Color(0.471, 0, 0, .25),health_opacity)
|
||||||
else:
|
else:
|
||||||
health_indicator.color = Color(0.471, 0, 0, 0)
|
health_indicator.color = Color(0.471, 0, 0, 0)
|
||||||
@@ -414,8 +412,8 @@ func _physics_process(delta):
|
|||||||
if gun != null:
|
if gun != null:
|
||||||
if !gun.anim_player.is_playing():
|
if !gun.anim_player.is_playing():
|
||||||
if held_item == null:
|
if held_item == null:
|
||||||
if level_control.held_guns.size() > 1:
|
if GameGlobals.held_guns.size() > 1:
|
||||||
weapon_select(level_control.current_gun_index + 1)
|
weapon_select(GameGlobals.current_gun_index + 1)
|
||||||
else:
|
else:
|
||||||
moveable_holder.rotation.y += deg_to_rad(45)
|
moveable_holder.rotation.y += deg_to_rad(45)
|
||||||
else:
|
else:
|
||||||
@@ -427,8 +425,8 @@ func _physics_process(delta):
|
|||||||
if gun != null:
|
if gun != null:
|
||||||
if !gun.anim_player.is_playing():
|
if !gun.anim_player.is_playing():
|
||||||
if held_item == null:
|
if held_item == null:
|
||||||
if level_control.held_guns.size() > 1:
|
if GameGlobals.held_guns.size() > 1:
|
||||||
weapon_select(level_control.current_gun_index - 1)
|
weapon_select(GameGlobals.current_gun_index - 1)
|
||||||
else:
|
else:
|
||||||
moveable_holder.rotation.y -= deg_to_rad(45)
|
moveable_holder.rotation.y -= deg_to_rad(45)
|
||||||
else:
|
else:
|
||||||
@@ -439,7 +437,7 @@ func _physics_process(delta):
|
|||||||
if Input.is_action_just_pressed("numb_" + str(i)):
|
if Input.is_action_just_pressed("numb_" + str(i)):
|
||||||
if gun != null:
|
if gun != null:
|
||||||
if !gun.anim_player.is_playing():
|
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))
|
weapon_select((i - 1))
|
||||||
|
|
||||||
if Input.is_action_just_pressed("holster"):
|
if Input.is_action_just_pressed("holster"):
|
||||||
@@ -455,7 +453,7 @@ func _physics_process(delta):
|
|||||||
Engine.time_scale = .01
|
Engine.time_scale = .01
|
||||||
elif Input.is_action_just_released("weapon_select"):
|
elif Input.is_action_just_released("weapon_select"):
|
||||||
var selection = weapon_select_menu.close()
|
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)
|
weapon_select(selection)
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
gamespeed_controlled = false
|
gamespeed_controlled = false
|
||||||
@@ -487,9 +485,9 @@ func _physics_process(delta):
|
|||||||
animation_player.play("punch")
|
animation_player.play("punch")
|
||||||
|
|
||||||
if Input.is_action_just_pressed("kill_self"):
|
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()
|
level_control.die()
|
||||||
|
|
||||||
focus_on_target()
|
focus_on_target()
|
||||||
@@ -660,7 +658,7 @@ func holster_gun(holster):
|
|||||||
if holster:
|
if holster:
|
||||||
gun_is_holstered = true
|
gun_is_holstered = true
|
||||||
if gun != null:
|
if gun != null:
|
||||||
holstered_gun_id = level_control.current_gun_index
|
holstered_gun_id = GameGlobals.current_gun_index
|
||||||
gun.anim_player.play("swap_out")
|
gun.anim_player.play("swap_out")
|
||||||
else:
|
else:
|
||||||
gun_is_holstered = false
|
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):
|
func add_ammo(new_gun,gun_name,ammo_type,max_ammo,start_mags):
|
||||||
if new_gun:
|
if new_gun:
|
||||||
gun_ammo[gun_name] = max_ammo
|
GameGlobals.gun_ammo[gun_name] = max_ammo
|
||||||
|
|
||||||
if ammo_reserve.has(str(ammo_type)):
|
if GameGlobals.ammo_reserve.has(str(ammo_type)):
|
||||||
ammo_reserve[str(ammo_type)] += start_mags * max_ammo
|
GameGlobals.ammo_reserve[str(ammo_type)] += start_mags * max_ammo
|
||||||
else:
|
else:
|
||||||
#if melee weapon don't do max ammo calc
|
#if melee weapon don't do max ammo calc
|
||||||
if ammo_type == 5:
|
if ammo_type == 5:
|
||||||
ammo_reserve[str(ammo_type)] = 0
|
GameGlobals.ammo_reserve[str(ammo_type)] = 0
|
||||||
#otherwise calculate starting ammo
|
#otherwise calculate starting ammo
|
||||||
else:
|
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("GUN AMMO ",GameGlobals.gun_ammo)
|
||||||
print("RESERVE AMMO ", ammo_reserve)
|
print("RESERVE AMMO ", GameGlobals.ammo_reserve)
|
||||||
|
|
||||||
## MISC
|
## MISC
|
||||||
|
|
||||||
@@ -712,16 +710,17 @@ func pickup_apply(type,ammo_type,value):
|
|||||||
|
|
||||||
match type:
|
match type:
|
||||||
0: #AMMO
|
0: #AMMO
|
||||||
if ammo_reserve.has(str(ammo_type)):
|
if GameGlobals.ammo_reserve.has(str(ammo_type)):
|
||||||
ammo_reserve[str(ammo_type)] += value
|
GameGlobals.ammo_reserve[str(ammo_type)] += value
|
||||||
else:
|
else:
|
||||||
ammo_reserve[str(ammo_type)] = value
|
GameGlobals.ammo_reserve[str(ammo_type)] = value
|
||||||
1: #STAMINA
|
1: #STAMINA
|
||||||
remaining_stamina = clamp(remaining_stamina + value,0,100)
|
remaining_stamina = clamp(remaining_stamina + value,0,100)
|
||||||
2: #HEALTH
|
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
|
3: #MONEY
|
||||||
level_control.money += value
|
GameGlobals.money += value * level_control.gamemode.money_multiplier
|
||||||
|
SignalBus.emit_signal("money_changed")
|
||||||
|
|
||||||
|
|
||||||
func focus_on_target():
|
func focus_on_target():
|
||||||
@@ -793,7 +792,7 @@ func toggle_hud(hud_on):
|
|||||||
|
|
||||||
func hit(damage, fired_by, target_type):
|
func hit(damage, fired_by, target_type):
|
||||||
SignalBus.emit_signal("player_hit")
|
SignalBus.emit_signal("player_hit")
|
||||||
level_control.health -= damage
|
GameGlobals.health -= damage
|
||||||
level_control.last_hit = fired_by
|
level_control.last_hit = fired_by
|
||||||
level_control.target_type = target_type
|
level_control.target_type = target_type
|
||||||
recoil.add_recoil(Vector3(.5,.1,.1),10,10)
|
recoil.add_recoil(Vector3(.5,.1,.1),10,10)
|
||||||
@@ -815,7 +814,5 @@ func save():
|
|||||||
"rot_z" : rotation.z,
|
"rot_z" : rotation.z,
|
||||||
"crouched" : crouched,
|
"crouched" : crouched,
|
||||||
"flashlight_on" : flashlight_on,
|
"flashlight_on" : flashlight_on,
|
||||||
"gun_ammo" : gun_ammo,
|
|
||||||
"ammo_reserve" : ammo_reserve
|
|
||||||
}
|
}
|
||||||
return save_dict
|
return save_dict
|
||||||
|
|||||||
@@ -68,20 +68,20 @@ func _process(_delta):
|
|||||||
|
|
||||||
|
|
||||||
func reload_finished():
|
func reload_finished():
|
||||||
if player.ammo_reserve[str(ammo_type)] >= max_ammo:
|
if GameGlobals.ammo_reserve[str(ammo_type)] >= max_ammo:
|
||||||
player.gun_ammo[gun_name] += max_ammo
|
GameGlobals.gun_ammo[gun_name] += max_ammo
|
||||||
player.ammo_reserve[str(ammo_type)] -= max_ammo
|
GameGlobals.ammo_reserve[str(ammo_type)] -= max_ammo
|
||||||
|
|
||||||
else:
|
else:
|
||||||
player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)]
|
GameGlobals.gun_ammo[gun_name] += GameGlobals.ammo_reserve[str(ammo_type)]
|
||||||
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
|
GameGlobals.ammo_reserve[str(ammo_type)] -= GameGlobals.ammo_reserve[str(ammo_type)]
|
||||||
|
|
||||||
|
|
||||||
func shoot(delta):
|
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():
|
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
|
#RECOIL --- fix later to happen over a period of time
|
||||||
#(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION)
|
#(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION)
|
||||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
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()
|
audio_empty.play()
|
||||||
|
|
||||||
func reload():
|
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
|
#player.reloading = true
|
||||||
anim_player.play("reload")
|
anim_player.play("reload")
|
||||||
audio_reload.play()
|
audio_reload.play()
|
||||||
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||||
if player.gun_ammo[gun_name] == 0:
|
if GameGlobals.gun_ammo[gun_name] == 0:
|
||||||
player.gun_ammo[gun_name] = 0
|
GameGlobals.gun_ammo[gun_name] = 0
|
||||||
else:
|
else:
|
||||||
player.gun_ammo[gun_name] = 1
|
GameGlobals.gun_ammo[gun_name] = 1
|
||||||
|
|
||||||
func spawn_mag():
|
func spawn_mag():
|
||||||
var instance_mag = mag.instantiate()
|
var instance_mag = mag.instantiate()
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ var data_cleared
|
|||||||
var player_loc
|
var player_loc
|
||||||
var player_rot
|
var player_rot
|
||||||
var player_health
|
var player_health
|
||||||
var player_money
|
var player_velocity_cache
|
||||||
var held_guns
|
|
||||||
var current_gun
|
var current_gun
|
||||||
var current_ammo
|
var current_ammo
|
||||||
var reserve_ammo
|
var reserve_ammo
|
||||||
@@ -30,27 +29,56 @@ func _ready() -> void:
|
|||||||
enemies_killed = 0
|
enemies_killed = 0
|
||||||
|
|
||||||
func save_persistent_data():
|
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)
|
var file = FileAccess.open(persistent_save_path, FileAccess.WRITE)
|
||||||
print("LAST HIT PATH " + str(last_hit_path))
|
print("LAST HIT PATH " + str(last_hit_path))
|
||||||
file.store_var(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(player_deaths)
|
||||||
file.store_var(enemies_killed)
|
file.store_var(enemies_killed)
|
||||||
file.store_var(shots_fired)
|
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.store_var(data_cleared)
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
func load_persistent_data():
|
func load_persistent_data():
|
||||||
|
var level_control = get_tree().current_scene
|
||||||
|
var player = level_control.player
|
||||||
if FileAccess.file_exists(persistent_save_path):
|
if FileAccess.file_exists(persistent_save_path):
|
||||||
var file = FileAccess.open(persistent_save_path, FileAccess.READ)
|
var file = FileAccess.open(persistent_save_path, FileAccess.READ)
|
||||||
last_hit_path = file.get_var()
|
last_hit_path = file.get_var()
|
||||||
print("CROWN PARENT : " + str(last_hit_path))
|
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))
|
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))
|
print("ENEMIES KILLED : " + str(enemies_killed))
|
||||||
shots_fired = file.get_var()
|
shots_fired = set_nulls_zero(file.get_var())
|
||||||
print("SHOTS FIRED ",shots_fired)
|
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()
|
data_cleared = file.get_var()
|
||||||
file.close()
|
file.close()
|
||||||
else:
|
else:
|
||||||
@@ -70,18 +98,6 @@ func save_game_data(level_name):
|
|||||||
data_cleared = false
|
data_cleared = false
|
||||||
player_loc = player.global_position
|
player_loc = player.global_position
|
||||||
player_rot = player.global_rotation
|
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
|
#save enemies
|
||||||
var objects = get_tree().get_nodes_in_group("persist")
|
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)
|
||||||
file.store_var(null)
|
file.store_var(null)
|
||||||
|
file.store_var(null)
|
||||||
|
|
||||||
print("PERSISTENT DATA CLEARED")
|
print("PERSISTENT DATA CLEARED")
|
||||||
file.close()
|
file.close()
|
||||||
@@ -131,11 +148,6 @@ func load_save_game_data(level_name):
|
|||||||
|
|
||||||
#GET DATA
|
#GET DATA
|
||||||
if !data_cleared:
|
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")
|
var current_nodes = get_tree().get_nodes_in_group("persist")
|
||||||
for i in current_nodes:
|
for i in current_nodes:
|
||||||
if i.is_in_group("enemy"):
|
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":
|
if i == "filename" or i == "pos_x" or i == "pos_y" or i == "pos_z":
|
||||||
continue
|
continue
|
||||||
new_object.set(i,node_data[i])
|
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()
|
file.close()
|
||||||
await get_tree().create_timer(1).timeout #need to fix this
|
await get_tree().create_timer(1).timeout #need to fix this
|
||||||
SignalBus.emit_signal("game_loaded")
|
SignalBus.emit_signal("game_loaded")
|
||||||
@@ -191,6 +193,12 @@ func data_validate(file,variable):
|
|||||||
else:
|
else:
|
||||||
return null
|
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
|
func null_data_check(variable,amount): #checks if value is null, adds the number to variable
|
||||||
if variable == null:
|
if variable == null:
|
||||||
variable = amount
|
variable = amount
|
||||||
@@ -209,11 +217,14 @@ func save_resource_path(array):
|
|||||||
return final_array
|
return final_array
|
||||||
|
|
||||||
func load_resource_path(array):
|
func load_resource_path(array):
|
||||||
var final_array = []
|
if array != null:
|
||||||
for i in array:
|
var final_array = []
|
||||||
var i_loaded = load(i)
|
for i in array:
|
||||||
final_array.append(i_loaded)
|
var i_loaded = load(i)
|
||||||
return final_array
|
final_array.append(i_loaded)
|
||||||
|
return final_array
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
func shot_fired():
|
func shot_fired():
|
||||||
shots_fired += 1 #null_data_check(shots_fired, 1)
|
shots_fired += 1 #null_data_check(shots_fired, 1)
|
||||||
|
|||||||
30
scripts/scene_changer.gd
Normal file
30
scripts/scene_changer.gd
Normal file
@@ -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
|
||||||
@@ -6,6 +6,8 @@ signal enemy_count_changed()
|
|||||||
signal game_loaded()
|
signal game_loaded()
|
||||||
|
|
||||||
##PLAYER
|
##PLAYER
|
||||||
|
signal money_changed()
|
||||||
|
signal player_exiting_tree()
|
||||||
signal player_hit()
|
signal player_hit()
|
||||||
signal shot_fired()
|
signal shot_fired()
|
||||||
signal enemy_hit()
|
signal enemy_hit()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ extends Node3D
|
|||||||
@onready var kills: Label3D = $Kills
|
@onready var kills: Label3D = $Kills
|
||||||
@onready var deaths: Label3D = $Deaths
|
@onready var deaths: Label3D = $Deaths
|
||||||
@onready var shots_fired: Label3D = $"Shots Fired"
|
@onready var shots_fired: Label3D = $"Shots Fired"
|
||||||
|
@onready var high_score: Label3D = $"High Score"
|
||||||
|
|
||||||
@onready var level_control = get_tree().current_scene
|
@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.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
gamemode.text = str(level_control.gamemode.gamemode_name)
|
gamemode.text = str(level_control.gamemode.gamemode_name)
|
||||||
|
high_score.text = str("HIGH SCORE : ",GameGlobals.high_score)
|
||||||
kills.text = "Kills : " + str(SaveLoad.enemies_killed)
|
kills.text = "Kills : " + str(SaveLoad.enemies_killed)
|
||||||
deaths.text = "Deaths : " + str(SaveLoad.player_deaths)
|
deaths.text = "Deaths : " + str(SaveLoad.player_deaths)
|
||||||
shots_fired.text = "Shots Fired : " + str(SaveLoad.shots_fired)
|
shots_fired.text = "Shots Fired : " + str(SaveLoad.shots_fired)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ func _ready():
|
|||||||
|
|
||||||
func interact():
|
func interact():
|
||||||
if active == true:
|
if active == true:
|
||||||
if level_control.money >= item_price:
|
if GameGlobals.money >= item_price:
|
||||||
level_control.money -= item_price
|
GameGlobals.money -= item_price
|
||||||
anim_player.play("vend")
|
anim_player.play("vend")
|
||||||
price_label.text = "vending..."
|
price_label.text = "vending..."
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -18,18 +18,16 @@ func _process(delta):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func picked_up():
|
func picked_up():
|
||||||
for i in level_control.held_guns:
|
for i in GameGlobals.held_guns:
|
||||||
if i == gun_resource:
|
if i == gun_resource:
|
||||||
gun_already_held = true
|
gun_already_held = true
|
||||||
|
|
||||||
if !gun_already_held:
|
if !gun_already_held:
|
||||||
var gun_info = gun_resource.instantiate()
|
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.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()
|
var instance_gun = gun_resource.instantiate()
|
||||||
level_control.ammo_current.append(instance_gun.max_ammo)
|
var weapon_id = GameGlobals.held_guns.size() - 1
|
||||||
level_control.ammo_reserve.append(instance_gun.max_ammo * instance_gun.start_mags)
|
|
||||||
var weapon_id = level_control.held_guns.size() - 1
|
|
||||||
if level_control.player.gun != null:
|
if level_control.player.gun != null:
|
||||||
level_control.player.gun.anim_player.play("swap_out")
|
level_control.player.gun.anim_player.play("swap_out")
|
||||||
level_control.gun_spawn(weapon_id)
|
level_control.gun_spawn(weapon_id)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ func _draw():
|
|||||||
)
|
)
|
||||||
|
|
||||||
func update_weapon_list():
|
func update_weapon_list():
|
||||||
options = level_control.held_guns
|
options = GameGlobals.held_guns
|
||||||
|
|
||||||
func joypad_select():
|
func joypad_select():
|
||||||
var joy_out = Vector2.ZERO
|
var joy_out = Vector2.ZERO
|
||||||
|
|||||||
Reference in New Issue
Block a user