fix():修复重启时花屏效果未关闭的BUG

This commit is contained in:
2025-10-27 22:13:55 +08:00
parent 4951f25187
commit 5e30e6412a
13 changed files with 6261 additions and 5368 deletions

View File

@@ -43,7 +43,7 @@ namespace Script.Gameplay.Global
{
int beTriggerCycle = GameDataManager.Instance.TotalLoopCount;
stackOverflowBugLogs.Add(new StackOverflowBUGLog(targetTransform, beTriggerCycle));
GameManager.Instance.ReStartGame();
StartCoroutine(GameManager.Instance.ReStartGame());
}
public void GenerateBUGCubes()

View File

@@ -27,7 +27,7 @@ namespace Script.Gameplay.Global
_gameCountdownManager.OnFinish.AddListener(() =>
{
if (IsOpenRestartGameOnCountdownFinish)
StartCoroutine(OnCountDown());
StartCoroutine(GameManager.Instance.ReStartGame());
}
);
}
@@ -36,12 +36,5 @@ namespace Script.Gameplay.Global
{
_gameCountdownManager.StartLevelTimer();
}
public IEnumerator OnCountDown()
{
StartCoroutine(ScreenGlitchManager.Instance.TriggerGlitchEffect());
yield return new WaitForSeconds(1.0f);
GameManager.Instance.ReStartGame();
}
}
}

View File

@@ -1,6 +1,9 @@
using System;
using System.Collections;
using Core;
using UnityEngine;
namespace Script.Gameplay.Global
{
public class GameManager : MonoSingleton<GameManager>
@@ -26,8 +29,10 @@ namespace Script.Gameplay.Global
OnGameStart?.Invoke();
}
public void ReStartGame()
public IEnumerator ReStartGame()
{
StartCoroutine(ScreenGlitchManager.Instance.TriggerGlitchEffect());
yield return new WaitForSeconds(1.0f);
ScenesManager.Instance.LoadGameplay(currentStartGameMode);
OnGameStart?.Invoke();
}

View File

@@ -45,5 +45,12 @@ namespace Script.Gameplay.Global
yield return new WaitForSeconds(glitchDuration);
SetFeatureActive(false);
}
protected override void OnDestroy()
{
base.OnDestroy();
// 确保在销毁时禁用特效
SetFeatureActive(false);
}
}
}

View File

@@ -41,7 +41,7 @@ namespace Script.Gameplay.Player
private void Start()
{
OnDeath += () => StartCoroutine(GameFlowManager.Instance.OnCountDown());
OnDeath += () => StartCoroutine(GameManager.Instance.ReStartGame());
}
public void TakeDamage(int damage)

View File

@@ -27,50 +27,32 @@ namespace UI
{
base.Start();
inputManager = InputManager.Instance;
inputManager.Input.Player.Setting.performed += (ctx) => { UIManager.Instance.SwitchUI<SettingViewer>(); };
inputManager.Input.Player.Setting.performed += OnSettingOnperformed;
}
private void OnSettingOnperformed(InputAction.CallbackContext ctx)
{
UIManager.Instance.SwitchUI<SettingViewer>();
}
private void OnReloadButtonClicked()
{
GameManager.Instance.ReStartGame();
ContentText.text = "循环次数:" + GameDataManager.Instance.TotalLoopCount.ToString();
inputManager.SetCursorState(false, CursorLockMode.Locked);
inputManager.SetInputForLook(true);
inputManager.SetInputForMove(true);
StartCoroutine(GameManager.Instance.ReStartGame());
}
private void RegisterInput(InputAction.CallbackContext ctx)
{
if (!isActiveAndEnabled)
{
Show();
inputManager.SetCursorState(true, CursorLockMode.Confined);
inputManager.SetInputForLook(false);
inputManager.SetInputForMove(false);
}
else
{
Hide();
inputManager.SetCursorState(false, CursorLockMode.Locked);
inputManager.SetInputForLook(true);
inputManager.SetInputForMove(true);
}
}
public override void Show()
{
base.Show();
ContentText.text = "循环次数:" + GameDataManager.Instance.TotalLoopCount.ToString();
}
private void OnDestroy()
{
inputManager.Input.Player.Setting.performed -= OnSettingOnperformed;
}
public override void Hide()
{
base.Hide();
}
private void OnDestroy()
{
inputManager.Input.Player.Setting.performed -= RegisterInput;
}
}
}