From 2e0bd4ff8bacdc034b60eb1f65dcc34427e9e6e2 Mon Sep 17 00:00:00 2001 From: Jiangqvweihuan <15987148+jiangqvweihuan@user.noreply.gitee.com> Date: Sun, 20 Jul 2025 03:00:39 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20Assets/s?= =?UTF-8?q?cripts/gamePlay=5Fgameplay/BeatmapManager.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamePlay_gameplay/BeatmapManager.cs | 131 ------------------ 1 file changed, 131 deletions(-) delete mode 100644 Assets/scripts/gamePlay_gameplay/BeatmapManager.cs diff --git a/Assets/scripts/gamePlay_gameplay/BeatmapManager.cs b/Assets/scripts/gamePlay_gameplay/BeatmapManager.cs deleted file mode 100644 index fa76a2e8..00000000 --- a/Assets/scripts/gamePlay_gameplay/BeatmapManager.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.IO; -using UnityEngine; -using UnityEngine.UI; - - -public class BeatmapManager : MonoBehaviour - -{ - public Beatmap beatmap; // 当前谱面数据 - - // 音符生成器引用 - public NoteSpawner noteSpawner; - - - - // 保存谱面数据到 JSON 文件 - //public void SaveBeatmap(string fileName) - //{ - // string json = JsonUtility.ToJson(beatmap, true); // 格式化 JSON 输出 - // File.WriteAllText(Application.dataPath + "/" + fileName, json); - // Debug.Log("谱面已保存:" + Application.dataPath + "/" + fileName); - //} - - // 从 JSON 文件加载谱面数据 - public void LoadBeatmap(string fileName) - { - string path = Application.streamingAssetsPath + "/" + fileName; - if (File.Exists(path)) - { - string json = File.ReadAllText(path); - beatmap = JsonUtility.FromJson(json); - Debug.Log("谱面已加载:" + json); - - // 在加载后立即调用音符生成 - noteSpawner.LoadBeatmap(beatmap); - - } - else - { - Debug.LogError("文件不存在:" + path); - } - } - public void LoadBeatmap(Beatmap loadedBeatmap) - { - beatmap = loadedBeatmap; - Debug.Log("谱面已加载:" + beatmap.title); - - // 在加载后立即调用音符生成 - noteSpawner.LoadBeatmap(beatmap); - } - - //public void LoadBeatmapFromFile(string fileName) - //{ - // string path = Application.persistentDataPath + "/" + fileName; - // if (File.Exists(path)) - // { - // string json = File.ReadAllText(path); - // Beatmap beatmap = JsonUtility.FromJson(json); - // beatmapManager.LoadBeatmap(beatmap); // 使用 LoadBeatmap 方法传递 Beatmap 对象 - // } - // else - // { - // Debug.LogError("文件不存在:" + path); - // } - //} - - // 创建一个示例谱面并保存 - //public void CreateSampleBeatmap() - //{ - // beatmap = new Beatmap - // { - // title = "Moonlight Sonata", - // composer = "Ludwig van Beethoven", - // illustrator = "John Doe", - // charter = "Jane Smith", - // beatmapId = "ML-001", - // duration = 120.5f, - // bpm = 128f, - // difficulty = 5, - // difficultyName = "Hard", - // createdDate = System.DateTime.Now.ToString("yyyy-MM-dd"), - // musicFile = "moonlight_sonata.mp3", - // backgroundFile = "moonlight_art.png", - - // tracks = new TrackData[] - // { - // new TrackData { color = "red" }, - // new TrackData { color = "green" }, - // new TrackData { color = "yellow" }, - // new TrackData { color = "purple" }, - // new TrackData { color = "blue" } - // }, - - // notes = new NoteData[] - // { - // new NoteData { trackIndex = 0, time = 1.0f, color = "red", type = "tap", length = 0.0f }, - // new NoteData { trackIndex = 4, time = 2.0f, color = "blue", type = "tap", length = 0.0f }, - // new NoteData { trackIndex = 1, time = 3.5f, color = "green", type = "tap", length = 0.0f }, - // new NoteData { trackIndex = 2, time = 3.5f, color = "yellow", type = "tap", length = 0.0f }, - // new NoteData { trackIndex = 2, time = 3.5f, color = "yellow", type = "tap", length = 0.0f }, - // new NoteData { trackIndex = 3, time = 3.5f, color = "purple", type = "tap", length = 0.0f }, - // } - // }; - - // SaveBeatmap("test_beatmap.json"); - //} - - // 读取并加载当前谱面到音符生成器 - public void LoadBeatmapFromFile() - { - string path = Application.streamingAssetsPath + "/Emilia_demo.json"; - if (File.Exists(path)) - { - string json = File.ReadAllText(path); - beatmap = JsonUtility.FromJson(json); - noteSpawner.LoadBeatmap(beatmap); - } - else - { - Debug.LogError("谱面文件未找到!"); - } - } - - // 在 Start() 方法中初始化 - void Start() - { - // 这里可以选择在启动时创建一个示例谱面并加载 - //CreateSampleBeatmap(); // 创建并保存一个示例谱面 - LoadBeatmap("Emilia_demo.json"); // 加载并实例化音符 - } -}