修复短音符延迟
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class JudgeManager : MonoBehaviour
|
||||
{
|
||||
[Header("settlement go")]
|
||||
public GameObject settlement_go;
|
||||
public settlementController sc;
|
||||
|
||||
public static JudgeManager Instance { get; private set; }
|
||||
|
||||
// total/remaining notes tracking for end-of-song detection
|
||||
private int totalNotes = 0;
|
||||
private int remainingNotes = 0;
|
||||
|
||||
// ===== ԭ������ =====
|
||||
private Dictionary<KeyCode, Queue<Note>> judgeQueues = new Dictionary<KeyCode, Queue<Note>>();
|
||||
private Dictionary<string, bool> startJudgedNotes = new Dictionary<string, bool>();
|
||||
@@ -29,13 +38,95 @@ public class JudgeManager : MonoBehaviour
|
||||
return holdStates[noteID];
|
||||
}
|
||||
|
||||
// Public event and hook invoked when the entire beatmap's last note has been judged.
|
||||
// The method is intentionally empty so you can override or call it via the singleton.
|
||||
public event Action AllNotesJudged;
|
||||
|
||||
/// <summary>
|
||||
/// Public empty hook called when all notes have been judged. Implement your end-of-song logic here
|
||||
/// or subscribe to the AllNotesJudged event. This method is intentionally left empty.
|
||||
/// </summary>
|
||||
public void OnAllNotesJudged()
|
||||
{
|
||||
// safe null checks and invocation
|
||||
if (settlement_go != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
sc?.startSettlement_uiUpdate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] Exception calling startSettlement_uiUpdate: {ex}");
|
||||
}
|
||||
settlement_go.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("结算页面不存在!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper to invoke the AllNotesJudged event and call the public hook.
|
||||
/// Call this when you detect the last note was judged.
|
||||
/// </summary>
|
||||
public void TriggerAllNotesJudged()
|
||||
{
|
||||
try
|
||||
{
|
||||
AllNotesJudged?.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] Exception while invoking AllNotesJudged event: {ex}");
|
||||
}
|
||||
try
|
||||
{
|
||||
OnAllNotesJudged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] Exception in OnAllNotesJudged hook: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null) Instance = this;
|
||||
else Destroy(gameObject);
|
||||
|
||||
if (settlement_go != null) settlement_go.SetActive(false);
|
||||
}
|
||||
|
||||
// ===== �������ж�����բ�� =====
|
||||
/// <summary>
|
||||
/// Set the total number of notes in the current beatmap. Remaining notes will be initialized
|
||||
/// to this value. Call before playback/spawning starts.
|
||||
/// </summary>
|
||||
public void SetTotalNotes(int total)
|
||||
{
|
||||
totalNotes = Mathf.Max(0, total);
|
||||
remainingNotes = totalNotes;
|
||||
Debug.Log($"[JudgeManager] SetTotalNotes: total={totalNotes}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify that one note has been finally judged (hit or miss). When remaining reaches zero,
|
||||
/// TriggerAllNotesJudged will be invoked.
|
||||
/// </summary>
|
||||
public void NotifyNoteJudged()
|
||||
{
|
||||
if (remainingNotes <= 0) return;
|
||||
remainingNotes = Mathf.Max(0, remainingNotes - 1);
|
||||
Debug.Log($"[JudgeManager] NotifyNoteJudged: remaining={remainingNotes}");
|
||||
if (remainingNotes == 0)
|
||||
{
|
||||
Debug.Log("[JudgeManager] All notes judged -> Triggering AllNotesJudged");
|
||||
TriggerAllNotesJudged();
|
||||
}
|
||||
}
|
||||
|
||||
// ===== �������ж�����խ�� =====
|
||||
public bool TryResolveStart(string noteID)
|
||||
{
|
||||
var s = GetHoldState(noteID);
|
||||
|
||||
Reference in New Issue
Block a user