feat(): 完成将Manager从Gameplay转移到Core,实现循环次数持久化,实现设置面板
This commit is contained in:
27
Assets/Script/Gameplay/Global/GameDataManager.cs
Normal file
27
Assets/Script/Gameplay/Global/GameDataManager.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager.Instance.OnGameStart += AddLoop;
|
||||
// 读取已保存的循环次数
|
||||
TotalLoopCount = PlayerPrefs.GetInt(LoopCountKey, 0);
|
||||
Debug.Log("目前循环次数:" + TotalLoopCount);
|
||||
}
|
||||
|
||||
public void AddLoop()
|
||||
{
|
||||
TotalLoopCount++;
|
||||
PlayerPrefs.SetInt(LoopCountKey, TotalLoopCount);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Script/Gameplay/Global/GameDataManager.cs.meta
Normal file
3
Assets/Script/Gameplay/Global/GameDataManager.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a768588a5a1e4d7f8d54f8d16b0f4bb0
|
||||
timeCreated: 1761362127
|
||||
@@ -19,23 +19,24 @@ namespace Script.Gameplay.Global
|
||||
public class GameFlowManager : MonoSingleton<GameFlowManager>
|
||||
{
|
||||
public bool IsOpenRestartGameOnCountdownFinish = true;
|
||||
|
||||
private GameCountdownManager _gameCountdownManager;
|
||||
private void Start()
|
||||
{
|
||||
GameCountdownManager.Instance.StartLevelTimer();
|
||||
GameCountdownManager.Instance.OnFinish.AddListener(() =>
|
||||
_gameCountdownManager = GameCountdownManager.Instance;
|
||||
_gameCountdownManager.StartLevelTimer();
|
||||
_gameCountdownManager.OnFinish.AddListener(() =>
|
||||
{
|
||||
if (IsOpenRestartGameOnCountdownFinish)
|
||||
StartCoroutine(RestartGame());
|
||||
StartCoroutine(OnCountDown());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public IEnumerator RestartGame()
|
||||
public IEnumerator OnCountDown()
|
||||
{
|
||||
StartCoroutine(ScreenGlitchManager.Instance.TriggerGlitchEffect());
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
GameManager.Instance.ReStartGame();
|
||||
GameManager.Instance.ReStartGameplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user