重写NoteManager
This commit is contained in:
39
Assets/Scripts/Manager/NoteManager.cs
Normal file
39
Assets/Scripts/Manager/NoteManager.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user