// Use this for initialization void Awake() { editor = GetComponent <ChartEditor>(); GameObject groupMovePool = new GameObject("Main Song Object Pool"); noteParent = new GameObject("Notes"); starpowerParent = new GameObject("Starpowers"); bpmParent = new GameObject("BPMs"); timesignatureParent = new GameObject("Time Signatures"); sectionParent = new GameObject("Sections"); songEventParent = new GameObject("Global Events"); chartEventParent = new GameObject("Chart Events"); notePool = new NotePool(noteParent, editor.notePrefab, NOTE_POOL_SIZE); noteParent.transform.SetParent(groupMovePool.transform); spPool = new StarpowerPool(starpowerParent, editor.starpowerPrefab, POOL_SIZE); starpowerParent.transform.SetParent(groupMovePool.transform); bpmPool = new BPMPool(bpmParent, editor.bpmPrefab, POOL_SIZE); bpmParent.transform.SetParent(groupMovePool.transform); tsPool = new TimesignaturePool(timesignatureParent, editor.tsPrefab, POOL_SIZE); timesignatureParent.transform.SetParent(groupMovePool.transform); sectionPool = new SectionPool(sectionParent, editor.sectionPrefab, POOL_SIZE); sectionParent.transform.SetParent(groupMovePool.transform); songEventPool = new EventPool(songEventParent, editor.songEventPrefab, POOL_SIZE); songEventParent.transform.SetParent(groupMovePool.transform); chartEventPool = new ChartEventPool(chartEventParent, editor.chartEventPrefab, POOL_SIZE); chartEventParent.transform.SetParent(groupMovePool.transform); }
/// <summary> /// 添加一个音符到场景中,主线程 /// 调用的太早的话Stage.Main会为空,请使用 region -> MonoMessage 里提供的函数调用 /// 注意:你可以在任意时间Add任意Note到Stage里,即便是在初始化时就把所有Note都Add进去,Stage也会正常运转 /// 但是Add太多Note会影响性能,所以请在Note出现前几秒把它Add进Stage /// 你不需要清理过期的Note /// </summary> /// <param name="info"> /// 这个音符的信息 /// </param> public static void AddNote(NoteInfo info) { pendingNotes[info.PitchId] = info; Transform tf = NotePool.SpawnToDefault("Note"); Note n = tf.GetComponent <Note>(); if (n) { n.NoteInfo = info; } SortNotePool(); }
public static void RemoveAllNotes(NoteState state) { int len = NotePool.Count; for (int i = 0; i < len; i++) { Note note = NotePool[i].GetComponent <Note>(); if (note && note.State == state) { NotePool.DespawnToDefault(NotePool[i]); i--; len--; } } }
// Use this for initialization void Awake() { editor = ChartEditor.Instance; GameObject groupMovePool = new GameObject("Main Song Object Pool"); noteParent = new GameObject("Notes"); starpowerParent = new GameObject("Starpowers"); bpmParent = new GameObject("BPMs"); timesignatureParent = new GameObject("Time Signatures"); sectionParent = new GameObject("Sections"); songEventParent = new GameObject("Global Events"); chartEventParent = new GameObject("Chart Events"); notePool = new NotePool(noteParent, editor.assets.notePrefab, NOTE_POOL_SIZE); noteParent.transform.SetParent(groupMovePool.transform); spPool = new StarpowerPool(starpowerParent, editor.assets.starpowerPrefab, POOL_SIZE); starpowerParent.transform.SetParent(groupMovePool.transform); bpmPool = new BPMPool(bpmParent, editor.assets.bpmPrefab, POOL_SIZE); bpmParent.transform.SetParent(groupMovePool.transform); tsPool = new TimesignaturePool(timesignatureParent, editor.assets.tsPrefab, POOL_SIZE); timesignatureParent.transform.SetParent(groupMovePool.transform); sectionPool = new SectionPool(sectionParent, editor.assets.sectionPrefab, POOL_SIZE); sectionParent.transform.SetParent(groupMovePool.transform); songEventPool = new EventPool(songEventParent, editor.assets.songEventPrefab, POOL_SIZE); songEventParent.transform.SetParent(groupMovePool.transform); chartEventPool = new ChartEventPool(chartEventParent, editor.assets.chartEventPrefab, POOL_SIZE); chartEventParent.transform.SetParent(groupMovePool.transform); editor.events.hyperspeedChangeEvent.Register(SetAllPoolsDirty); editor.events.chartReloadedEvent.Register(SetAllPoolsDirty); editor.events.leftyFlipToggledEvent.Register(SetAllPoolsDirty); editor.events.drumsModeOptionChangedEvent.Register(SetAllNotesDirty); editor.events.playbackStoppedEvent.Register(OnPlaybackStopped); }
private void Awake() { notePoolInstanse = this; }
private void Awake() { instance = this; }
// public NotePool notePool = noteHolder.NotePool; // Start is called before the first frame update void Start() { noteHolder = GameObject.Find("NoteHolder"); notePool = noteHolder.GetComponent <NotePool>(); }
/// <summary> /// 瞬间清除台面上的所有音符 /// </summary> public static void RemoveAllNotes() { NotePool.DespawnAllToDefault(); }
private static void SortNotePool() { NotePool.Sort(NoteTimeSorter.TheNoteTimeSorter); }