32 lines
847 B
C#
32 lines
847 B
C#
using Core;
|
|
using Script.Gameplay.Input;
|
|
using UnityEngine;
|
|
|
|
namespace Script.Gameplay.Global
|
|
{
|
|
public class GameDataManager : MonoSingleton<GameDataManager>
|
|
{
|
|
private const string LoopCountKey = "TotalLoopCount";
|
|
public int TotalLoopCount { get; private set; }
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
// 读取已保存的循环次数
|
|
TotalLoopCount = PlayerPrefs.GetInt(LoopCountKey, 0);
|
|
Debug.Log("目前循环次数:" + TotalLoopCount);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
GameManager.Instance.OnGameStart += AddLoop;
|
|
}
|
|
|
|
public void AddLoop()
|
|
{
|
|
TotalLoopCount++;
|
|
PlayerPrefs.SetInt(LoopCountKey, TotalLoopCount);
|
|
PlayerPrefs.Save();
|
|
}
|
|
}
|
|
} |