技能主要更新,修复卡顿并加入动画,以及各种其他更新。
This commit is contained in:
@@ -10,6 +10,23 @@ public class JudgeManager : MonoBehaviour
|
||||
public settlementController sc;
|
||||
public NoteSpawner ns;
|
||||
|
||||
private bool _cachedIsDebugEnabled;
|
||||
private void UpdateDebugCache()
|
||||
{
|
||||
_cachedIsDebugEnabled = (_enableDebugLogs || GameConfig.verboseLogs);
|
||||
}
|
||||
|
||||
[Header("Debug Settings")]
|
||||
[SerializeField] private bool _enableDebugLogs = false;
|
||||
public bool EnableDebugLogs => _enableDebugLogs;
|
||||
public static bool IsDebugEnabled => (Instance != null && Instance._cachedIsDebugEnabled);
|
||||
|
||||
[Header("Global Note Settings")]
|
||||
[Tooltip("Global material applied to hold notes when they are judged.")]
|
||||
public Material globalJudgedMaterial;
|
||||
[Tooltip("Whether to enable material switching after a hold note is judged.")]
|
||||
public bool enableJudgedMaterial = false;
|
||||
|
||||
public static JudgeManager Instance { get; private set; }
|
||||
|
||||
// total/remaining notes tracking for end-of-song detection
|
||||
@@ -35,9 +52,12 @@ public class JudgeManager : MonoBehaviour
|
||||
|
||||
private HoldJudgeState GetHoldState(string noteID)
|
||||
{
|
||||
if (!holdStates.ContainsKey(noteID))
|
||||
holdStates[noteID] = new HoldJudgeState();
|
||||
return holdStates[noteID];
|
||||
if (!holdStates.TryGetValue(noteID, out var state))
|
||||
{
|
||||
state = new HoldJudgeState();
|
||||
holdStates[noteID] = state;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
// Public event and hook invoked when the entire beatmap's last note has been judged.
|
||||
@@ -52,7 +72,7 @@ public class JudgeManager : MonoBehaviour
|
||||
{
|
||||
if (settlement_go == null)
|
||||
{
|
||||
Debug.LogError("结算页面不存在!");
|
||||
if (IsDebugEnabled) Debug.LogError("结算页面不存在!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +83,7 @@ public class JudgeManager : MonoBehaviour
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] Failed to activate settlement_go: {ex}");
|
||||
if (IsDebugEnabled) Debug.LogWarning($"[JudgeManager] Failed to activate settlement_go: {ex}");
|
||||
}
|
||||
|
||||
// Try to resolve settlementController reference if missing
|
||||
@@ -87,12 +107,12 @@ public class JudgeManager : MonoBehaviour
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] Exception calling startSettlement_uiUpdate: {ex}");
|
||||
if (IsDebugEnabled) Debug.LogWarning($"[JudgeManager] Exception calling startSettlement_uiUpdate: {ex}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[JudgeManager] settlementController (sc) not found on settlement_go; cannot call startSettlement_uiUpdate().");
|
||||
if (IsDebugEnabled) Debug.LogWarning("[JudgeManager] settlementController (sc) not found on settlement_go; cannot call startSettlement_uiUpdate().");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +128,7 @@ public class JudgeManager : MonoBehaviour
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] Exception while invoking AllNotesJudged event: {ex}");
|
||||
if (IsDebugEnabled) Debug.LogWarning($"[JudgeManager] Exception while invoking AllNotesJudged event: {ex}");
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -116,7 +136,7 @@ public class JudgeManager : MonoBehaviour
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] Exception in OnAllNotesJudged hook: {ex}");
|
||||
if (IsDebugEnabled) Debug.LogWarning($"[JudgeManager] Exception in OnAllNotesJudged hook: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +145,7 @@ public class JudgeManager : MonoBehaviour
|
||||
if (Instance == null) Instance = this;
|
||||
else Destroy(gameObject);
|
||||
|
||||
UpdateDebugCache();
|
||||
if (settlement_go != null) settlement_go.SetActive(false);
|
||||
}
|
||||
|
||||
@@ -136,7 +157,7 @@ public class JudgeManager : MonoBehaviour
|
||||
{
|
||||
totalNotes = Mathf.Max(0, total);
|
||||
remainingNotes = totalNotes;
|
||||
Debug.Log($"[JudgeManager] SetTotalNotes: total={totalNotes}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] SetTotalNotes: total={totalNotes}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -147,10 +168,10 @@ public class JudgeManager : MonoBehaviour
|
||||
{
|
||||
if (remainingNotes <= 0) return;
|
||||
remainingNotes = Mathf.Max(0, remainingNotes - 1);
|
||||
Debug.Log($"[JudgeManager] NotifyNoteJudged: remaining={remainingNotes}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] NotifyNoteJudged: remaining={remainingNotes}");
|
||||
if (remainingNotes == 0)
|
||||
{
|
||||
Debug.Log("[JudgeManager] All notes judged -> Triggering AllNotesJudged");
|
||||
if (IsDebugEnabled) Debug.Log("[JudgeManager] All notes judged -> Triggering AllNotesJudged");
|
||||
TriggerAllNotesJudged();
|
||||
}
|
||||
}
|
||||
@@ -161,11 +182,11 @@ public class JudgeManager : MonoBehaviour
|
||||
var s = GetHoldState(noteID);
|
||||
if (s.startResolved)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] TryResolveStart: already resolved start for {noteID}");
|
||||
if (IsDebugEnabled) Debug.LogWarning($"[JudgeManager] TryResolveStart: already resolved start for {noteID}");
|
||||
return false;
|
||||
}
|
||||
s.startResolved = true;
|
||||
Debug.Log($"[JudgeManager] TryResolveStart: start resolved for {noteID} at time={Time.time:F3}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] TryResolveStart: start resolved for {noteID} at time={Time.time:F3}");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -174,11 +195,11 @@ public class JudgeManager : MonoBehaviour
|
||||
var s = GetHoldState(noteID);
|
||||
if (s.endResolved)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] TryResolveEnd: already resolved end for {noteID}");
|
||||
if (IsDebugEnabled) Debug.LogWarning($"[JudgeManager] TryResolveEnd: already resolved end for {noteID}");
|
||||
return false;
|
||||
}
|
||||
s.endResolved = true;
|
||||
Debug.Log($"[JudgeManager] TryResolveEnd: end resolved for {noteID} at time={Time.time:F3}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] TryResolveEnd: end resolved for {noteID} at time={Time.time:F3}");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -187,11 +208,11 @@ public class JudgeManager : MonoBehaviour
|
||||
var s = GetHoldState(noteID);
|
||||
if (s.skillTriggered)
|
||||
{
|
||||
Debug.LogWarning($"[JudgeManager] TryTriggerSkill: already triggered for {noteID}");
|
||||
if (IsDebugEnabled) Debug.LogWarning($"[JudgeManager] TryTriggerSkill: already triggered for {noteID}");
|
||||
return false;
|
||||
}
|
||||
s.skillTriggered = true;
|
||||
Debug.Log($"[JudgeManager] TryTriggerSkill: skill triggered for {noteID} at time={Time.time:F3}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] TryTriggerSkill: skill triggered for {noteID} at time={Time.time:F3}");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -200,7 +221,7 @@ public class JudgeManager : MonoBehaviour
|
||||
if (holdStates.ContainsKey(noteID))
|
||||
{
|
||||
holdStates.Remove(noteID);
|
||||
Debug.Log($"[JudgeManager] ClearHoldState: cleared state for {noteID}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] ClearHoldState: cleared state for {noteID}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,34 +230,34 @@ public class JudgeManager : MonoBehaviour
|
||||
public void RegisterScheduledEndTime(string noteID, float endTime)
|
||||
{
|
||||
noteEndTimes[noteID] = endTime;
|
||||
Debug.Log($"[JudgeManager] RegisterScheduledEndTime: {noteID} -> {endTime:F3}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] RegisterScheduledEndTime: {noteID} -> {endTime:F3}");
|
||||
}
|
||||
|
||||
public float GetScheduledEndTime(string noteID)
|
||||
{
|
||||
return noteEndTimes.ContainsKey(noteID) ? noteEndTimes[noteID] : 0f;
|
||||
return noteEndTimes.TryGetValue(noteID, out var endTime) ? endTime : 0f;
|
||||
}
|
||||
|
||||
public void RegisterStartJudged(string noteID, bool state)
|
||||
{
|
||||
startJudgedNotes[noteID] = state;
|
||||
Debug.Log($"[JudgeManager] RegisterStartJudged: {noteID} = {state} at time={Time.time:F3}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] RegisterStartJudged: {noteID} = {state} at time={Time.time:F3}");
|
||||
}
|
||||
|
||||
public bool IsStartJudged(string noteID)
|
||||
{
|
||||
return startJudgedNotes.ContainsKey(noteID) && startJudgedNotes[noteID];
|
||||
return startJudgedNotes.TryGetValue(noteID, out var state) && state;
|
||||
}
|
||||
|
||||
public void RegisterNoteReleased(string noteID, bool state)
|
||||
{
|
||||
releasedNotes[noteID] = state;
|
||||
Debug.Log($"[JudgeManager] RegisterNoteReleased: {noteID} = {state}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] RegisterNoteReleased: {noteID} = {state}");
|
||||
}
|
||||
|
||||
public bool HasNoteReleased(string noteID)
|
||||
{
|
||||
return releasedNotes.ContainsKey(noteID) && releasedNotes[noteID];
|
||||
return releasedNotes.TryGetValue(noteID, out var state) && state;
|
||||
}
|
||||
|
||||
public void RegisterNote(KeyCode key, Note note)
|
||||
@@ -246,7 +267,7 @@ public class JudgeManager : MonoBehaviour
|
||||
|
||||
if (!judgeQueues[key].Contains(note))
|
||||
judgeQueues[key].Enqueue(note);
|
||||
Debug.Log($"[JudgeManager] RegisterNote: key={key} note={note.name} time={Time.time:F3} queueSize={judgeQueues[key].Count}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] RegisterNote: key={key} note={note.name} time={Time.time:F3} queueSize={judgeQueues[key].Count}");
|
||||
}
|
||||
|
||||
public void UnregisterNote(KeyCode key, Note note)
|
||||
@@ -263,7 +284,7 @@ public class JudgeManager : MonoBehaviour
|
||||
n.JudgeMiss();
|
||||
}
|
||||
judgeQueues[key] = newQueue;
|
||||
Debug.Log($"[JudgeManager] UnregisterNote: key={key} removed {note.name}, newQueueSize={judgeQueues[key].Count}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] UnregisterNote: key={key} removed {note.name}, newQueueSize={judgeQueues[key].Count}");
|
||||
}
|
||||
|
||||
public void JudgeEarliestNote(KeyCode key)
|
||||
@@ -273,7 +294,7 @@ public class JudgeManager : MonoBehaviour
|
||||
Note note = judgeQueues[key].Dequeue();
|
||||
if (note != null && !note.IsJudged())
|
||||
{
|
||||
Debug.Log($"[JudgeManager] JudgeEarliestNote: judging {note.name} for key={key} at time={Time.time:F3}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] JudgeEarliestNote: judging {note.name} for key={key} at time={Time.time:F3}");
|
||||
note.Judge();
|
||||
}
|
||||
}
|
||||
@@ -281,15 +302,28 @@ public class JudgeManager : MonoBehaviour
|
||||
|
||||
public void RegisterMiddlePassed(string noteID)
|
||||
{
|
||||
if (!middlePassedCounts.ContainsKey(noteID))
|
||||
middlePassedCounts[noteID] = 0;
|
||||
middlePassedCounts[noteID]++;
|
||||
Debug.Log($"[JudgeManager] Middle passed for {noteID}, total={middlePassedCounts[noteID]}");
|
||||
if (middlePassedCounts.TryGetValue(noteID, out int count))
|
||||
{
|
||||
middlePassedCounts[noteID] = count + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
middlePassedCounts[noteID] = 1;
|
||||
}
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] Middle passed for {noteID}, total={middlePassedCounts[noteID]}");
|
||||
}
|
||||
|
||||
// Event for syncing alpha across segments of a hold note
|
||||
public event Action<string, float> OnHoldAlphaSync;
|
||||
|
||||
public void SyncHoldAlpha(string noteID, float alpha)
|
||||
{
|
||||
OnHoldAlphaSync?.Invoke(noteID, alpha);
|
||||
}
|
||||
|
||||
public int GetMiddlePassedCount(string noteID)
|
||||
{
|
||||
return middlePassedCounts.ContainsKey(noteID) ? middlePassedCounts[noteID] : 0;
|
||||
return middlePassedCounts.TryGetValue(noteID, out var count) ? count : 0;
|
||||
}
|
||||
|
||||
public void ClearNoteRecord(string noteID)
|
||||
@@ -299,6 +333,6 @@ public class JudgeManager : MonoBehaviour
|
||||
noteEndTimes.Remove(noteID);
|
||||
middlePassedCounts.Remove(noteID);
|
||||
ClearHoldState(noteID);
|
||||
Debug.Log($"[JudgeManager] ClearNoteRecord: cleared records for {noteID}");
|
||||
if (IsDebugEnabled) Debug.Log($"[JudgeManager] ClearNoteRecord: cleared records for {noteID}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user