好多新内容

This commit is contained in:
2026-07-22 05:35:53 +08:00
parent b5d1cdcbc5
commit 15649d02f8
128 changed files with 5956 additions and 673 deletions
@@ -46,10 +46,12 @@ public class InputManager : MonoBehaviour
private KeyCode[] cachedKeys = new KeyCode[5];
private bool pauseBlockedLastFrame = false;
// Per-track held state. Written by both keyboard (Update) and touch (PressTrack/
// Per-track held count. Written by both keyboard (Update) and touch (PressTrack/
// ReleaseTrack) so hold-note logic can query one platform-agnostic source instead
// of polling Input.GetKey directly (which cannot be driven by touch on Android).
private bool[] trackHeld = new bool[5];
// Count-based tracking fixes multi-touch on the same lane: one finger lifting no
// longer releases the lane while another finger is still holding it.
private int[] trackHeldCount = new int[5];
/// <summary>
/// True while the given track (0-4) is currently held, regardless of whether the
@@ -57,8 +59,8 @@ public class InputManager : MonoBehaviour
/// </summary>
public bool IsTrackHeld(int trackIndex)
{
if (trackIndex < 0 || trackIndex >= trackHeld.Length) return false;
return trackHeld[trackIndex];
if (trackIndex < 0 || trackIndex >= trackHeldCount.Length) return false;
return trackHeldCount[trackIndex] > 0;
}
private void Awake()
@@ -145,9 +147,10 @@ public class InputManager : MonoBehaviour
public void PressTrack(int index)
{
if (index < 0 || index >= TrackColors.Length) return;
if (trackHeld[index]) return; // already held; avoid duplicate press events
bool wasHeld = trackHeldCount[index] > 0;
trackHeldCount[index]++;
trackHeld[index] = true;
if (wasHeld) return; // already held; avoid duplicate press events
KeyCode key = cachedKeys[index];
if (key != KeyCode.None)
@@ -170,9 +173,10 @@ public class InputManager : MonoBehaviour
public void ReleaseTrack(int index)
{
if (index < 0 || index >= TrackColors.Length) return;
if (!trackHeld[index]) return; // not held; nothing to release
if (trackHeldCount[index] <= 0) return; // not held; nothing to release
trackHeld[index] = false;
trackHeldCount[index]--;
if (trackHeldCount[index] > 0) return; // another finger/key is still holding this lane
KeyCode key = cachedKeys[index];
if (key != KeyCode.None)
@@ -204,10 +208,14 @@ public class InputManager : MonoBehaviour
for (int i = 0; i < TrackColors.Length; i++)
{
string color = TrackColors[i];
trackHeld[i] = false; // clear held state so hold notes don't see a stale press after pause/clear
bool wasHeld = trackHeldCount[i] > 0;
trackHeldCount[i] = 0; // clear held state so hold notes don't see a stale press after pause/clear
KeyCode key = KeyBindingManager.GetKeyForColor(color);
if (key == KeyCode.None) continue;
try { OnKeyReleased?.Invoke(key); } catch { }
if (wasHeld)
{
try { OnKeyReleased?.Invoke(key); } catch { }
}
int index = GetIndexForColor(color);
if (laneSprites != null && index >= 0 && index < laneSprites.Length)