added main menu and can continue from last level

This commit is contained in:
derek
2025-02-24 17:00:41 -06:00
parent a303eb6430
commit c87f22d9e8
14 changed files with 204 additions and 68 deletions

47
MainMenu.tscn Normal file
View File

@@ -0,0 +1,47 @@
[gd_scene load_steps=3 format=3 uid="uid://sa1d1rftyn87"]
[ext_resource type="Script" path="res://scripts/main_menu.gd" id="1_haaol"]
[ext_resource type="FontFile" uid="uid://d2h2tjhxiv5wo" path="res://assets/fonts/White On Black.ttf" id="2_ac165"]
[node name="MainMenu" type="Control" groups=["ui"]]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_haaol")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -277.018
offset_top = -174.68
offset_right = 277.018
offset_bottom = 174.68
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="Continue" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_ac165")
theme_override_font_sizes/font_size = 150
text = "Continue"
[node name="Exit" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_ac165")
theme_override_font_sizes/font_size = 150
text = "exit"
[connection signal="pressed" from="MarginContainer/VBoxContainer/Continue" to="." method="_on_continue_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Exit" to="." method="_on_exit_pressed"]

6
continuelevel.tscn Normal file
View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://blbxu6joxyu1t"]
[ext_resource type="Script" path="res://scripts/main_menu.gd" id="1_splou"]
[node name="CONTINUELEVEL" type="Node3D" groups=["ui"]]
script = ExtResource("1_splou")

View File

@@ -11,7 +11,7 @@ config_version=5
[application]
config/name="First Person Test"
run/main_scene="res://scenes/HUBWORLD.tscn"
run/main_scene="res://scenes/asset_checker.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg"
@@ -59,6 +59,7 @@ breakable=""
leak="will leak if damaged"
item_pickup=""
hub_level=""
ui=""
[input]

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://jdwpc622vmok"]
[gd_scene load_steps=17 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"]
@@ -6,12 +6,13 @@
[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="Resource" uid="uid://bs8yvpq65yh3w" path="res://GameModes/cookie_mode.tres" id="6_pf4wj"]
[ext_resource type="Resource" uid="uid://dn3t7wcoumlm3" path="res://GameModes/standard.tres" id="6_t16kj"]
[ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="7_2h1ea"]
[ext_resource type="Resource" uid="uid://llsqx2cby5in" path="res://GameModes/Arena of Money.tres" id="7_j0hxr"]
[ext_resource type="PackedScene" uid="uid://bvjrsc86n2ak0" path="res://assets/deposit_money.tscn" id="8_n0nhe"]
[ext_resource type="PackedScene" uid="uid://c6bpysq1tjhy4" path="res://vendingmahcine.tscn" id="9_nu6q5"]
[ext_resource type="PackedScene" uid="uid://eujx0yilqqcp" path="res://assets/level_sign.tscn" id="11_p3sg0"]
[ext_resource type="PackedScene" uid="uid://bji3bukudxlhm" path="res://assets/health_dispenser.tscn" id="13_h5xga"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_s7e4t"]
sky_top_color = Color(0.623488, 0.812575, 0.900791, 1)
@@ -148,19 +149,19 @@ transform = Transform3D(1, 0.000164476, 0.000583754, -0.000165075, 0.999999, 0.0
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"
scene_name = "Enemy Working Scene"
gamemode = ExtResource("6_t16kj")
level_gamemode = ExtResource("6_t16kj")
[node name="Blockout2" parent="." instance=ExtResource("5_alya6")]
transform = Transform3D(0.100323, 0, 16.2141, 0, 30.4856, 0, -22.8099, 0, 0.0713132, -17.949, -57.3609, -2.74808)
scene_path = "res://assets/blockout_2.tscn"
scene_name = "Blockout 2"
gamemode = ExtResource("6_t16kj")
level_gamemode = ExtResource("6_t16kj")
[node name="Gulag of Money" parent="." instance=ExtResource("5_alya6")]
transform = Transform3D(22.8101, 0, 0, 0, 30.4856, 0, 0, 0, 16.2143, -0.602371, -57.3609, 24.0114)
scene_path = "res://scenes/Arena of Money.tscn"
scene_name = "The Gulag"
gamemode = ExtResource("7_j0hxr")
level_gamemode = ExtResource("6_pf4wj")
[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)
@@ -190,3 +191,6 @@ portal_node = NodePath("../Blockout2")
[node name="Level Sign3" parent="." node_paths=PackedStringArray("portal_node") instance=ExtResource("11_p3sg0")]
transform = Transform3D(-0.899916, 0, -0.436063, 0, 1, 0, 0.436063, 0, -0.899916, 2.88079, 1.19868, 10.7051)
portal_node = NodePath("../Gulag of Money")
[node name="HealthDispenser" parent="." instance=ExtResource("13_h5xga")]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 7.99763, 1.77484, -1.41809)

View File

@@ -1,7 +1,5 @@
[gd_scene load_steps=54 format=4 uid="uid://f7e0v1r6ra6c"]
[gd_scene load_steps=50 format=4 uid="uid://f7e0v1r6ra6c"]
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_saj4q"]
[ext_resource type="PackedScene" uid="uid://b5eclfg0cmmal" path="res://assets/revolver_1.tscn" id="2_ntm2q"]
[ext_resource type="Material" uid="uid://b6hhomp4kcjvb" path="res://assets/materials/prototype/tadaoando.tres" id="3_pecld"]
[ext_resource type="PackedScene" uid="uid://c0uv33kbndbvy" path="res://assets/trashcan.tscn" id="4_2tu3b"]
[ext_resource type="PackedScene" uid="uid://do6gt53xr2l23" path="res://assets/garbage_bin.tscn" id="5_ywaty"]
@@ -11,11 +9,7 @@
[ext_resource type="PackedScene" uid="uid://bcmd7elfjhppe" path="res://assets/tree_1.tscn" id="9_ol3is"]
[ext_resource type="PackedScene" uid="uid://by3n26uvps8tb" path="res://assets/water_tower.tscn" id="10_ey3w4"]
[ext_resource type="PackedScene" uid="uid://ciw10g8q4td1y" path="res://assets/tv.tscn" id="11_w3jqu"]
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="12_d3sh8"]
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="13_smi87"]
[ext_resource type="PackedScene" uid="uid://bww5k3t3yu7m0" path="res://assets/mug.tscn" id="14_vp24a"]
[ext_resource type="PackedScene" uid="uid://dqwkal3t4gf2p" path="res://blunderbus.tscn" id="16_xsk8x"]
[ext_resource type="PackedScene" uid="uid://2o2wcc5i1al4" path="res://assets/rocket_launcher.tscn" id="17_32jc8"]
[ext_resource type="PackedScene" uid="uid://be3x56aehx4ks" path="res://assets/Models/spider.blend" id="18_axqdp"]
[ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="19_7tuy7"]
[ext_resource type="Texture2D" uid="uid://cy4cwv7ppdclm" path="res://assets/Models/rat1.albedo.png" id="19_e5pct"]
@@ -27,10 +21,8 @@
[ext_resource type="PackedScene" uid="uid://c7vrpfdh603kr" path="res://assets/bottle_1.tscn" id="25_fk5nr"]
[ext_resource type="PackedScene" uid="uid://c6bpysq1tjhy4" path="res://vendingmahcine.tscn" id="26_rsia7"]
[ext_resource type="PackedScene" uid="uid://8cwmkiwcoaji" path="res://terrain1.tscn" id="27_hlma7"]
[ext_resource type="PackedScene" uid="uid://dyu46bns8mesv" path="res://assets/mac10_pickup.tscn" id="28_x7033"]
[ext_resource type="PackedScene" uid="uid://cucqbjb8bcha5" path="res://assets/blunderbuss_pickup.tscn" id="29_kr1fy"]
[ext_resource type="PackedScene" uid="uid://clu76sc4uoswn" path="res://assets/rocketlauncher_pickup.tscn" id="30_msqcq"]
[ext_resource type="PackedScene" uid="uid://dlhjacsike5a4" path="res://assets/oildrum1.tscn" id="31_jbe2q"]
[ext_resource type="PackedScene" uid="uid://sa1d1rftyn87" path="res://MainMenu.tscn" id="32_uxyoo"]
[ext_resource type="PackedScene" uid="uid://df34olntmk0wl" path="res://assets/vent_1.tscn" id="32_x8mvi"]
[ext_resource type="PackedScene" uid="uid://dt4t2a48204v1" path="res://assets/spikes_1.tscn" id="33_u3uct"]
@@ -310,11 +302,46 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_7g1e1")
[node name="AssetChecker" type="Node3D" node_paths=PackedStringArray("player")]
script = ExtResource("1_saj4q")
player = NodePath("Player")
start_health = 10
gun_1 = ExtResource("2_ntm2q")
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_6pck7"]
dof_blur_far_enabled = true
dof_blur_far_distance = 31.17
dof_blur_near_enabled = true
[sub_resource type="Animation" id="Animation_slj52"]
resource_name = "Menu"
length = 40.0
tracks/0/type = "position_3d"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Camera3D")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = PackedFloat32Array(0, 1, 4.83154, 1.76087, 7.17499, 19.9333, 1, -4.96827, 1.76087, 6.32403, 40, 1, 4.83154, 1.76087, 7.17499)
tracks/1/type = "rotation_3d"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Camera3D")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = PackedFloat32Array(0, 1, 0, 0, 0, 1, 19.9, 1, 0, 0.254973, 0, 0.966948, 40, 1, 0, 0, 0, 1)
[sub_resource type="Animation" id="Animation_6siip"]
length = 0.001
tracks/0/type = "position_3d"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Camera3D")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = PackedFloat32Array(0, 1, 4.83154, 1.76087, 7.17499)
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ey8td"]
_data = {
"Menu": SubResource("Animation_slj52"),
"RESET": SubResource("Animation_6siip")
}
[node name="AssetChecker" type="Node3D" groups=["ui"]]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_tngkl")
@@ -398,27 +425,12 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.55033, 0.0999999, -13.7541
[node name="TV" parent="." instance=ExtResource("11_w3jqu")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -5.11621, 0.856588, 0.461154)
[node name="mac10" parent="." instance=ExtResource("12_d3sh8")]
transform = Transform3D(0.997808, 0, 0.0661694, 0, 1, 0, -0.0661694, 0, 0.997808, -18.2675, 1.58391, 3.54959)
[node name="Player" parent="." instance=ExtResource("13_smi87")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.59557, 1.21359, 6.06777)
[node name="Mug" parent="." instance=ExtResource("14_vp24a")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.37968, 3.71927, 1.60889)
[node name="Blunderbus" parent="." instance=ExtResource("16_xsk8x")]
transform = Transform3D(0.999289, 0, -0.0376902, 0, 1, 0, 0.0376902, 0, 0.999289, -18.1798, 1.65336, 1.80161)
[node name="RocketLauncher" parent="." instance=ExtResource("17_32jc8")]
transform = Transform3D(0.999637, 0, -0.0269447, 0, 1, 0, 0.0269447, 0, 0.999637, -18.1851, 1.33295, -1.82648)
[node name="spider" parent="." instance=ExtResource("18_axqdp")]
transform = Transform3D(-0.976217, 0, -0.216797, 0, 1, 0, 0.216797, 0, -0.976217, -8.60265, 0, -0.445837)
[node name="revolver1" parent="." instance=ExtResource("2_ntm2q")]
transform = Transform3D(0.996452, 0, -0.0841648, 0, 1, 0, 0.0841648, 0, 0.996452, -18.2394, 1.58237, -3.43193)
[node name="Crate1" parent="." instance=ExtResource("19_7tuy7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9, 2, 8)
@@ -547,15 +559,6 @@ transform = Transform3D(0.0288986, 0, 0.999582, 0, 1, 0, -0.999582, 0, 0.0288986
[node name="Terrain" parent="." instance=ExtResource("27_hlma7")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 1001.46, -70.327, 173.409)
[node name="mac10_pickup" parent="." instance=ExtResource("28_x7033")]
transform = Transform3D(0.735482, -0.677544, 0, 0.677544, 0.735482, 0, 0, 0, 1, 9.33994, 3.7532, 15.9239)
[node name="blunderbuss_pickup" parent="." instance=ExtResource("29_kr1fy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 39.0626, 0.909491, 22.5097)
[node name="rocketlauncher1_pickup" parent="." instance=ExtResource("30_msqcq")]
transform = Transform3D(-0.136113, 0, 0.990693, 0, 1, 0, -0.990693, 0, -0.136113, 35.3662, 0.662383, 22.6891)
[node name="RigidBody3D" parent="." instance=ExtResource("31_jbe2q")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.3714, 1.04444, -2.16718)
@@ -585,3 +588,16 @@ transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 23.119
[node name="Vent2" parent="." instance=ExtResource("32_x8mvi")]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -6.98721, 0.923517, 22.4057)
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.83154, 1.76087, 7.17499)
attributes = SubResource("CameraAttributesPractical_6pck7")
fov = 42.0
[node name="MainMenu" parent="Camera3D" instance=ExtResource("32_uxyoo")]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_ey8td")
}
autoplay = "Menu"

View File

@@ -35,6 +35,12 @@ 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()
GameGlobals.current_level = str(self.scene_file_path)
if GameGlobals.loading_gamemode != null:
gamemode = GameGlobals.loading_gamemode
GameGlobals.loading_gamemode = null
#connect to signals
SignalBus.enemy_count_changed.connect(enemy_count)
@@ -60,6 +66,8 @@ func _ready():
if crown_target:
crown_target.add_child(crown_spawn)
crown_spawn.position = Vector3(0,2,0)
if crown_target.is_in_group("enemy"):
crown_target.loot_amount = 10
#global randomize function
randomize()
@@ -208,19 +216,20 @@ func pickup_spawn(randomized):
var i_weight
match int(i):
0:
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["light"]),0,1)
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(gamemode.expected_ammo["light"]),0,1)
1:
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["medium"]),0,1)
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(gamemode.expected_ammo["medium"]),0,1)
2:
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["heavy"]),0,1)
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(gamemode.expected_ammo["heavy"]),0,1)
3:
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["shotgun"]),0,1)
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(gamemode.expected_ammo["shotgun"]),0,1)
4:
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(expected_ammo["rocket"]),0,1)
i_weight = 1.0 - clamp(float(GameGlobals.ammo_reserve[str(i)]) / float(gamemode.expected_ammo["rocket"]),0,1)
5:
i_weight = 0
if i_weight > ammo_weight:
ammo_weight = i_weight
ammo_type_weight.erase(5)
ammo_type_weight[i] = i_weight + drop_chance_minimum
pickup_type = HelperFuncs.weighted_random({"0" : ammo_weight, "1" : stamina_weight,"2" : health_weight,"3" : money_weight})
@@ -244,5 +253,6 @@ func pickup_spawn(randomized):
return {"pickup_type" : pickup_type,"ammo_type" : ammo_type,"value" : value}
func save_quit():
SignalBus.emit_signal("player_exiting_tree")
SaveLoad.save_game_data(level_name)
get_tree().quit()

View File

@@ -9,14 +9,24 @@ var held_guns = []
var current_gun_index
var gun_ammo = {}
var ammo_reserve = {}
var loading_gamemode
var current_level
var current_gamemode
#Player Stats
func _ready() -> void:
SignalBus.money_deposited.connect(deposit_money)
func deposit_money():
deposited_money = money
if money > deposited_money:
deposited_money = money
if deposited_money > high_score:
high_score = deposited_money
func _process(delta: float) -> void:
pass
#print("current level : ",get_tree().current_scene.scene_file_path)
func money_penalty():
var level_control = get_tree().current_scene

View File

@@ -111,12 +111,16 @@ func _process(delta: float) -> void:
current_stam_bar.value = player.remaining_stamina
if player.gun != null:
if GameGlobals.gun_ammo.has(player.gun.gun_name):
if GameGlobals.gun_ammo.has(player.gun.gun_name) and GameGlobals.gun_ammo[player.gun.gun_name] != null:
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)
else:
ammo_current.text = "-"
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:
ammo_reserve.text = "-"
else:
fade_in_out(ammo_current,1,false,10,delta)
fade_in_out(ammo_reserve,1,false,10,delta)

View File

@@ -9,7 +9,7 @@ extends Node3D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
level_name.text = portal_node.scene_name
gamemode_label.text = portal_node.gamemode.gamemode_name
gamemode_label.text = portal_node.level_gamemode.gamemode_name
# Called every frame. 'delta' is the elapsed time since the previous frame.

25
scripts/main_menu.gd Normal file
View File

@@ -0,0 +1,25 @@
extends Node
var last_scene
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
SaveLoad.load_persistent_data()
func _on_continue_pressed() -> void:
var level
var load_to_gamemode
if GameGlobals.current_level == null:
level = "res://scenes/HUBWORLD.tscn"
load_to_gamemode = "res://GameModes/hubworld.tres"
else:
level = GameGlobals.current_level
load_to_gamemode = GameGlobals.current_gamemode
get_tree().change_scene_to_file(level)
GameGlobals.loading_gamemode = load(load_to_gamemode)
print("LEVEL : ",GameGlobals.current_level)
func _on_exit_pressed() -> void:
get_tree().quit()

View File

@@ -667,14 +667,16 @@ func holster_gun(holster):
func add_ammo(new_gun,gun_name,ammo_type,max_ammo,start_mags):
if new_gun:
GameGlobals.gun_ammo[gun_name] = max_ammo
if ammo_type != 5: #if ammo is not melee
GameGlobals.gun_ammo[gun_name] = max_ammo
else:
GameGlobals.gun_ammo[gun_name] = null
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:
GameGlobals.ammo_reserve[str(ammo_type)] = 0
pass
#otherwise calculate starting ammo
else:
GameGlobals.ammo_reserve[str(ammo_type)] = start_mags * max_ammo

View File

@@ -35,7 +35,10 @@ func save_persistent_data():
print("LAST HIT PATH " + str(last_hit_path))
file.store_var(last_hit_path)
file.store_var(player.velocity)
file.store_var(get_tree().current_scene.scene_file_path)
file.store_var(get_tree().current_scene.gamemode.resource_path)
file.store_var(GameGlobals.money)
file.store_var(GameGlobals.deposited_money)
file.store_var(GameGlobals.health)
file.store_var(GameGlobals.high_score)
file.store_var(player_deaths)
@@ -52,24 +55,20 @@ func save_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):
var file = FileAccess.open(persistent_save_path, FileAccess.READ)
last_hit_path = file.get_var()
print("CROWN PARENT : " + str(last_hit_path))
player_velocity_cache = file.get_var()
GameGlobals.current_level = str(file.get_var())
GameGlobals.current_gamemode = file.get_var()
GameGlobals.money = set_nulls_zero(file.get_var())
print("MONEY : ", GameGlobals.money)
GameGlobals.deposited_money = set_nulls_zero(file.get_var())
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 = set_nulls_zero(file.get_var())
print("ENEMIES KILLED : " + str(enemies_killed))
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)
@@ -77,7 +76,8 @@ func load_persistent_data():
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)
if !get_tree().current_scene.is_in_group("ui"):
get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index)
data_cleared = file.get_var()
file.close()

View File

@@ -2,7 +2,7 @@ extends Area3D
@export var scene_path : String
@export var scene_name : String
@export var gamemode : gamemode
@export var level_gamemode : gamemode
@export var scene_thumbnail : Texture2D
var active = false
@@ -19,7 +19,11 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node3D) -> void:
if active:
#Let the Bounds detector know player is exiting
SignalBus.emit_signal("player_exiting_tree")
#Set incoming gamemode
GameGlobals.loading_gamemode = level_gamemode
#Save data
if get_tree().current_scene.gamemode.load_save == true:
SaveLoad.save_game_data(get_tree().current_scene.get_name())
SaveLoad.save_persistent_data()

View File

@@ -45,10 +45,17 @@ func vend():
##SET VARIABLES
item_vend.pickup_type = pickup_type
if level_control.player.gun != null:
item_vend.ammo_type = level_control.player.gun.ammo_type
if level_control.player.gun.ammo_type != 5:
item_vend.ammo_type = level_control.player.gun.ammo_type
else:
item_vend.ammo_type = item_stats["ammo_type"]
item_vend.value = pickup_amount
if pickup_type == 0:
if level_control.player.gun != null:
item_vend.value = level_control.player.gun.max_ammo
else:
item_vend.value = item_stats["value"]
else:
item_vend.value = pickup_amount
print("ITEM : ",item_vend.pickup_type,item_vend.ammo_type,item_vend.value)
else:
item_vend = item.instantiate()