收拾烂摊子
增加编队初步,改动了判定系统,编队UI组装好
This commit is contained in:
@@ -8,13 +8,16 @@ public class Note : BaseNote
|
||||
private NoteController controller;
|
||||
private bool isJudged = false;
|
||||
|
||||
[Header("判定区间配置")]
|
||||
public NoteJudgeConfig judgeConfig; // 判定区间配置,需在预制体或生成时赋值
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
anim = GetComponent<AnimationController>();
|
||||
controller = GetComponent<NoteController>();
|
||||
}
|
||||
|
||||
public void Setup(KeyCode key, int trackIndex, float speed, float hitTime, string color)
|
||||
public void Setup(KeyCode key, int trackIndex, float speed, float hitTime, string color, NoteJudgeConfig judgeConfig)
|
||||
{
|
||||
keyToPress = key;
|
||||
noteColor = color;
|
||||
@@ -22,6 +25,7 @@ public class Note : BaseNote
|
||||
Speed = speed;
|
||||
this.hitTime = hitTime;
|
||||
isJudged = false;
|
||||
this.judgeConfig = judgeConfig;
|
||||
|
||||
if (controller != null)
|
||||
{
|
||||
@@ -29,6 +33,12 @@ public class Note : BaseNote
|
||||
}
|
||||
|
||||
InputManager.OnKeyPressed += HandlePress;
|
||||
|
||||
// 判定区间配置检查
|
||||
if (judgeConfig == null)
|
||||
Debug.LogError($"NoteJudgeConfig is null! 判定区间配置未传入!track={trackIndex}");
|
||||
else
|
||||
Debug.Log($"NoteJudgeConfig: perfect={judgeConfig.perfectRange}, great={judgeConfig.greatRange}, good={judgeConfig.goodRange}, miss={judgeConfig.missRange}");
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@@ -38,27 +48,75 @@ public class Note : BaseNote
|
||||
|
||||
private void HandlePress(KeyCode key)
|
||||
{
|
||||
// 确保只有匹配的按键触发,并且音符处于判定区域
|
||||
// 只判定正确轨道且在判定区
|
||||
if (isJudged || key != keyToPress || (controller != null && !controller.IsInJudgeZone()))
|
||||
return;
|
||||
|
||||
float timeDifference = Mathf.Abs(Time.time - hitTime);
|
||||
string judgeResult = null;
|
||||
|
||||
if (timeDifference <= 0.08f)
|
||||
if (judgeConfig != null)
|
||||
{
|
||||
Debug.Log($"短音符 {keyToPress}: Perfect");
|
||||
}
|
||||
else if (timeDifference <= 0.15f)
|
||||
{
|
||||
Debug.Log($"短音符 {keyToPress}: Great");
|
||||
if (timeDifference <= judgeConfig.perfectRange)
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Perfect");
|
||||
judgeResult = "Perfect";
|
||||
}
|
||||
else if (timeDifference <= judgeConfig.greatRange)
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Great");
|
||||
judgeResult = "Great";
|
||||
}
|
||||
else if (timeDifference <= judgeConfig.goodRange)
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Good");
|
||||
judgeResult = "Good";
|
||||
}
|
||||
else if (timeDifference <= judgeConfig.missRange)
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Miss");
|
||||
judgeResult = "Miss";
|
||||
InputManager.Instance?.ShowJudgeResult(TrackIndex, judgeResult);
|
||||
JudgeMiss();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Miss");
|
||||
judgeResult = "Miss";
|
||||
InputManager.Instance?.ShowJudgeResult(TrackIndex, judgeResult);
|
||||
JudgeMiss();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"短音符 {keyToPress} Miss");
|
||||
JudgeMiss();
|
||||
return;
|
||||
// 兼容旧逻辑
|
||||
if (timeDifference <= 0.08f)
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Perfect");
|
||||
judgeResult = "Perfect";
|
||||
}
|
||||
else if (timeDifference <= 0.15f)
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Great");
|
||||
judgeResult = "Great";
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"{keyToPress}: Miss");
|
||||
judgeResult = "Miss";
|
||||
InputManager.Instance?.ShowJudgeResult(TrackIndex, judgeResult);
|
||||
JudgeMiss();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示判定文本
|
||||
if (!string.IsNullOrEmpty(judgeResult))
|
||||
{
|
||||
InputManager.Instance?.ShowJudgeResult(TrackIndex, judgeResult);
|
||||
}
|
||||
Judge();
|
||||
}
|
||||
|
||||
@@ -81,7 +139,6 @@ public class Note : BaseNote
|
||||
ReturnToPool();
|
||||
if (anim !=null)
|
||||
{
|
||||
Debug.Log("执行");
|
||||
anim.PlayDestroyAnimation(noteColor);
|
||||
}
|
||||
|
||||
@@ -91,7 +148,8 @@ public class Note : BaseNote
|
||||
{
|
||||
if (isJudged) return;
|
||||
isJudged = true;
|
||||
Debug.Log($"短音符 {keyToPress} Miss");
|
||||
Debug.Log($"{keyToPress} Miss");
|
||||
// InputManager.Instance?.ShowJudgeResult(TrackIndex, "Miss"); // 已在HandlePress中调用
|
||||
ReturnToPool();
|
||||
}
|
||||
|
||||
@@ -117,11 +175,11 @@ public class Note : BaseNote
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由 Controller 调用,通知 Note 是否在判定区域内
|
||||
/// 由 Controller 通知 Note 是否进入判定区
|
||||
/// </summary>
|
||||
public void SetJudgeZone(bool inZone)
|
||||
{
|
||||
// 如果音符离开判定区域且还未判定,则判为 Miss
|
||||
// 离开判定区且未判定则判 Miss
|
||||
if (!inZone && !isJudged)
|
||||
{
|
||||
JudgeMiss();
|
||||
|
||||
Reference in New Issue
Block a user