You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB
C#

2 weeks ago
2 weeks ago
// Introduce your new variables under Game Variables and pass them accordingly
// in the Constructor => SaveData();
using UnityEngine;
using Sirenix.OdinInspector;
public sealed class SaveData
{
//===================================================
// PRIVATE FIELDS
//===================================================
private static SaveData _instance = null;
//===================================================
// PROPERTIES
//===================================================
public static SaveData Instance
{
get
{
if(_instance is null)
{
_instance = new SaveData();
SaveSystem.LoadProgress();
}//if end
return _instance;
}//get end
}//Property end
public bool HasID => !string.IsNullOrEmpty(UserData._id);
//===================================================
// FIELDS
//===================================================
[Title("Game Settings")]
[DisplayAsString]
public bool Music = true;
[DisplayAsString]
public bool SFX = true;
[DisplayAsString]
public bool Haptic = true;
[DisplayAsString]
public int Level = 1;
[Space]
[Title("Game Values")]
public UserData UserData = new();
[HideInInspector]
public string HashOfSaveData = null;
public SaveData(){}
private SaveData(SaveData data)
{
Music = data.Music;
SFX = data.SFX;
Haptic = data.Haptic;
UserData = data.UserData;
Level = data.Level;
}//CopyConstructor() end
public SaveData CreateSaveObject() => new(_instance);
public void Reset() => _instance = new();
}//class end