Exemple #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();
                }
            }
        }
Exemple #2
0
        private void SetUpEvents()
        {
            _hubConnection.On <CurrentSong>("startSongCommandNotification", currentSong =>
            {
                OnSongStarted?.Invoke(this, currentSong);
            });

            _hubConnection.On <CurrentSong>("finishSongCommandNotification", currentSong =>
            {
                OnSongFinished?.Invoke(this, currentSong);
            });

            _hubConnection.On <Song>("addSongCommandNotification", song =>
            {
                OnSongAdded?.Invoke(this, song);
            });

            _hubConnection.On <SongToRemove>("removeSongCommandNotification", song =>
            {
                OnRemoveSong?.Invoke(this, song);
            });

            _hubConnection.On("endSessionCommandNotification", () =>
            {
                OnSessionEnded?.Invoke(this, null);
            });

            _hubConnection.On("startSessionCommandNotification", () =>
            {
                OnRemoveSong?.Invoke(this, null);
            });
        }