打包1.4

This commit is contained in:
2025-11-04 00:37:25 +08:00
parent ffd6a01587
commit cbc67120fa
13 changed files with 19486 additions and 18472 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Core;
using UnityEngine;
@@ -45,15 +46,19 @@ namespace Script.Gameplay.Global
private void Start()
{
OnBugHappenedInArea.AddListener(() =>
{
GameManager.Instance.EndGameplay();
Debug.Log("天核区域内检测到BUG立方体");
});
OnBugHappenedInArea.AddListener(() => { StartCoroutine(EndGame()); });
GameManager.Instance.OnGameStart += GenerateBugCubes;
}
private IEnumerator EndGame()
{
// 触发游戏结束,先等待3秒防止场景未加载
yield return new WaitForSeconds(3.0f);
GameManager.Instance.EndGameplay();
Debug.Log("天核区域内检测到BUG立方体");
}
public void LogStackOverflowBug(Transform targetTransform)
{
@@ -67,6 +72,7 @@ namespace Script.Gameplay.Global
{
Destroy(bugCube);
}
bugCubes.Clear();
int currentCycle = GameDataManager.Instance.TotalLoopCount;

View File

@@ -32,6 +32,7 @@ namespace Script.Gameplay.Global
public void EndGameplay()
{
ScenesManager.Instance.LoadGameplay("End");
currentStartGameMode = "End";
}
public IEnumerator ReStartGame()

View File

@@ -18,7 +18,7 @@ namespace Script.Gameplay.Global
// 修正:只有当已有记录的 gameplay 场景且激活场景与之匹配时才返回 true
public bool IsInGameplay =>
currentGameplayScene == "Level1" || currentGameplayScene == "Test";
currentGameplayScene == "Level1" || currentGameplayScene == "Test" || currentGameplayScene == "End";
public bool IsActiveScene(string sceneName)
{
@@ -27,6 +27,8 @@ namespace Script.Gameplay.Global
public bool IsSceneLoaded(string sceneName)
{
if (string.IsNullOrEmpty(sceneName))
return false;
return SceneManager.GetSceneByName(sceneName).isLoaded;
}
@@ -68,12 +70,22 @@ namespace Script.Gameplay.Global
yield return LoadSceneAdditive(newScene);
currentGameplayScene = newScene;
// 可选:将新场景设置为激活场景
SceneManager.SetActiveScene(SceneManager.GetSceneByName(newScene));
var scene = SceneManager.GetSceneByName(newScene);
if (scene.IsValid())
{
SceneManager.SetActiveScene(scene);
}
}
private IEnumerator LoadSceneAdditive(string sceneName)
{
if (string.IsNullOrEmpty(sceneName))
yield break;
var async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
if (async == null)
yield break;
while (!async.isDone)
{
yield return null;
@@ -82,7 +94,17 @@ namespace Script.Gameplay.Global
private IEnumerator UnloadScene(string sceneName)
{
if (string.IsNullOrEmpty(sceneName))
yield break;
var scene = SceneManager.GetSceneByName(sceneName);
if (!scene.IsValid() || !scene.isLoaded)
yield break;
var async = SceneManager.UnloadSceneAsync(sceneName);
if (async == null)
yield break;
while (!async.isDone)
{
yield return null;
@@ -96,6 +118,8 @@ namespace Script.Gameplay.Global
if (IsSceneLoaded(sceneName))
{
var async = SceneManager.UnloadSceneAsync(sceneName);
if (async == null)
continue;
while (!async.isDone)
{
yield return null;
@@ -106,7 +130,12 @@ namespace Script.Gameplay.Global
public void QuitGame()
{
var scenesToUnload = new List<string> { "UIScene", currentGameplayScene };
var scenesToUnload = new List<string>();
if (isLoadGameplayUI)
scenesToUnload.Add("UIScene");
if (!string.IsNullOrEmpty(currentGameplayScene))
scenesToUnload.Add(currentGameplayScene);
StartCoroutine(QuitAndUnload(scenesToUnload));
}
@@ -120,11 +149,11 @@ namespace Script.Gameplay.Global
Destroy(InputManager.Instance.gameObject);
}
#if UNITY_EDITOR
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
#else
Application.Quit();
#endif
}
}
}
}