// Deactivates and returns a Note Object to the pool. public void ReturnNoteObjectToPool(NoteObject obj) { if (obj != null) { obj.enabled = false; obj.gameObject.SetActive(false); noteObjectPool.Push(obj); } }
// Checks if a Note Object is hit. If one is, it will perform the Hit and remove the object // from the trackedNotes Queue. public void CheckNoteHit() { // Always check only the first event as we clear out missed entries before. if (trackedNotes.Count > 0 && trackedNotes.Peek().IsNoteHittable()) { NoteObject hitNote = trackedNotes.Dequeue(); hitNote.OnHit(); } }
// Checks if the next Note Object should be spawned. If so, it will spawn the Note Object and // add it to the trackedNotes Queue. void CheckSpawnNext() { int samplesToTarget = GetSpawnSampleOffset(); int currentTime = gameController.DelayedSampleTime; // Spawn for all events within range. while (pendingEventIdx < laneEvents.Count && laneEvents[pendingEventIdx].StartSample < currentTime + samplesToTarget) { KoreographyEvent evt = laneEvents[pendingEventIdx]; NoteObject newObj = gameController.GetFreshNoteObject(); newObj.Initialize(evt, color, this, gameController); trackedNotes.Enqueue(newObj); pendingEventIdx++; } }