This commit is contained in:
SoulliesOfficial
2025-07-21 05:42:20 -04:00
parent e483cfe502
commit bae0bfbc20
533 changed files with 172709 additions and 125965 deletions

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class NoteManager : MonoBehaviour
{
private List<(float activationTime, NoteBase note)> pendingNotes = new List<(float, NoteBase)>();
private int nextNoteIndex = 0;
public void RegisterNote(NoteBase note, float activationTime)
{
pendingNotes.Add((activationTime, note));
}
// 在所有物体注册完毕后,对列表进行一次排序
public void AllNotesRegistered()
{
pendingNotes.Sort((a, b) => a.activationTime.CompareTo(b.activationTime));
}
void Update()
{
// 如果所有音符都已激活,则不执行任何操作
if (nextNoteIndex >= pendingNotes.Count)
{
return;
}
// 检查下一个待激活的音符
while (nextNoteIndex < pendingNotes.Count &&
GameManager.instance.songTime >= pendingNotes[nextNoteIndex].activationTime)
{
pendingNotes[nextNoteIndex].note.gameObject.SetActive(true);
nextNoteIndex++;
}
}
}
}