Added indexes saving
This commit is contained in:
+19
-18
@@ -13,7 +13,7 @@ const PARAMETER_GAME_SECTOR_INDEX = "current_sector_index"
|
||||
|
||||
var _save_file: ConfigFile
|
||||
|
||||
var _game_data : GameData
|
||||
var game_data : GameData
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -21,42 +21,43 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func save() -> void:
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_SEED, _game_data.game_seed)
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, _game_data.current_area_index)
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, _game_data.current_stage_index)
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, _game_data.current_sector_index)
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_SEED, game_data.game_seed)
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, game_data.current_area_index)
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, game_data.current_stage_index)
|
||||
_save_file.set_value(CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, game_data.current_sector_index)
|
||||
|
||||
_save_file.save_encrypted_pass(SAVE_FILE, SAVE_FILE_PASS)
|
||||
|
||||
|
||||
func new_game() -> void:
|
||||
_game_data.randomize()
|
||||
game_data.randomize()
|
||||
|
||||
|
||||
func get_game_data() -> GameData:
|
||||
return _game_data
|
||||
func delete_game_data() -> void:
|
||||
game_data = GameData.new()
|
||||
save()
|
||||
|
||||
|
||||
func _load() -> void:
|
||||
_save_file = ConfigFile.new()
|
||||
_game_data = GameData.new()
|
||||
game_data = GameData.new()
|
||||
|
||||
if _save_file.load_encrypted_pass(SAVE_FILE, SAVE_FILE_PASS) == OK:
|
||||
_process_save_file()
|
||||
|
||||
|
||||
save()
|
||||
|
||||
|
||||
func _process_save_file() -> void:
|
||||
_game_data.game_seed = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_SEED, _game_data.game_seed
|
||||
game_data.game_seed = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_SEED, game_data.game_seed
|
||||
)
|
||||
_game_data.current_area_index = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, _game_data.current_area_index
|
||||
game_data.current_area_index = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, game_data.current_area_index
|
||||
)
|
||||
_game_data.current_stage_index = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, _game_data.current_stage_index
|
||||
game_data.current_stage_index = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, game_data.current_stage_index
|
||||
)
|
||||
_game_data.current_sector_index = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, _game_data.current_sector_index
|
||||
game_data.current_sector_index = _save_file.get_value(
|
||||
CATEGORY_GAME, PARAMETER_GAME_AREA_INDEX, game_data.current_sector_index
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user