Files
bansonic_beta_main/Assets/scripts/dailyTask/DailyTaskSaveService.cs
T

51 lines
1.2 KiB
C#

using System;
using System.IO;
using UnityEngine;
public static class DailyTaskSaveService
{
private const string SaveCategory = "daily_task";
private const string SaveKey = "runtime";
private static string LegacySaveFilePath
{
get { return Path.Combine(Application.persistentDataPath, "daily_tasks.json"); }
}
public static DailyTaskSaveData Load()
{
try
{
DailyTaskSaveData data;
if (SecureSaveVault.TryLoadJson(SaveCategory, SaveKey, out data, LegacySaveFilePath))
{
return data ?? new DailyTaskSaveData();
}
return new DailyTaskSaveData();
}
catch (Exception ex)
{
Debug.LogWarning($"[DailyTaskSaveService] Load failed: {ex.Message}");
return new DailyTaskSaveData();
}
}
public static void Save(DailyTaskSaveData data)
{
if (data == null)
{
return;
}
try
{
SecureSaveVault.SaveJson(SaveCategory, SaveKey, data, LegacySaveFilePath);
}
catch (Exception ex)
{
Debug.LogWarning($"[DailyTaskSaveService] Save failed: {ex.Message}");
}
}
}