超大量的更新 修复很多问题,gameplay特效初步
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class Note : BaseNote
|
||||
{
|
||||
@@ -11,11 +11,11 @@ public class Note : BaseNote
|
||||
|
||||
private NoteData noteData;
|
||||
|
||||
[Header("判定配置")]
|
||||
public NoteJudgeConfig judgeConfig; // 判定窗口配置,包含判定时间范围
|
||||
|
||||
[Header("Inspector")]
|
||||
public NoteJudgeConfig judgeConfig; // Documentation text normalized.
|
||||
// Cache allies per track to avoid GameObject.Find on every judge.
|
||||
private static AllyCombatant[] allyCache;
|
||||
private static BeatmapManager beatmapManagerCache;
|
||||
|
||||
// Timeout handling - force miss if note isn't judged by this time
|
||||
private float missDeadlineTime = -1f;
|
||||
@@ -34,6 +34,40 @@ public class Note : BaseNote
|
||||
return allyCache[trackIndex];
|
||||
}
|
||||
|
||||
private static BeatmapManager GetBeatmapManagerCached()
|
||||
{
|
||||
if (beatmapManagerCache != null) return beatmapManagerCache;
|
||||
beatmapManagerCache = Object.FindAnyObjectByType<BeatmapManager>();
|
||||
return beatmapManagerCache;
|
||||
}
|
||||
|
||||
private static float JudgeToPmMultiplier(string judgeResult)
|
||||
{
|
||||
switch (judgeResult)
|
||||
{
|
||||
case "Perfect": return 1f;
|
||||
case "Great": return 0.75f;
|
||||
case "Good": return 0.5f;
|
||||
case "Miss": return 0f;
|
||||
default: return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private static int ComputePmDeltaFromJudge(string judgeResult, AllyCombatant ally)
|
||||
{
|
||||
int baseScore = 0;
|
||||
|
||||
var bmm = ally != null ? ally.bmm : null;
|
||||
if (bmm == null) bmm = GetBeatmapManagerCached();
|
||||
if (bmm != null) baseScore = Mathf.Max(0, bmm.perNoteScore);
|
||||
|
||||
if (baseScore <= 0 && ally != null) baseScore = Mathf.Max(0, ally.baseTrackScore);
|
||||
if (baseScore <= 0) return 0;
|
||||
|
||||
float mult = JudgeToPmMultiplier(judgeResult);
|
||||
return Mathf.FloorToInt(baseScore * mult);
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
anim = GetComponent<AnimationController>();
|
||||
@@ -63,10 +97,9 @@ public class Note : BaseNote
|
||||
|
||||
InputManager.OnKeyPressed += HandlePress;
|
||||
|
||||
// 判定配置检查
|
||||
if (judgeConfig == null)
|
||||
{
|
||||
if (JudgeManager.IsDebugEnabled) Debug.LogError($"NoteJudgeConfig is null! 判定配置未赋值!track={trackIndex}");
|
||||
if (JudgeManager.IsDebugEnabled) Debug.LogError($"NoteJudgeConfig is null! 判定配置未赋值,track={trackIndex}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,6 +120,17 @@ public class Note : BaseNote
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Autoplay: automatically judge notes as Perfect without user input.
|
||||
if (!isJudged && GameConfig.autoPlayEnabled && gameObject.activeSelf)
|
||||
{
|
||||
// Only judge once the note reaches its scheduled hit time.
|
||||
if (Time.time >= hitTime)
|
||||
{
|
||||
TryAutoJudgePerfect();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Force miss if we've passed the deadline without being judged
|
||||
if (!isJudged && Time.time > missDeadlineTime && gameObject.activeSelf)
|
||||
{
|
||||
@@ -95,8 +139,77 @@ public class Note : BaseNote
|
||||
}
|
||||
}
|
||||
|
||||
private void TryAutoJudgePerfect()
|
||||
{
|
||||
if (isJudged) return;
|
||||
|
||||
string myId = gameObject.GetInstanceID().ToString();
|
||||
|
||||
// Acquire the track lock to stay compatible with the existing single-judge-per-track invariants.
|
||||
bool locked = false;
|
||||
if (TrackKeyManager.Instance != null)
|
||||
{
|
||||
if (!TrackKeyManager.Instance.TryLockTrackForJudge(TrackIndex, myId))
|
||||
return;
|
||||
locked = true;
|
||||
}
|
||||
|
||||
hasLock = locked;
|
||||
|
||||
float pressTime = hitTime; // force Perfect regardless of frame timing
|
||||
float maxWindow = (judgeConfig?.missRange ?? 0.5f);
|
||||
|
||||
// If not in judge zone, still allow judgement (we're using scheduled timing).
|
||||
if (TrackKeyManager.Instance != null)
|
||||
{
|
||||
if (!TrackKeyManager.Instance.IsBestCandidate(TrackIndex, myId, pressTime, maxWindow))
|
||||
{
|
||||
if (JudgeManager.IsDebugEnabled) Debug.Log($"[Note.AutoPlay] Ignored because another note is a better candidate on track {TrackIndex}");
|
||||
ReleaseTrackLock(myId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Record Perfect stats and offsets
|
||||
ScoreManager.Instance.countPerfect += 1;
|
||||
if (TrackIndex >= 0 && TrackIndex < 5) ScoreManager.Instance.trackPerfectCounts[TrackIndex]++;
|
||||
if (noteData != null) noteData.judgeOffsetMs = 0f;
|
||||
ScoreManager.Instance.RecordOffset(0f);
|
||||
|
||||
const string judgeResult = "Perfect";
|
||||
|
||||
InputManager.Instance?.ShowJudgeResult(TrackIndex, judgeResult);
|
||||
JudgeSoundManager.Instance?.PlayJudgeSound(judgeResult);
|
||||
teamUIController.Instance?.OnJudgeResult(judgeResult);
|
||||
|
||||
if (JudgeManager.IsDebugEnabled) Debug.Log($"[Note.AutoPlay] Spawning judge prefab: color={noteColor}, result={judgeResult}");
|
||||
Animation_GenerateJudgementSituationPrefab.Instance?.SpawnJudgePrefab(noteColor, judgeResult);
|
||||
|
||||
try
|
||||
{
|
||||
var ally = GetAllyForTrackCached(TrackIndex);
|
||||
if (ally != null) ally.AddScoreForJudge(judgeResult);
|
||||
|
||||
int pmDelta = ComputePmDeltaFromJudge(judgeResult, ally);
|
||||
float efficiency = (ally != null && !ally.IsDead) ? ally.scoreEfficiency : 0f;
|
||||
ScoreManager.Instance?.AddPmScoreForTrack(TrackIndex, pmDelta, efficiency);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
if (JudgeManager.IsDebugEnabled) Debug.LogWarning($"[Note.AutoPlay] Failed to add per-track score: {ex}");
|
||||
}
|
||||
|
||||
try { SkillBuilder.Instance?.NotifyNoteHit(TrackIndex, judgeResult, SkillDefinition.NoteTypeTrigger.Tap); } catch { }
|
||||
|
||||
Judge();
|
||||
}
|
||||
|
||||
private void HandlePress(KeyCode key)
|
||||
{
|
||||
// Autoplay ignores player input to guarantee Perfect.
|
||||
if (GameConfig.autoPlayEnabled)
|
||||
return;
|
||||
|
||||
// only proceed for matching key and not already judged
|
||||
if (isJudged || key != keyToPress)
|
||||
return;
|
||||
@@ -224,12 +337,11 @@ public class Note : BaseNote
|
||||
try
|
||||
{
|
||||
var ally = GetAllyForTrackCached(TrackIndex);
|
||||
if (ally != null)
|
||||
{
|
||||
int added = ally.AddScoreForJudge(judgeResult);
|
||||
float efficiency = ally.scoreEfficiency;
|
||||
ScoreManager.Instance?.AddPmScoreForTrack(TrackIndex, added, efficiency);
|
||||
}
|
||||
if (ally != null) ally.AddScoreForJudge(judgeResult);
|
||||
|
||||
int pmDelta = ComputePmDeltaFromJudge(judgeResult, ally);
|
||||
float efficiency = (ally != null && !ally.IsDead) ? ally.scoreEfficiency : 0f;
|
||||
ScoreManager.Instance?.AddPmScoreForTrack(TrackIndex, pmDelta, efficiency);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
@@ -305,12 +417,11 @@ public class Note : BaseNote
|
||||
try
|
||||
{
|
||||
var ally = GetAllyForTrackCached(TrackIndex);
|
||||
if (ally != null)
|
||||
{
|
||||
int added = ally.AddScoreForJudge("Miss");
|
||||
float efficiency = ally.scoreEfficiency;
|
||||
ScoreManager.Instance?.AddPmScoreForTrack(TrackIndex, added, efficiency);
|
||||
}
|
||||
if (ally != null) ally.AddScoreForJudge("Miss");
|
||||
|
||||
int pmDelta = ComputePmDeltaFromJudge("Miss", ally);
|
||||
float efficiency = (ally != null && !ally.IsDead) ? ally.scoreEfficiency : 0f;
|
||||
ScoreManager.Instance?.AddPmScoreForTrack(TrackIndex, pmDelta, efficiency);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user