成就系统 巨大修改 新的ui 黑白效果 等一堆

This commit is contained in:
FloatGaming
2026-01-23 18:43:23 +08:00
parent f3ece026ca
commit 0e47864569
256 changed files with 134131 additions and 31192 deletions
@@ -36,14 +36,19 @@ public class BeatmapManager : MonoBehaviour
Debug.LogWarning($"BeatmapManager.AcceptSongData: accepted song={(song==null?"NULL":song.songName)}, difficulty={difficulty}");
}
public Beatmap beatmap; // 当前谱面数据
public Beatmap beatmap; // ǰ
// 音符生成器引用
//
public NoteSpawner noteSpawner;
// teamUIController 引用,直接拖拽赋值
// teamUIController ãֱקֵ
public teamUIController uiController;
public Image bgSpriteImage; // ͼƬ
public GameObject bgSpriteObject;
public Image startCanvas_image;
// Extra fields from beatmap JSON (stored temporarily)
[HideInInspector] public string parsedTitle;
[HideInInspector] public string parsedComposer;
@@ -77,7 +82,7 @@ public class BeatmapManager : MonoBehaviour
public float imMultiplier = 3f;
[Header("HP Calculation Settings")]
[Tooltip("Scales the note amount to enemy HP. Example: NoteAmount * MaxMultiplier * BaseScale TotalHP")]
[Tooltip("Scales the note amount to enemy HP. Example: NoteAmount * MaxMultiplier * BaseScale TotalHP")]
public float baseHpUnitScale = 1f;
// Total chart score and per-note score fields
@@ -85,23 +90,23 @@ public class BeatmapManager : MonoBehaviour
public int perNoteScore;
public int leftoverScore;
// JSON 文件加载谱面数据
// JSON ļ
public void LoadBeatmap(string fileName)
{
string path = Application.streamingAssetsPath + "/" + fileName;
if (File.Exists(path))
{
string json = File.ReadAllText(path);
Debug.Log("谱面 JSON 已读取: " + path);
Debug.Log(" JSON Ѷȡ: " + path);
ProcessJsonAndLoad(json);
}
else
{
Debug.LogError("文件不存在:" + path);
Debug.LogError("ļڣ" + path);
}
}
// 从原始 JSON 字符串加载谱面(允许任意磁盘路径先读取后传入)
// ԭʼ JSON ַ·ȶȡ
public void LoadBeatmapFromJsonString(string json)
{
if (string.IsNullOrEmpty(json))
@@ -112,7 +117,7 @@ public class BeatmapManager : MonoBehaviour
ProcessJsonAndLoad(json);
}
// 解析 JSON 但不启动 NoteSpawner(用于 test mode 的延迟开始)
// JSON NoteSpawner test mode ӳٿʼ
public bool ParseJsonOnly(string json)
{
if (string.IsNullOrEmpty(json))
@@ -129,13 +134,13 @@ public class BeatmapManager : MonoBehaviour
}
catch (System.Exception ex)
{
Debug.LogError($"ParseJsonOnly 解析 Beatmap 失败: {ex}");
Debug.LogError($"ParseJsonOnly Beatmap ʧ: {ex}");
return false;
}
if (parsed == null)
{
Debug.LogError("ParseJsonOnly: 解析 Beatmap 返回 null");
Debug.LogError("ParseJsonOnly: Beatmap null");
return false;
}
@@ -203,22 +208,22 @@ public class BeatmapManager : MonoBehaviour
beatmap = parsed;
Debug.Log("ParseJsonOnly: parsed beatmap " + beatmap.title);
// 调用统一的敌人处理逻辑(包含 HP 计算和设置)
// ͳһĵ˴߼ HP ã
SetupEnemiesAndHP();
return true;
}
// 直接传入已经解析的 Beatmap(兼容旧调用)
// ֱӴѾ Beatmapݾɵã
public void LoadBeatmap(Beatmap loadedBeatmap)
{
beatmap = loadedBeatmap;
Debug.Log("谱面已加载(来自 Beatmap 对象):" + (beatmap != null ? beatmap.title : "null"));
Debug.Log("Ѽأ Beatmap 󣩣" + (beatmap != null ? beatmap.title : "null"));
// No globalDelaySeconds available in this path. Call NoteSpawner directly.
noteSpawner.LoadBeatmap(beatmap);
}
// 读取并加载当前谱面到音符生成器(备用)
// ȡصǰã
public void LoadBeatmapFromFile()
{
string path = Application.streamingAssetsPath + "/Emilia_demo.json";
@@ -229,11 +234,11 @@ public class BeatmapManager : MonoBehaviour
}
else
{
Debug.LogError("谱面文件未找到!");
Debug.LogError("ļδҵ");
}
}
// 新增:从 TextAsset 解析并根据 parseOnly 决定是否只是解析或直接加载
// TextAsset parseOnly ǷֻǽֱӼ
public bool LoadBeatmapFromTextAsset(TextAsset chartAsset, bool parseOnly = false)
{
if (chartAsset == null)
@@ -257,7 +262,7 @@ public class BeatmapManager : MonoBehaviour
}
}
// 新增:从 SongData chart TextAsset 加载谱面
// SongData chart TextAsset
public bool LoadBeatmapFromSongData(SongData song, int difficulty, bool parseOnly = false)
{
if (song == null)
@@ -275,18 +280,18 @@ public class BeatmapManager : MonoBehaviour
return LoadBeatmapFromTextAsset(ta, parseOnly);
}
// Start() 方法中初始化
// Start() гʼ
void Start()
{
// 被动接收上一个场景传递过来的 SongData(通过 BeatmapManager.pendingSongData
// һݹ SongDataͨ BeatmapManager.pendingSongData
if (pendingSongData != null)
{
Debug.LogWarning($"BeatmapManager.Start: pendingSongData detected: {pendingSongData.songName}, difficulty={pendingDifficulty}");
// pending 显示到 Inspector 字段,便于检查
// pending ʾ Inspector ֶΣڼ
assignedSongData = pendingSongData;
assignedDifficulty = pendingDifficulty;
// 尝试解析(只解析,不立即生成音符)
// Խֻ
bool ok = LoadBeatmapFromSongData(assignedSongData, assignedDifficulty, true);
if (!ok) Debug.LogWarning("BeatmapManager.Start: LoadBeatmapFromSongData failed");
else
@@ -328,6 +333,41 @@ public class BeatmapManager : MonoBehaviour
Debug.LogWarning("GameManager or its musicSource not found; audio not assigned");
}
// Assign fullscreen image from SongData to bgSprite if available
if (assignedSongData != null && assignedSongData.fullscreen_songPicture != null)
{
// Prefer setting a Scene GameObject's SpriteRenderer if provided
if (bgSpriteObject != null)
{
var sr = bgSpriteObject.GetComponentInChildren<SpriteRenderer>();
if (sr != null)
{
sr.sprite = assignedSongData.fullscreen_songPicture;
// ensure fully visible
sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, 1f);
if (startCanvas_image != null)
{
startCanvas_image.sprite = assignedSongData.fullscreen_songPicture;
}
sr = null;
Debug.LogWarning($"Assigned SongData.fullscreen_songPicture to SpriteRenderer on bgSpriteObject for song {assignedSongData.songName}");
}
else
{
Debug.LogWarning("bgSpriteObject has no SpriteRenderer in children; cannot assign fullscreen sprite");
}
}
else if (bgSpriteImage != null)
{
bgSpriteImage.sprite = assignedSongData.fullscreen_songPicture;
Debug.LogWarning($"Assigned SongData.fullscreen_songPicture to bgSpriteImage for song {assignedSongData.songName}");
}
else
{
Debug.LogWarning("No bg target (bgSpriteObject or bgSpriteImage) assigned; fullscreen sprite not applied");
}
}
// Pause the system to show pause overlay (PauseManager will enable overlayRoot)
var pauseMgr = PauseManager.Instance ?? FindObjectOfType<PauseManager>();
if (pauseMgr != null)
@@ -346,20 +386,20 @@ public class BeatmapManager : MonoBehaviour
pendingDifficulty = -1;
}
// 如果处于测试模式,则跳过自动加载谱面
// ڲģʽԶ
if (GameConfig.testMode)
{
Debug.Log("Test mode active: skipping automatic beatmap load in BeatmapManager.Start");
}
else
{
// 原先默认加载的调试谱面已注释,改为仅在需要时手动恢复
// LoadBeatmap("Emilia_demo.json"); // 加载并实例化音符
// ԭĬϼصĵעͣΪҪʱֶָ
// LoadBeatmap("Emilia_demo.json"); // زʵ
Debug.LogWarning("Default automatic demo beatmap load is commented out to prioritize SO-provided charts.");
}
}
// 获取当前难度乘数
// ȡǰѶȳ
private float GetCurrentDifficultyMultiplier()
{
if (parsedDifficulty == 1) return ezMultiplier;
@@ -369,7 +409,7 @@ public class BeatmapManager : MonoBehaviour
return 1f;
}
// 统一处理敌人 ID 提取、发送给 UI 以及 HP 计算的逻辑
// ͳһ ID ȡ͸ UI Լ HP ߼
private void SetupEnemiesAndHP()
{
if (uiController == null)
@@ -438,13 +478,13 @@ public class BeatmapManager : MonoBehaviour
}
catch (System.Exception ex)
{
Debug.LogError($"解析 Beatmap 失败: {ex}");
Debug.LogError($" Beatmap ʧ: {ex}");
return;
}
if (parsed == null)
{
Debug.LogError("解析 Beatmap 返回 null");
Debug.LogError(" Beatmap null");
return;
}
@@ -497,10 +537,13 @@ public class BeatmapManager : MonoBehaviour
Debug.LogWarning("BeatmapExtra not found in JSON; populated limited fields from Beatmap.");
}
// Ensure amount and color statistics are populated even if missing from JSON
ValidateAndPopulateStatistics(parsed);
CalculateNoteScores();
beatmap = parsed;
Debug.Log("谱面已加载:" + beatmap.title);
Debug.Log("Ѽأ" + beatmap.title);
if (noteSpawner != null) noteSpawner.LoadBeatmap(beatmap);
else Debug.LogError("NoteSpawner is null in BeatmapManager.");
@@ -524,6 +567,39 @@ public class BeatmapManager : MonoBehaviour
}
}
private void ValidateAndPopulateStatistics(Beatmap parsed)
{
if (parsed == null || parsed.notes == null) return;
// Ensure note amount is correct
if (parsedNoteAmount <= 0)
{
parsedNoteAmount = parsed.notes.Length;
if (GameConfig.verboseLogs) Debug.Log($"[BeatmapManager] Calculated missing noteAmount: {parsedNoteAmount}");
}
// Ensure note statistics (counts by color) are populated
if (parsedNoteStatistics == null || parsedNoteStatistics.Length == 0)
{
var counts = new System.Collections.Generic.Dictionary<string, int>();
foreach (var note in parsed.notes)
{
if (string.IsNullOrEmpty(note.color)) continue;
string c = note.color.ToLower();
if (!counts.ContainsKey(c)) counts[c] = 0;
counts[c]++;
}
parsedNoteStatistics = new NoteStatistic[counts.Count];
int i = 0;
foreach (var kvp in counts)
{
parsedNoteStatistics[i++] = new NoteStatistic { colorType = kvp.Key, count = kvp.Value };
}
if (GameConfig.verboseLogs) Debug.Log($"[BeatmapManager] Calculated missing noteStatistics for {counts.Count} colors");
}
}
[System.Serializable]
private class BeatmapExtra
{