成就系统 巨大修改 新的ui 黑白效果 等一堆
This commit is contained in:
@@ -6,12 +6,24 @@ public class HoldNoteController : MonoBehaviour
|
||||
private bool isInsideJudgeZone = false;
|
||||
public event Action<bool> OnJudgeZoneChanged;
|
||||
private bool isMoving = false;
|
||||
private float speed = 0f; // 运动速度
|
||||
private float activationTime; // 何时开始移动(Time.time 基准)
|
||||
private float speed = 0f;
|
||||
private float activationTime;
|
||||
|
||||
// Absolute positioning for hold segments (keeps segments connected under frame spikes)
|
||||
private bool useAbsolutePositioning = false;
|
||||
private Vector3 spawnPosition;
|
||||
private float baseSpawnYOffset = 0f; // can be negative to offset upward for delayed segments
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 到达激活时间后开始移动
|
||||
if (useAbsolutePositioning)
|
||||
{
|
||||
if (!isMoving) return;
|
||||
ApplyAbsolutePosition(Time.time);
|
||||
return;
|
||||
}
|
||||
|
||||
// Start moving after activation time in legacy mode
|
||||
if (!isMoving && Time.time >= activationTime)
|
||||
{
|
||||
isMoving = true;
|
||||
@@ -24,26 +36,24 @@ public class HoldNoteController : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置该段的“到达判定线的目标时间”(hitTime) 与分段延迟(delay),并由此推导移动开始时间。
|
||||
/// 注意:这里必须使用与 HoldNote.hitTime 一致的时间基准(NoteSpawner 传入的谱面实时点),
|
||||
/// 否则用 Time.time + delay 会在首段/暂停/开歌延迟时产生系统性错位,导致永远 Miss。
|
||||
/// Configure legacy timing (per-segment activation).
|
||||
/// </summary>
|
||||
public void ConfigureTiming(float baseHitTime, float segmentDelay, float travelTime)
|
||||
{
|
||||
// baseHitTime = startTime + noteData.time (+ globalHitDelay)
|
||||
float hitTime = baseHitTime + segmentDelay;
|
||||
activationTime = hitTime - travelTime;
|
||||
isMoving = false;
|
||||
useAbsolutePositioning = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 兼容旧接口:不推荐。旧版用 Time.time 会导致时间基准不一致。
|
||||
/// Legacy delay setter (not recommended).
|
||||
/// </summary>
|
||||
public void SetSegmentDelay(float segmentDelay)
|
||||
{
|
||||
// Fallback to old behavior if caller didn't use ConfigureTiming.
|
||||
activationTime = Time.time + segmentDelay;
|
||||
isMoving = false;
|
||||
useAbsolutePositioning = false;
|
||||
}
|
||||
|
||||
public void SetSpeed(float newSpeed)
|
||||
@@ -51,6 +61,23 @@ public class HoldNoteController : MonoBehaviour
|
||||
speed = newSpeed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configure absolute positioning for hold segments so they stay connected.
|
||||
/// spawnPoint should be the original spawn point for the lane.
|
||||
/// baseSpawnYOffset is applied to keep delayed segments offset upward (can be negative).
|
||||
/// </summary>
|
||||
public void ConfigureAbsolutePositioning(Vector3 spawnPoint, float newActivationTime, float spawnYOffset)
|
||||
{
|
||||
spawnPosition = spawnPoint;
|
||||
activationTime = newActivationTime;
|
||||
baseSpawnYOffset = spawnYOffset;
|
||||
useAbsolutePositioning = true;
|
||||
isMoving = true;
|
||||
|
||||
// Snap immediately to the expected position to avoid a 1-frame pop.
|
||||
ApplyAbsolutePosition(Time.time);
|
||||
}
|
||||
|
||||
public void StopMovement()
|
||||
{
|
||||
isMoving = false;
|
||||
@@ -79,4 +106,17 @@ public class HoldNoteController : MonoBehaviour
|
||||
|
||||
public float ActivationTime => activationTime;
|
||||
public float CurrentSpeed => speed;
|
||||
public bool UsesAbsolutePositioning => useAbsolutePositioning;
|
||||
public float BaseSpawnYOffset => baseSpawnYOffset;
|
||||
public Vector3 SpawnPosition => spawnPosition;
|
||||
|
||||
private void ApplyAbsolutePosition(float time)
|
||||
{
|
||||
float elapsed = time - activationTime;
|
||||
float travelDistance = speed * elapsed;
|
||||
|
||||
Vector3 newPos = spawnPosition;
|
||||
newPos.y -= (baseSpawnYOffset + travelDistance);
|
||||
transform.position = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user