original ver 25/06/01

This commit is contained in:
GardeniaRabbit
2025-06-02 00:48:08 +08:00
committed by FloatGaming
commit 89e03899f0
1065 changed files with 183622 additions and 0 deletions
@@ -0,0 +1,58 @@
using System.Collections.Generic;
using UnityEngine;
public class TrackKeyManager : MonoBehaviour
{
public static TrackKeyManager Instance { get; private set; }
private Dictionary<int, Queue<KeyCode>> trackKeyMappings = new Dictionary<int, Queue<KeyCode>>();
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
/// <summary>
/// 当音符进入判定区域时,添加按键映射
/// </summary>
public void RegisterKey(int trackIndex, KeyCode key)
{
if (!trackKeyMappings.ContainsKey(trackIndex))
trackKeyMappings[trackIndex] = new Queue<KeyCode>();
trackKeyMappings[trackIndex].Enqueue(key);
}
/// <summary>
/// 当音符离开判定区域时,移除按键映射
/// </summary>
public void UnregisterKey(int trackIndex, KeyCode key)
{
if (!trackKeyMappings.ContainsKey(trackIndex) || trackKeyMappings[trackIndex].Count == 0)
return;
if (trackKeyMappings[trackIndex].Peek() == key)
{
trackKeyMappings[trackIndex].Dequeue();
}
}
/// <summary>
/// 获取轨道当前的按键(队列头)
/// </summary>
public KeyCode GetCurrentKey(int trackIndex)
{
if (trackKeyMappings.ContainsKey(trackIndex) && trackKeyMappings[trackIndex].Count > 0)
{
return trackKeyMappings[trackIndex].Peek();
}
return KeyCode.None; // 无按键
}
}