收拾烂摊子

增加编队初步,改动了判定系统,编队UI组装好
This commit is contained in:
2025-09-28 00:23:05 +08:00
parent 1d818fa4eb
commit 98510eef0f
53 changed files with 10492 additions and 60 deletions
+67 -19
View File
@@ -37,10 +37,30 @@ public class HoldNote : BaseNote
// 新增变量
private bool hasBeenHeldFromStart = false; // 进入判定区时是否已按住 (用于辅助判断,但不再直接阻断判定)
[Header("判定区间配置")]
public NoteJudgeConfig judgeConfig; // 判定区间配置,需在预制体或生成时赋值
private void Awake()
{
controller = GetComponent<HoldNoteController>();
anim = GetComponent<AnimationController>();
if (controller != null)
{
controller.OnJudgeZoneChanged += OnJudgeZoneChanged;
}
}
private void OnDestroy()
{
if (controller != null)
{
controller.OnJudgeZoneChanged -= OnJudgeZoneChanged;
}
}
private void OnJudgeZoneChanged(bool inZone)
{
hasEnteredLine = inZone;
}
private void OnEnable()
@@ -68,7 +88,7 @@ public class HoldNote : BaseNote
}
public void Setup(int id, int trackIndex, float speed, float time, float delay,
bool isEnd, float scheduledEnd, string color, KeyCode key, string type)
bool isEnd, float scheduledEnd, string color, KeyCode key, string type, NoteJudgeConfig judgeConfig)
{
this.id = id;
this.trackIndex = trackIndex;
@@ -80,6 +100,7 @@ public class HoldNote : BaseNote
this.color = color;
this.key = key;
this.type = type;
this.judgeConfig = judgeConfig;
this.noteID = id.ToString();
this.keyToPress = key;
@@ -90,6 +111,12 @@ public class HoldNote : BaseNote
this.hasEnteredLine = false;
this.hasReleased = false;
// 判定区间配置检查
if (judgeConfig == null)
Debug.LogError($"HoldNoteJudgeConfig is null! 判定区间配置未传入!track={trackIndex}");
else
Debug.Log($"HoldNoteJudgeConfig: perfect={judgeConfig.perfectRange}, great={judgeConfig.greatRange}, good={judgeConfig.goodRange}, miss={judgeConfig.missRange}");
// 在 Setup 时注册初始状态
JudgeManager.Instance?.RegisterNoteReleased(noteID, false);
if (segment == NoteSegment.Start)
@@ -304,9 +331,10 @@ public class HoldNote : BaseNote
{
float pressTime = Time.time;
float offset = Mathf.Abs(pressTime - hitTime);
string result;
if (offset < 0.1f) // 判定成功
{
result = "Perfect";
Debug.Log($"[HoldNote] START判定成功(偏差={offset:F2}秒): {noteColor}");
JudgeManager.Instance.RegisterStartJudged(noteID, true);
isHoldActive = true; // 成功判定Start,长按状态激活
@@ -314,11 +342,12 @@ public class HoldNote : BaseNote
}
else
{
result = "Miss";
Debug.Log($"[HoldNote] START Miss(偏差={offset:F2}秒): {noteColor}");
JudgeManager.Instance.RegisterStartJudged(noteID, false); // 明确标记未判定
isHoldActive = false; // Start Miss,长按状态不激活
}
InputManager.Instance?.ShowJudgeResult(trackIndex, result);
// Start段判定后立即回收,因为它的视觉部分可能只需要短暂显示
StartCoroutine(DelayedReturn());
}
@@ -332,46 +361,65 @@ public class HoldNote : BaseNote
}
}
// 重载 HandleEnd 方法,增加一个强制Miss的参数
private void HandleEnd(bool forceMiss = false)
{
releaseTime = Time.time;
hasReleased = true; // 标记此音符已被释放
JudgeManager.Instance.RegisterNoteReleased(noteID, true); // 在 JudgeManager 中注册释放
hasReleased = true;
JudgeManager.Instance.RegisterNoteReleased(noteID, true);
string result;
// 如果强制Miss,或者头部未判定,或者长按已经中断,则直接判定为Miss
if (forceMiss || !JudgeManager.Instance.IsStartJudged(noteID) || !isHoldActive)
// 只要头部判定通过,松手时机在判定区间内就给出对应判定
if (forceMiss || !JudgeManager.Instance.IsStartJudged(noteID))
{
result = "Miss";
Debug.LogWarning($"[HoldNote] END判定失败({noteColor}):{(forceMiss ? "Miss" : (!JudgeManager.Instance.IsStartJudged(noteID) ? "" : ""))}");
Debug.LogWarning($"[HoldNote] END判定失败({noteColor}):{(forceMiss ? "Miss" : "")}");
}
else if (judgeConfig != null)
{
float diff = Mathf.Abs(releaseTime - scheduledEndTime);
if (diff <= judgeConfig.perfectRange)
{
result = "Perfect";
}
else if (diff <= judgeConfig.greatRange)
{
result = "Great";
}
else if (diff <= judgeConfig.goodRange)
{
result = "Good";
}
else if (diff <= judgeConfig.missRange)
{
result = "Miss";
}
else
{
result = "Miss";
}
}
else
{
float diff = Mathf.Abs(releaseTime - scheduledEndTime);
// End段的判定规则
if (diff <= 0.1f) // 更严格的完美判定窗口
if (diff <= 0.1f)
{
result = "Perfect";
}
else if (diff < 0.2f) // 适当放宽的Great判定
else if (diff < 0.2f)
{
result = "Great";
}
else if (diff < 0.3f) // 再次放宽的Good判定
else if (diff < 0.3f)
{
result = "Good";
}
else
{
result = "Bad"; // 更大的偏差可能视为Bad或Miss
result = "Bad";
}
}
InputManager.Instance?.ShowJudgeResult(trackIndex, result);
Debug.Log($"[HoldNote] END判定结果: {noteColor} {result} (release={releaseTime:F2}, target={scheduledEndTime:F2})");
ReturnToPool(); // 判定后回收
ReturnToPool();
}
private void OnDisable()