重写NoteManager
This commit is contained in:
@@ -33,6 +33,46 @@ namespace Ichni.RhythmGame
|
||||
[FormerlySerializedAs("isJudged")] public bool isFirstJudged;
|
||||
public override int HierarchyPriority => -10;
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
base.AfterInitialize();
|
||||
|
||||
float beyondTime = 0f;
|
||||
|
||||
foreach (EffectBase effectBase in noteVisual.effectSubmodule.effectCollection["Generate"])
|
||||
{
|
||||
if (effectBase is NoteGenerateEffect ge)
|
||||
{
|
||||
ge.Recover();
|
||||
beyondTime = Mathf.Max(beyondTime, ge.generateTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
effectBase.Recover();
|
||||
}
|
||||
}
|
||||
|
||||
float finishTime = 0f;
|
||||
List<EffectBase> finishEffects = new List<EffectBase>();
|
||||
finishEffects.AddRange(noteVisual.effectSubmodule.effectCollection["GeneralJudge"]);
|
||||
finishEffects.AddRange(noteVisual.effectSubmodule.effectCollection["Perfect"]);
|
||||
finishEffects.AddRange(noteVisual.effectSubmodule.effectCollection["Good"]);
|
||||
finishEffects.AddRange(noteVisual.effectSubmodule.effectCollection["Bad"]);
|
||||
finishEffects.AddRange(noteVisual.effectSubmodule.effectCollection["Miss"]);
|
||||
|
||||
foreach (EffectBase effectBase in finishEffects)
|
||||
{
|
||||
finishTime = Mathf.Max(finishTime, effectBase.effectTime);
|
||||
}
|
||||
|
||||
if (exactJudgeTime - beyondTime - 0.5f > -EditorManager.instance.songInformation.delay)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
EditorManager.instance.noteManager.RegisterNote(this, exactJudgeTime - beyondTime - 0.5f, exactJudgeTime + finishTime + 1.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在MovableTrack上更新Note的位置,注意HoldNote需要重写这个方法
|
||||
/// </summary>
|
||||
@@ -75,6 +115,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
foreach (SampleWindow i in SampleWindow.instances.Where(i => i.gameElement)) i.OnceSpawnNote();
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
var editor = EditorManager.instance;
|
||||
|
||||
@@ -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