重写NoteManager
This commit is contained in:
@@ -28,6 +28,7 @@ namespace Ichni
|
||||
public BackgroundController backgroundController;
|
||||
public GridController gridController;
|
||||
public CameraManager cameraManager;
|
||||
public NoteManager noteManager;
|
||||
public Ichni.Editor.PostProcessingManager postProcessingManager;
|
||||
public Canvas judgeHintCanvas;
|
||||
public Canvas inspectorCanvas;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Manager/NoteManager.cs.meta
Normal file
11
Assets/Scripts/Manager/NoteManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fe401fc051728b49a4e682f518ffc54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user