长音符再修复 加入了关卡连接 优化了一些默认加载

This commit is contained in:
2026-01-13 11:22:39 +08:00
parent 2738089af1
commit 2f9d4aae0c
426 changed files with 299413 additions and 1050 deletions
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using System.Collections;
using TMPro;
@@ -29,6 +29,14 @@ public class NoteSpawner : MonoBehaviour
[Range(0.8f, 1.25f)]
public float speedMultiplier = 1f;
[Header("Calibration")]
[Tooltip("Tolerance (world units) for snapping middle segments to expected position after spawn.")]
public float calibrateTolerance = 0.02f;
[Tooltip("How many calibration checks to perform after spawn (spread over frames).")]
public int calibrateChecks = 2;
[Tooltip("Interval (seconds realtime) between calibration checks.")]
public float calibrateInterval = 0.01f;
// optional: constants for runtime clamping (kept for internal use)
private const float SpeedMultiplierMin = 0.8f;
private const float SpeedMultiplierMax = 1.25f;
@@ -94,7 +102,15 @@ public class NoteSpawner : MonoBehaviour
if (GameConfig.verboseLogs) Debug.Log($"delay: {delay}");
if (delay > 0)
yield return new WaitForSeconds(delay);
{
// Use scaled-time wait so spawning is paused while Time.timeScale==0 (PauseManager pause)
float target = Time.time + delay;
// Wait using frames so this loop respects Time.timeScale (Time.time won't advance when paused)
while (Time.time < target)
{
yield return null;
}
}
if (note.type == "hold")
{
@@ -263,6 +279,10 @@ public class NoteSpawner : MonoBehaviour
float visualScaleMid = 0.9f * smLocalHold + 0.1f;
holdSeg.ApplyVisualScale(visualScaleMid);
holdSeg.visualSpeedMultiplier = smLocalHold;
// Immediately calibrate position and schedule additional checks to correct any offset
holdSeg.CalibratePosition(spawnPoint.position, calibrateTolerance);
StartCoroutine(CalibrateAfterSpawn(holdSeg, spawnPoint.position));
}
else
{
@@ -298,6 +318,10 @@ public class NoteSpawner : MonoBehaviour
float visualScaleEnd = 0.9f * smLocalHold + 0.1f;
holdEnd.ApplyVisualScale(visualScaleEnd);
holdEnd.visualSpeedMultiplier = smLocalHold;
// schedule calibration for end as well to be safe
holdEnd.CalibratePosition(spawnPoint.position, calibrateTolerance);
StartCoroutine(CalibrateAfterSpawn(holdEnd, spawnPoint.position));
}
else
{
@@ -305,6 +329,16 @@ public class NoteSpawner : MonoBehaviour
}
}
private IEnumerator CalibrateAfterSpawn(HoldNote seg, Vector3 spawnPos)
{
if (seg == null) yield break;
for (int i = 0; i < Mathf.Max(1, calibrateChecks); i++)
{
yield return new WaitForSecondsRealtime(calibrateInterval);
if (seg == null || !seg.gameObject.activeSelf) yield break;
seg.CalibratePosition(spawnPos, calibrateTolerance);
}
}
private float CalculateSpeed(float noteTravelTime)
{