clears savegame on death

This commit is contained in:
derek
2024-12-02 16:46:16 -06:00
parent c30ccff06c
commit a9aaed9c6f
3 changed files with 23 additions and 15 deletions

View File

@@ -96,6 +96,7 @@ theme_override_font_sizes/font_size = 150
text = "Resume"
[node name="Load" type="Button" parent="MarginContainer/VBoxContainer"]
visible = false
layout_mode = 2
theme_override_fonts/font = ExtResource("3_4nq4f")
theme_override_font_sizes/font_size = 150

View File

@@ -45,6 +45,10 @@ var engine_time_scale_cache : float = 1.0
func _ready():
##LOAD DATA
SaveLoad.load_persistent_data()
SaveLoad.load_save_game_data()
if SaveLoad.data_cleared:
refresh_scene()
#Spawn Crown
var crown_spawn = crown.instantiate()
@@ -56,15 +60,6 @@ func _ready():
#global randomize function
randomize()
health = start_health
respawn_position = player.camera.global_position
respawn_cam_rotation = player.global_transform.basis
#clear spawned in objects
for node in get_tree().get_nodes_in_group("spawned"):
node.queue_free()
#assign pickups to array
if ammo_drop_enabled == true:
pickups.append(ammo_drop)
@@ -75,6 +70,22 @@ func _ready():
if money_drop_enabled == true:
pickups.append(money_drop)
#clear spawned in objects
for node in get_tree().get_nodes_in_group("spawned"):
node.queue_free()
#find enemy hiveminds
for node in get_tree().get_nodes_in_group("enemy_hivemind"):
enemy_hiveminds.append(node)
#count starting enemies
enemy_count()
func refresh_scene():
health = start_health
respawn_position = player.camera.global_position
respawn_cam_rotation = player.global_transform.basis
if player:
#Set up starting guns and ammo
if gun_1 != null:
@@ -94,11 +105,6 @@ func _ready():
current_gun_index = 0
gun_spawn(0)
#find enemy hiveminds
for node in get_tree().get_nodes_in_group("enemy_hivemind"):
enemy_hiveminds.append(node)
#count starting enemies
enemy_count()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):

View File

@@ -130,7 +130,8 @@ func load_save_game_data():
level_control.health = player_health
level_control.money = player_money
level_control.held_guns = held_guns
player.gun.queue_free()
if player.gun:
player.gun.queue_free()
level_control.gun_spawn(current_gun)
level_control.ammo_current = current_ammo
level_control.ammo_reserve = reserve_ammo