好多新内容

This commit is contained in:
2026-07-22 05:35:53 +08:00
parent b5d1cdcbc5
commit 15649d02f8
128 changed files with 5956 additions and 673 deletions
@@ -1,13 +1,18 @@
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using TMPro;
using System.IO;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using TMPro;
using UnityEngine.SceneManagement;
using Bansonic;
public class BeatmapManager : MonoBehaviour
{
private static readonly bool VerboseLogs = false;
private const string MissingSongDataFallbackScene = "selectYourSongFirst";
public static BeatmapManager Instance { get; private set; }
private bool missingSongDataRedirectStarted;
private void Awake()
{
@@ -315,25 +320,43 @@ public class BeatmapManager : MonoBehaviour
void Start()
{
// 如果 assignedSongData 为空,尝试从 SongDataHolder 获取,作为最后的兜底
if (pendingSongData == null && assignedSongData == null)
{
assignedSongData = SongDataHolder.SelectedSongData;
if (pendingSongData == null && assignedSongData == null)
{
assignedSongData = SongDataHolder.SelectedSongData;
if (VerboseLogs) Debug.Log($"[BeatmapManager] No pending song, fallback to SongDataHolder: {(assignedSongData != null ? assignedSongData.songName : "null")}");
}
}
if (!GameConfig.testMode && pendingSongData == null && assignedSongData == null)
{
RedirectToSongSelectForMissingSongData("no pending SongData and no assigned SongData");
return;
}
// 无论如何,在加载谱面前先同步敌人编队到 teamUIController
SyncEnemyListToUI();
if (pendingSongData != null)
{
if (VerboseLogs) Debug.Log($"BeatmapManager.Start: pendingSongData detected: {pendingSongData.songName}, difficulty={pendingDifficulty}");
// Documentation text normalized.
assignedSongData = pendingSongData;
assignedDifficulty = pendingDifficulty;
// Documentation text normalized.
bool ok = LoadBeatmapFromSongData(assignedSongData, assignedDifficulty, true);
if (!ok) Debug.LogWarning("BeatmapManager.Start: LoadBeatmapFromSongData failed");
if (pendingSongData != null || assignedSongData != null)
{
SongData startupSongData = pendingSongData != null ? pendingSongData : assignedSongData;
int startupDifficulty = ResolveStartupDifficulty(startupSongData, pendingSongData != null ? pendingDifficulty : assignedDifficulty);
if (VerboseLogs) Debug.Log($"BeatmapManager.Start: startup SongData detected: {startupSongData.songName}, difficulty={startupDifficulty}");
// Documentation text normalized.
assignedSongData = startupSongData;
assignedDifficulty = startupDifficulty;
// Documentation text normalized.
bool ok = LoadBeatmapFromSongData(assignedSongData, assignedDifficulty, true);
if (!ok)
{
Debug.LogWarning("BeatmapManager.Start: LoadBeatmapFromSongData failed");
pendingSongData = null;
pendingDifficulty = -1;
if (!GameConfig.testMode)
{
RedirectToSongSelectForMissingSongData("SongData exists but chart load failed");
return;
}
}
else
{
if (VerboseLogs) Debug.Log("BeatmapManager.Start: chart parsed from SongData, attempting to assign audio and pause system");
@@ -438,12 +461,82 @@ public class BeatmapManager : MonoBehaviour
if (VerboseLogs) Debug.Log("Default automatic demo beatmap load is commented out to prioritize SO-provided charts.");
}
UpdateGameplayUI();
}
private void UpdateGameplayUI()
{
UpdateGameplayUI();
}
private int ResolveStartupDifficulty(SongData song, int requestedDifficulty)
{
if (requestedDifficulty >= 0)
{
return requestedDifficulty;
}
if (song != null)
{
int selectedDifficulty = Mathf.Clamp(song.thisLevel_selectedDifficultyID, 0, 3);
if (song.GetResolvedChartFile(selectedDifficulty) != null)
{
return selectedDifficulty;
}
int songDifficulty = Mathf.Clamp(song.difficultyID, 0, 3);
if (song.GetResolvedChartFile(songDifficulty) != null)
{
return songDifficulty;
}
}
if (song != null && song.chartFiles != null)
{
for (int i = 0; i < song.chartFiles.Count; i++)
{
ChartFileEntry entry = song.chartFiles[i];
if (entry != null && entry.chartFile != null)
{
return entry.difficulty;
}
}
}
return 0;
}
private void RedirectToSongSelectForMissingSongData(string reason)
{
if (missingSongDataRedirectStarted)
{
return;
}
missingSongDataRedirectStarted = true;
Debug.LogWarning($"[BeatmapManager] Missing valid SongData ({reason}). Returning to {MissingSongDataFallbackScene}.");
try { Time.timeScale = 1f; } catch { }
StartCoroutine(LoadMissingSongDataFallbackScene());
}
private IEnumerator LoadMissingSongDataFallbackScene()
{
yield return null;
if (gTransition.LoadScene(MissingSongDataFallbackScene, LoadSceneMode.Single))
{
while (gTransition.IsBusy)
{
yield return null;
}
yield break;
}
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(MissingSongDataFallbackScene, LoadSceneMode.Single);
while (asyncLoad != null && !asyncLoad.isDone)
{
yield return null;
}
}
private void UpdateGameplayUI()
{
if (assignedSongData == null) return;
if (gameplay_songname != null)