started work on save structures and data validation
This commit is contained in:
@@ -11,6 +11,7 @@ survival_time = 160.0
|
|||||||
money_lost_multiplier = 0.5
|
money_lost_multiplier = 0.5
|
||||||
weapon_penalty = 0
|
weapon_penalty = 0
|
||||||
weapon_drop_percentage = 0.5
|
weapon_drop_percentage = 0.5
|
||||||
|
ammo_drop_percentage = 0.5
|
||||||
walk_speed = 5.0
|
walk_speed = 5.0
|
||||||
jump_velocity = 5
|
jump_velocity = 5
|
||||||
dash_speed = 5
|
dash_speed = 5
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ survival_time = 160.0
|
|||||||
money_lost_multiplier = 0.5
|
money_lost_multiplier = 0.5
|
||||||
weapon_penalty = 0
|
weapon_penalty = 0
|
||||||
weapon_drop_percentage = 0.5
|
weapon_drop_percentage = 0.5
|
||||||
|
ammo_drop_percentage = 0.5
|
||||||
walk_speed = 12.0
|
walk_speed = 12.0
|
||||||
jump_velocity = 5
|
jump_velocity = 5
|
||||||
dash_speed = 40
|
dash_speed = 40
|
||||||
|
|||||||
@@ -36,14 +36,25 @@ grow_vertical = 2
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
|
theme_override_constants/separation = 30
|
||||||
|
|
||||||
[node name="leaderboard_name" type="TextEdit" parent="MarginContainer/VBoxContainer"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
custom_minimum_size = Vector2(0, 75)
|
custom_minimum_size = Vector2(0, 75)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="leaderboard_name" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
|
clip_contents = false
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
theme = ExtResource("2_3fflq")
|
theme = ExtResource("2_3fflq")
|
||||||
theme_override_font_sizes/font_size = 51
|
theme_override_font_sizes/font_size = 51
|
||||||
placeholder_text = "Leaderboard name"
|
placeholder_text = "Leaderboard name"
|
||||||
|
|
||||||
|
[node name="Confirmed" type="CheckButton" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Continue" type="Button" parent="MarginContainer/VBoxContainer"]
|
[node name="Continue" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_fonts/font = ExtResource("2_ac165")
|
theme_override_fonts/font = ExtResource("2_ac165")
|
||||||
@@ -56,5 +67,7 @@ theme_override_fonts/font = ExtResource("2_ac165")
|
|||||||
theme_override_font_sizes/font_size = 150
|
theme_override_font_sizes/font_size = 150
|
||||||
text = "exit"
|
text = "exit"
|
||||||
|
|
||||||
|
[connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer/leaderboard_name" to="." method="_on_leaderboard_name_text_changed"]
|
||||||
|
[connection signal="toggled" from="MarginContainer/VBoxContainer/HBoxContainer/Confirmed" to="." method="_on_confirmed_toggled"]
|
||||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Continue" to="." method="_on_continue_pressed"]
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Continue" to="." method="_on_continue_pressed"]
|
||||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Exit" to="." method="_on_exit_pressed"]
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Exit" to="." method="_on_exit_pressed"]
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_qvqs2")
|
script = ExtResource("1_qvqs2")
|
||||||
generate_playlist_now = null
|
generate_playlist_now = null
|
||||||
|
checksum_test = null
|
||||||
maps_in_rotation = Array[String](["res://assets/blockout_2.tscn", "res://scenes/enemy_working_scene.tscn", "res://scenes/test_level_2v2.tscn", "res://scenes/Arena of Money.tscn"])
|
maps_in_rotation = Array[String](["res://assets/blockout_2.tscn", "res://scenes/enemy_working_scene.tscn", "res://scenes/test_level_2v2.tscn", "res://scenes/Arena of Money.tscn"])
|
||||||
gamemodes_in_rotation = Array[ExtResource("2_hoyqc")]([ExtResource("2_85uje"), ExtResource("3_t0mxh"), ExtResource("4_8wht4"), ExtResource("6_vu1w7")])
|
gamemodes_in_rotation = Array[ExtResource("2_hoyqc")]([ExtResource("2_85uje"), ExtResource("3_t0mxh"), ExtResource("4_8wht4"), ExtResource("6_vu1w7")])
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,12 @@ theme_override_fonts/font = ExtResource("3_4nq4f")
|
|||||||
theme_override_font_sizes/font_size = 150
|
theme_override_font_sizes/font_size = 150
|
||||||
text = "Resume"
|
text = "Resume"
|
||||||
|
|
||||||
|
[node name="Main Menu" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_fonts/font = ExtResource("3_4nq4f")
|
||||||
|
theme_override_font_sizes/font_size = 150
|
||||||
|
text = "Main Menu"
|
||||||
|
|
||||||
[node name="Save & Quit" type="Button" parent="MarginContainer/VBoxContainer"]
|
[node name="Save & Quit" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_fonts/font = ExtResource("3_4nq4f")
|
theme_override_fonts/font = ExtResource("3_4nq4f")
|
||||||
@@ -103,4 +109,5 @@ theme_override_font_sizes/font_size = 150
|
|||||||
text = "Save & Quit"
|
text = "Save & Quit"
|
||||||
|
|
||||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Resume" to="." method="_on_resume_pressed"]
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Resume" to="." method="_on_resume_pressed"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Main Menu" to="." method="_on_main_menu_pressed"]
|
||||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Save & Quit" to="." method="_on_save__quit_pressed"]
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/Save & Quit" to="." method="_on_save__quit_pressed"]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="First Person Test"
|
config/name="First Person Test"
|
||||||
run/main_scene="res://scenes/asset_checker.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"
|
||||||
|
|
||||||
|
|||||||
@@ -44,3 +44,25 @@ func only_valid_chars(input_string: String) -> String:
|
|||||||
valid_chars += char
|
valid_chars += char
|
||||||
|
|
||||||
return valid_chars
|
return valid_chars
|
||||||
|
|
||||||
|
func checksum(check_data):
|
||||||
|
var mult = 0.0
|
||||||
|
var div : float = 0.0
|
||||||
|
var checksum : float = 0.0
|
||||||
|
var index = 0.0
|
||||||
|
|
||||||
|
for data in check_data:
|
||||||
|
if data == null:
|
||||||
|
data = TAU
|
||||||
|
if data > div:
|
||||||
|
div = data
|
||||||
|
if index == 0:
|
||||||
|
mult = PI * data
|
||||||
|
checksum += mult * data
|
||||||
|
mult = PI * data
|
||||||
|
print("DATA : ",data," | MULT : ",mult)
|
||||||
|
index += 1
|
||||||
|
|
||||||
|
checksum = checksum/div
|
||||||
|
print(checksum)
|
||||||
|
return checksum
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ func _ready():
|
|||||||
refresh_scene()
|
refresh_scene()
|
||||||
|
|
||||||
#Spawn Crown
|
#Spawn Crown
|
||||||
if SaveLoad.last_hit_path:
|
if GameGlobals.last_hit_path:
|
||||||
var crown_spawn = crown.instantiate()
|
var crown_spawn = crown.instantiate()
|
||||||
var crown_target = get_node(SaveLoad.last_hit_path)
|
var crown_target = get_node(GameGlobals.last_hit_path)
|
||||||
if crown_target:
|
if crown_target:
|
||||||
crown_target.add_child(crown_spawn)
|
crown_target.add_child(crown_spawn)
|
||||||
crown_spawn.position = Vector3(0,2,0)
|
crown_spawn.position = Vector3(0,2,0)
|
||||||
@@ -162,7 +162,7 @@ func die():
|
|||||||
instance_dead.transform.basis = player.global_transform.basis
|
instance_dead.transform.basis = player.global_transform.basis
|
||||||
if last_hit != null:
|
if last_hit != null:
|
||||||
instance_dead.target = last_hit
|
instance_dead.target = last_hit
|
||||||
SaveLoad.last_hit_path = str(last_hit.get_path())
|
GameGlobals.last_hit_path = str(last_hit.get_path())
|
||||||
instance_dead.target_type = target_type
|
instance_dead.target_type = target_type
|
||||||
instance_dead.respawn_position = respawn_position
|
instance_dead.respawn_position = respawn_position
|
||||||
instance_dead.respawn_rotation = respawn_cam_rotation
|
instance_dead.respawn_rotation = respawn_cam_rotation
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ var leaderboard_name = "Test"
|
|||||||
var playlist_test
|
var playlist_test
|
||||||
|
|
||||||
#Player Stats
|
#Player Stats
|
||||||
|
var player_deaths
|
||||||
|
var shots_fired
|
||||||
|
var last_hit_path
|
||||||
|
var enemies_killed = 0
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
SignalBus.money_deposited.connect(deposit_money)
|
SignalBus.money_deposited.connect(deposit_money)
|
||||||
|
|||||||
@@ -3,14 +3,18 @@ extends Node
|
|||||||
var last_scene
|
var last_scene
|
||||||
|
|
||||||
@onready var playlist_generator: Node = $PlaylistGenerator
|
@onready var playlist_generator: Node = $PlaylistGenerator
|
||||||
@onready var leaderboard_name: TextEdit = $MarginContainer/VBoxContainer/leaderboard_name
|
@onready var leaderboard_name: TextEdit = $MarginContainer/VBoxContainer/HBoxContainer/leaderboard_name
|
||||||
|
@onready var confirmed: CheckButton = $MarginContainer/VBoxContainer/HBoxContainer/Confirmed
|
||||||
|
|
||||||
|
func _enter_tree() -> void:
|
||||||
|
SaveLoad.load_persistent_data()
|
||||||
|
|
||||||
# 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() -> void:
|
func _ready() -> void:
|
||||||
SaveLoad.load_persistent_data()
|
confirmed.button_pressed = true
|
||||||
leaderboard_name.text = GameGlobals.leaderboard_name
|
leaderboard_name.text = GameGlobals.leaderboard_name
|
||||||
playlist_generator.load_playlist()
|
playlist_generator.load_playlist()
|
||||||
|
print("leaderboard : ",GameGlobals.leaderboard_name)
|
||||||
|
|
||||||
func _on_continue_pressed() -> void:
|
func _on_continue_pressed() -> void:
|
||||||
var level
|
var level
|
||||||
@@ -27,9 +31,15 @@ func _on_continue_pressed() -> void:
|
|||||||
level = GameGlobals.current_level
|
level = GameGlobals.current_level
|
||||||
load_to_gamemode = GameGlobals.current_gamemode
|
load_to_gamemode = GameGlobals.current_gamemode
|
||||||
|
|
||||||
|
SaveLoad.save_persistent_data()
|
||||||
|
|
||||||
get_tree().change_scene_to_file(level)
|
get_tree().change_scene_to_file(level)
|
||||||
GameGlobals.loading_gamemode = load(load_to_gamemode)
|
|
||||||
print("LEVEL : ",GameGlobals.current_level)
|
print("LEVEL : ",GameGlobals.current_level)
|
||||||
|
|
||||||
func _on_exit_pressed() -> void:
|
func _on_exit_pressed() -> void:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_leaderboard_name_text_changed() -> void:
|
||||||
|
GameGlobals.leaderboard_name = leaderboard_name.text
|
||||||
|
confirmed.button_pressed = false
|
||||||
|
|||||||
@@ -47,3 +47,7 @@ func resume():
|
|||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
player.toggle_hud(true)
|
player.toggle_hud(true)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_main_menu_pressed() -> void:
|
||||||
|
get_tree().change_scene_to_file("res://scenes/asset_checker.tscn")
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export var generate_playlist_now = false
|
@export var generate_playlist_now = false
|
||||||
|
@export var checksum_test = false
|
||||||
@export var load_playlist_from_file = false
|
@export var load_playlist_from_file = false
|
||||||
@export var maps_in_rotation : Array[String] = []
|
@export var maps_in_rotation : Array[String] = []
|
||||||
@export var gamemodes_in_rotation : Array[gamemode]= []
|
@export var gamemodes_in_rotation : Array[gamemode]= []
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
## SAVE DATA
|
## SAVE DATA
|
||||||
#PERSISTENT DATA
|
|
||||||
var last_hit_path
|
|
||||||
var player_deaths = 0
|
|
||||||
var enemies_killed = 0
|
|
||||||
var shots_fired = 0
|
|
||||||
|
|
||||||
#GAME DATA
|
#GAME DATA
|
||||||
var data_cleared
|
var data_cleared
|
||||||
@@ -23,53 +18,51 @@ var persistent_save_path = "user://persistent_data.save"
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
SignalBus.shot_fired.connect(shot_fired)
|
SignalBus.shot_fired.connect(shot_fired)
|
||||||
|
|
||||||
if player_deaths == null:
|
|
||||||
player_deaths = 0
|
|
||||||
if enemies_killed == null:
|
|
||||||
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(GameGlobals.last_hit_path))
|
||||||
file.store_var(last_hit_path)
|
#cache data before saving and creating checksum in case it changes between data saving and checksum generating
|
||||||
file.store_var(player.velocity)
|
var money = GameGlobals.money
|
||||||
|
var deposited_money = GameGlobals.deposited_money
|
||||||
|
var health = GameGlobals.health
|
||||||
|
var high_score = GameGlobals.high_score
|
||||||
|
var player_deaths = GameGlobals.player_deaths
|
||||||
|
var shots_fired = GameGlobals.shots_fired
|
||||||
|
|
||||||
|
file.store_var(GameGlobals.last_hit_path)
|
||||||
file.store_var(GameGlobals.leaderboard_name)
|
file.store_var(GameGlobals.leaderboard_name)
|
||||||
file.store_var(get_tree().current_scene.scene_file_path)
|
file.store_var(get_tree().current_scene.scene_file_path)
|
||||||
file.store_var(get_tree().current_scene.gamemode.resource_path)
|
file.store_var(money)
|
||||||
file.store_var(GameGlobals.money)
|
file.store_var(deposited_money)
|
||||||
file.store_var(GameGlobals.deposited_money)
|
file.store_var(health)
|
||||||
file.store_var(GameGlobals.health)
|
file.store_var(high_score)
|
||||||
file.store_var(GameGlobals.high_score)
|
|
||||||
file.store_var(player_deaths)
|
file.store_var(player_deaths)
|
||||||
file.store_var(enemies_killed)
|
file.store_var(GameGlobals.enemies_killed)
|
||||||
file.store_var(shots_fired)
|
file.store_var(shots_fired)
|
||||||
var held_guns = save_resource_path(GameGlobals.held_guns)
|
var held_guns = save_resource_path(GameGlobals.held_guns)
|
||||||
file.store_var(held_guns)
|
file.store_var(held_guns)
|
||||||
file.store_var(GameGlobals.gun_ammo)
|
file.store_var(GameGlobals.gun_ammo)
|
||||||
file.store_var(GameGlobals.ammo_reserve)
|
file.store_var(GameGlobals.ammo_reserve)
|
||||||
file.store_var(GameGlobals.current_gun_index)
|
file.store_var(GameGlobals.current_gun_index)
|
||||||
file.store_var(data_cleared)
|
var check_data = [money,deposited_money,health,high_score,player_deaths,shots_fired]
|
||||||
|
file.store_var(HelperFuncs.checksum(check_data))
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
func load_persistent_data():
|
func load_persistent_data():
|
||||||
var level_control = get_tree().current_scene
|
|
||||||
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()
|
GameGlobals.last_hit_path = file.get_var()
|
||||||
player_velocity_cache = file.get_var()
|
|
||||||
GameGlobals.leaderboard_name = file.get_var()
|
GameGlobals.leaderboard_name = file.get_var()
|
||||||
GameGlobals.current_level = str(file.get_var())
|
GameGlobals.current_level = str(file.get_var())
|
||||||
GameGlobals.current_gamemode = file.get_var()
|
var money = set_nulls_zero(file.get_var())
|
||||||
GameGlobals.money = set_nulls_zero(file.get_var())
|
var deposited_money = set_nulls_zero(file.get_var())
|
||||||
GameGlobals.deposited_money = set_nulls_zero(file.get_var())
|
var health = file.get_var()
|
||||||
GameGlobals.health = file.get_var()
|
var high_score = file.get_var()
|
||||||
GameGlobals.high_score = file.get_var()
|
var player_deaths = set_nulls_zero(file.get_var())
|
||||||
player_deaths = set_nulls_zero(file.get_var())
|
GameGlobals.enemies_killed = set_nulls_zero(file.get_var())
|
||||||
enemies_killed = set_nulls_zero(file.get_var())
|
var shots_fired = set_nulls_zero(file.get_var())
|
||||||
shots_fired = set_nulls_zero(file.get_var())
|
|
||||||
|
|
||||||
|
|
||||||
var held_guns_encoded = file.get_var()
|
var held_guns_encoded = file.get_var()
|
||||||
@@ -81,13 +74,15 @@ func load_persistent_data():
|
|||||||
if !get_tree().current_scene.is_in_group("ui"):
|
if !get_tree().current_scene.is_in_group("ui"):
|
||||||
get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index)
|
get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index)
|
||||||
|
|
||||||
data_cleared = file.get_var()
|
var checksum = file.get_var()
|
||||||
|
var check_data = [money,deposited_money,health,high_score,player_deaths,shots_fired]
|
||||||
|
if checksum == HelperFuncs.checksum(check_data):
|
||||||
|
print("DATA VALID") #APPLY DATA AFTER
|
||||||
|
else:
|
||||||
|
print("DATA NOT VALID")
|
||||||
file.close()
|
file.close()
|
||||||
else:
|
else:
|
||||||
print("no data saved...")
|
print("no data saved...")
|
||||||
last_hit_path = null
|
|
||||||
player_deaths = null
|
|
||||||
enemies_killed = null
|
|
||||||
|
|
||||||
|
|
||||||
func save_game_data(level_name):
|
func save_game_data(level_name):
|
||||||
@@ -229,4 +224,4 @@ func load_resource_path(array):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
func shot_fired():
|
func shot_fired():
|
||||||
shots_fired += 1 #null_data_check(shots_fired, 1)
|
GameGlobals.shots_fired += 1 #null_data_check(shots_fired, 1)
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ func _ready() -> void:
|
|||||||
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)
|
high_score.text = str("HIGH SCORE : $",GameGlobals.high_score)
|
||||||
kills.text = "Kills : " + str(SaveLoad.enemies_killed)
|
kills.text = "Kills : " + str(GameGlobals.enemies_killed)
|
||||||
deaths.text = "Deaths : " + str(SaveLoad.player_deaths)
|
deaths.text = "Deaths : " + str(GameGlobals.player_deaths)
|
||||||
shots_fired.text = "Shots Fired : " + str(SaveLoad.shots_fired)
|
shots_fired.text = "Shots Fired : " + str(GameGlobals.shots_fired)
|
||||||
|
|||||||
Reference in New Issue
Block a user