Exemplo n.º 1
0
        private void UpdateNotes()
        {
            if (!musicIsPlaying || musicIsFinished)
            {
                return;
            }

            double relativeMusicTimestamp = Time.time - musicStartTimestamp;

            if (notes.Count > 0)
            {
                double noteTimestamp = notes.Peek().timestamp + eventOffsetInSeconds;
                if (!(noteTimestamp < relativeMusicTimestamp))
                {
                    return;
                }
                TimedNote note = notes.Dequeue();
                FireNoteEvent(note);

                if (notes.Count == 0)
                {
                    musicIsFinished = true;
                    OnSongFinished?.Invoke();
                }
            }
        }
Exemplo n.º 2
0
        private void BassGuidance(TimedNote note)
        {
            Debug.Log("Bass Guide");
            Guidance bassGuidance = Instantiate(bassPrefab, guidanceSpawnPosition.transform).GetComponent <Guidance>();

            bassGuidance.OnMiss += Miss;
            activeGuidance.Add(bassGuidance);
        }
Exemplo n.º 3
0
        private void SnareGuidance(TimedNote note)
        {
            Guidance snareGuidance = Instantiate(snarePrefab).GetComponent <Guidance>();

            snareGuidance.transform.SetParent(guidanceSpawnPosition.transform, false);
            snareGuidance.OnMiss += Miss;
            activeGuidance.Add(snareGuidance);
        }
Exemplo n.º 4
0
        private void FireNoteGuidanceEvent(TimedNote note)
        {
            switch (note.type)
            {
            case NoteType.Bass:
                OnBassGuidance?.Invoke(note);
                break;

            case NoteType.Rest:
                break;

            case NoteType.Snare:
                OnSnareGuidance?.Invoke(note);
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 5
0
        private void UpdateNoteGuidance()
        {
            if (!musicIsPlaying || musicIsFinished)
            {
                return;
            }

            double relativeMusicTimestamp = Time.time - musicStartTimestamp;

            if (noteGuidance.Count > 0)
            {
                double noteTimestamp = noteGuidance.Peek().timestamp;
                if (!(noteTimestamp < relativeMusicTimestamp))
                {
                    return;
                }
                TimedNote note = noteGuidance.Dequeue();
                FireNoteGuidanceEvent(note);
            }
        }
Exemplo n.º 6
0
 public void OnNote(TimedNote note)
 {
     activeNote = note;
 }