From a7cc1baebc1698fa26f077c28b34028033f28b15 Mon Sep 17 00:00:00 2001 From: Jiangqvweihuan <15987148+jiangqvweihuan@user.noreply.gitee.com> Date: Sun, 20 Jul 2025 03:01:06 +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/GameManager.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/gamePlay_gameplay/GameManager.cs | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 Assets/scripts/gamePlay_gameplay/GameManager.cs diff --git a/Assets/scripts/gamePlay_gameplay/GameManager.cs b/Assets/scripts/gamePlay_gameplay/GameManager.cs deleted file mode 100644 index d4fa3843..00000000 --- a/Assets/scripts/gamePlay_gameplay/GameManager.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.IO; -using UnityEngine; - -public class GameManager : MonoBehaviour -{ - public BeatmapManager beatmapManager; // 负责加载和管理谱面 - public NoteSpawner noteSpawner; // 音符生成器 - public AudioSource musicSource; // 音乐播放器 - - void Start() - { - Debug.Log("GameManager Start() 被调用"); - - // 检查关键组件是否为空 - if (beatmapManager == null) Debug.LogError("beatmapManager 未赋值!"); - if (noteSpawner == null) Debug.LogError("noteSpawner 未赋值!"); - if (musicSource == null) Debug.LogError("musicSource 未赋值!"); - - // 在游戏开始时加载并初始化谱面 - string beatmapFilePath = Path.Combine(Application.streamingAssetsPath, "Emilia_demo.json"); - - if (!File.Exists(beatmapFilePath)) - { - Debug.LogError($"谱面文件不存在: {beatmapFilePath}"); - return; - } - - string json = File.ReadAllText(beatmapFilePath); - Beatmap beatmap = JsonUtility.FromJson(json); // 解析 JSON 为 Beatmap 对象 - - if (beatmap == null) - { - Debug.LogError("谱面解析失败,JSON 格式可能错误!"); - return; - } - - beatmapManager.LoadBeatmap(beatmap); // 传递给 BeatmapManager - noteSpawner.LoadBeatmap(beatmap); // 传递给 NoteSpawner - - // 播放背景音乐 - if (!string.IsNullOrEmpty(beatmap.musicFile)) - { - AudioClip musicClip = Resources.Load(beatmap.musicFile); - if (musicClip == null) - { - Debug.LogError($"音乐文件加载失败: {beatmap.musicFile}"); - } - else - { - musicSource.clip = musicClip; - //musicSource.Play(); - } - } - else - { - Debug.LogError("谱面中 musicFile 为空!"); - } - } -}