39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public class NoteManager : MonoBehaviour
|
|
{
|
|
private List<(NoteBase note, float activationTime, float finishTime)> pendingNotes = new List<(NoteBase, float, float)>();
|
|
private int nextNoteIndex = 0;
|
|
|
|
public void RegisterNote(NoteBase note, float activationTime, float finishTime)
|
|
{
|
|
pendingNotes.Add((note, activationTime, finishTime));
|
|
}
|
|
|
|
// 在所有物体注册完毕后,对列表进行一次排序
|
|
public void AllNotesRegistered()
|
|
{
|
|
pendingNotes.Sort((a, b) => a.activationTime.CompareTo(b.activationTime));
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
foreach ((NoteBase note, float activationTime, float finishTime) note in pendingNotes)
|
|
{
|
|
if (EditorManager.instance.songInformation.songTime >= note.activationTime &&
|
|
EditorManager.instance.songInformation.songTime <= note.finishTime)
|
|
{
|
|
note.note.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
note.note.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |