加入用户最近100场战绩记录并实现展示

This commit is contained in:
FloatGaming
2026-03-16 23:18:58 +08:00
parent ec42f2e34b
commit f5c6f143c0
106 changed files with 12120 additions and 642 deletions
@@ -0,0 +1,57 @@
using System.Collections.Generic;
using UnityEngine;
public static class RecentPlayHistoryStore
{
private const string Category = "recent_play_history";
private const string Key = "runs_v1";
private const int MaxRecordCount = 100;
public static IReadOnlyList<RecentPlayRecord> GetRecords()
{
return LoadPayload().records;
}
public static void Push(RecentPlayRecord record)
{
if (record == null)
{
return;
}
var payload = LoadPayload();
if (payload.records == null)
{
payload.records = new List<RecentPlayRecord>();
}
payload.records.Insert(0, record);
if (payload.records.Count > MaxRecordCount)
{
payload.records.RemoveRange(MaxRecordCount, payload.records.Count - MaxRecordCount);
}
SecureSaveVault.SaveJson(Category, Key, payload);
}
public static void Clear()
{
SecureSaveVault.Delete(Category, Key);
}
private static RecentPlayHistoryPayload LoadPayload()
{
RecentPlayHistoryPayload payload;
if (!SecureSaveVault.TryLoadJson(Category, Key, out payload) || payload == null)
{
payload = new RecentPlayHistoryPayload();
}
if (payload.records == null)
{
payload.records = new List<RecentPlayRecord>();
}
return payload;
}
}