Пример #1
0
        public void KeyDown()
        {
            if (NoteTabSelected)
            {
                int noteCount = 0;
                foreach (var note in RGBData.Current.NoteList)
                {
                    if ((Keyboard.IsKeyDown(note.Value.Input1) && !note.Value.IsInput1Down) ||
                        (Keyboard.IsKeyDown(note.Value.Input2) && !note.Value.IsInput2Down))
                    {
                        if (Keyboard.IsKeyDown(note.Value.Input1))
                        {
                            note.Value.IsInput1Down = true;
                        }
                        if (Keyboard.IsKeyDown(note.Value.Input2))
                        {
                            note.Value.IsInput2Down = true;
                        }

                        PlayNote(note.Value);

                        double noteTime     = Music.CurrentTime;
                        double previousBeat = Music.PreviousBeat;
                        double nextBeat     = previousBeat + _BeatDelay;

                        noteTime =
                            noteTime - previousBeat < nextBeat - noteTime
                                                        ? previousBeat
                                                        : nextBeat;
                        //noteTime = Music.CurrentTime;

                        noteTime = (Convert.ToInt32(noteTime * 1000) + noteCount) / 1000.0;

                        //비교 연산을 위한 정수화
                        if (!NoteData.Any(x => Convert.ToInt32(x.NoteTime * 1000) == Convert.ToInt32(noteTime * 1000)))
                        {
                            NoteData.Add(
                                new NoteData
                            {
                                Note     = note.Value,
                                NoteTime = noteTime
                            }
                                );
                            Music.PreviousNote = noteTime;
                            RaisePropertyChanged(nameof(NoteData));
                        }

                        /*else if (noteTime == previousBeat)
                         * {
                         *      NoteData.Add(
                         *              new NoteData
                         *              {
                         *                      Note = note.Value,
                         *                      NoteTime = nextBeat
                         *              }
                         *      );
                         *      RaisePropertyChanged(nameof(NoteData));
                         * }*/
                    }
                    noteCount++;
                }
            }
        }