repaired the motherfucking hold note problem which troubled us longer than 2 months
added some UI
This commit is contained in:
@@ -1,69 +1,15 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using static HoldNote;
|
||||
public enum NoteScore
|
||||
{
|
||||
Perfect,
|
||||
Good,
|
||||
Okay,
|
||||
Miss
|
||||
}
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance { get; private set; }
|
||||
public BeatmapManager beatmapManager; // 负责加载和管理谱面
|
||||
public NoteSpawner noteSpawner; // 音符生成器
|
||||
public AudioSource musicSource; // 音乐播放器
|
||||
public int CurrentScore { get; private set; }
|
||||
public int MaxCombo { get; private set; }
|
||||
public int CurrentCombo { get; private set; }
|
||||
|
||||
// 添加计分方法
|
||||
public void AddScore(NoteScore scoreType)
|
||||
{
|
||||
// 计分逻辑
|
||||
switch (scoreType)
|
||||
{
|
||||
case NoteScore.Perfect:
|
||||
CurrentScore += 100;
|
||||
Debug.Log("Perfect! +100");
|
||||
break;
|
||||
case NoteScore.Good:
|
||||
CurrentScore += 80;
|
||||
Debug.Log("Good! +80");
|
||||
break;
|
||||
case NoteScore.Okay:
|
||||
CurrentScore += 50;
|
||||
Debug.Log("Okay +50");
|
||||
break;
|
||||
case NoteScore.Miss:
|
||||
CurrentCombo = 0; // 连击中断
|
||||
Debug.Log("Miss! 连击中断");
|
||||
return; // 不增加分数
|
||||
}
|
||||
|
||||
// 连击处理
|
||||
CurrentCombo++;
|
||||
if (CurrentCombo > MaxCombo)
|
||||
MaxCombo = CurrentCombo;
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
//Debug.Log("GameManager Start() 被调用");
|
||||
Debug.Log("GameManager Start() 被调用");
|
||||
|
||||
// 检查关键组件是否为空
|
||||
if (beatmapManager == null) Debug.LogError("beatmapManager 未赋值!");
|
||||
@@ -75,7 +21,7 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
if (!File.Exists(beatmapFilePath))
|
||||
{
|
||||
//Debug.LogError($"谱面文件不存在: {beatmapFilePath}");
|
||||
Debug.LogError($"谱面文件不存在: {beatmapFilePath}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,26 +30,20 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
if (beatmap == null)
|
||||
{
|
||||
//Debug.LogError("谱面解析失败,JSON 格式可能错误!");
|
||||
Debug.LogError("谱面解析失败,JSON 格式可能错误!");
|
||||
return;
|
||||
}
|
||||
|
||||
beatmapManager.LoadBeatmap(beatmap); // 传递给 BeatmapManager
|
||||
noteSpawner.LoadBeatmap(beatmap); // 传递给 NoteSpawner
|
||||
|
||||
|
||||
// 播放背景音乐
|
||||
if (!string.IsNullOrEmpty(beatmap.musicFile))
|
||||
{
|
||||
string musicPath = Path.Combine("song_songIndex/1002001_emilia", Path.GetFileNameWithoutExtension(beatmap.musicFile));
|
||||
AudioClip musicClip = Resources.Load<AudioClip>(musicPath);
|
||||
|
||||
AudioClip musicClip = Resources.Load<AudioClip>(beatmap.musicFile);
|
||||
if (musicClip == null)
|
||||
{
|
||||
//Debug.LogError($"音乐文件加载失败,尝试路径: {musicPath}");
|
||||
// 列出Resources文件夹下所有音频文件用于调试
|
||||
var allAudio = Resources.LoadAll<AudioClip>("");
|
||||
//Debug.Log("可用音频文件:" + string.Join(", ", allAudio.Select(a => a.name)));
|
||||
Debug.LogError($"音乐文件加载失败: {beatmap.musicFile}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -113,7 +53,7 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.LogError("谱面中 musicFile 为空!");
|
||||
Debug.LogError("谱面中 musicFile 为空!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user