Exemplo n.º 1
0
    public static void Save(JSON json, string fileName, int encriptionKey = 0)
    {
        if (!json.ContainsKey(VersionKey))
        {
            throw new Exception("File without version code");
        }

        if (json.GetInt(VersionKey) > CurrentVersion)
        {
            throw new Exception("File version is newer than this one");
        }

        if (json.GetInt(VersionKey) < CurrentVersion)
        {
            UpdateSave(ref json);
        }

        Debug.Log(json.CreatePrettyString());

        string rawData = json.CreatePrettyString();

        if (encriptionKey != 0)
        {
            rawData = SecureHelper.EncryptDecrypt(rawData, encriptionKey);
        }

        SaveLoadManager.SaveText(fileName, rawData);
    }
Exemplo n.º 2
0
    public void Load()
    {
        data = new GameData();
        string json = ReadFromFile(file);

        json = SecureHelper.EncryptDecrypt(json, key);
        JsonUtility.FromJsonOverwrite(json, data);
    }
Exemplo n.º 3
0
    public static void SaveEncryptedJson(JSON json, string fileName, int encriptionKey = 0)
    {
        string rawData = json.CreatePrettyString();

        if (encriptionKey != 0)
        {
            rawData = SecureHelper.EncryptDecrypt(rawData, encriptionKey);
        }
        SaveLoadManager.SaveText(fileName, rawData);
    }
Exemplo n.º 4
0
    public static JSON LoadEncryptedJson(string fileName, int encriptionKey = 0)
    {
        Debug.Log($"Loading: {fileName}");
        string rawData = SaveLoadManager.LoadText(fileName);

        if (encriptionKey != 0)
        {
            rawData = SecureHelper.EncryptDecrypt(rawData, encriptionKey);
        }
        JSON data = JSON.ParseString(rawData);

        return(data);
    }
Exemplo n.º 5
0
    public static JSON Load(string fileName, int encriptionKey = 0)
    {
        string rawData = SaveLoadManager.LoadText(fileName);

        if (encriptionKey != 0)
        {
            rawData = SecureHelper.EncryptDecrypt(rawData, encriptionKey);
        }
        JSON data = JSON.ParseString(rawData);

        if (data.GetInt(VersionKey) < CurrentVersion)
        {
            UpdateSave(ref data);
        }
        return(data);
    }
Exemplo n.º 6
0
    public void Save()
    {
        string json = JsonUtility.ToJson(data, true);

        WriteToFile(file, SecureHelper.EncryptDecrypt(json, key));
    }