Пример #1
0
        /// <summary>
        /// This method will check if a note exists in the list of custom notes
        /// as well as the connection between the note and the new note of the pair
        /// </summary>
        public static bool CheckNoteExists(Note note, Note newNote)
        {
            Note checkNote;

            CustomNotes.TryGetValue(note, out checkNote);
            if (checkNote != null && checkNote == newNote)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
 /// <summary>
 /// This method will play the notes in the song in sequence
 /// </summary>
 public static void PlaySong()
 {
     Stop = false;
     foreach (INote note in Song)
     {
         if (!Stop)
         {
             try
             {
                 if (note is Note)
                 {
                     if (CustomNotes.ContainsKey((Note)note))
                     {
                         Note customNote;
                         CustomNotes.TryGetValue((Note)note, out customNote);
                         customNote.Play();
                     }
                     else
                     {
                         note.Play();
                     }
                 }
                 else
                 {
                     note.Play();
                 }
                 if (note is Note || note is MultiNote)
                 {
                     if (isFastSpeed)
                     {
                         Thread.Sleep(DelayAtFastSpeed);
                     }
                     else
                     {
                         Thread.Sleep(DelayAtNormalSpeed);
                     }
                 }
             }
             catch (AutoplayerTargetNotFoundException error)
             {
                 Stop = true;
                 SongWasInteruptedByException?.Invoke(error);
             }
             catch (ArgumentException)
             {
                 Stop = true;
                 SongWasInteruptedByException?.Invoke(new AutoplayerException($"The program encountered an invalid note. Please inform the developer of this incident so it can be added to the list of invalid characters. Info: '{note.ToString()}'"));
             }
         }
         else
         {
             //The foreach loop here is to avoid any keys getting stuck when the song is stopped by the stop keybinding
             foreach (INote n in Song)
             {
                 if (n is Note)
                 {
                     ((Note)n).Stop();
                 }
                 if (n is MultiNote)
                 {
                     ((MultiNote)n).Stop();
                 }
             }
             SongWasStopped?.Invoke();
         }
     }
     if (Loop)
     {
         PlaySong();
     }
     SongFinishedPlaying?.Invoke();
 }