Exemplo n.º 1
0
        private void PlayThread()
        {
            Form1.WriteToConsole("Play Thread created...");
            try
            {
                while (true)
                {
                    if (!watch.IsRunning && Playing)
                    {
                        Form1.watchTime.Text = "Time: 0";
                        watch.Start();
                    }
                    else if (!Playing && watch.IsRunning)
                    {
                        Form1.console.Text = "";
                        watch.Reset();
                    }


                    if (!Playing)
                    {
                        Thread.Sleep(100);
                        continue;
                    }



                    int sectionSee = 0;

                    foreach (FNFSong.FNFSection sect in mBot.song.Sections)
                    {
                        sectionSee++;
                        List <FNFSong.FNFNote> notesToPlay = mBot.GetHitNotes(sect);

                        foreach (FNFSong.FNFNote n in notesToPlay)
                        {
                            Thread t = new Thread(() => HandleNote(n));
                            Form1.currentThreads.Add(t);
                            t.Start();
                        }

                        if (!Playing)
                        {
                            break;
                        }


                        if (Form1.Rendering)
                        {
                            Thread list = new Thread(() => rBot.ListNotes(notesToPlay));
                            Form1.currentThreads.Add(list);
                            list.Start();
                        }

                        while (notesPlayed != notesToPlay.Count && sectionSee == Form1.SectionSee)
                        {
                            Form1.watchTime.Text = "Time: " + watch.Elapsed.TotalSeconds.ToString();
                            Thread.Sleep(1);
                            if (!Playing)
                            {
                                break;
                            }
                        }

                        Form1.WriteToConsole("Section See: " + sectionSee);

                        if (sectionSee == Form1.SectionSee)
                        {
                            notesPlayed = 0;
                            Form1.WriteToConsole("---");
                            sectionSee = 0;
                        }
                    }
                    Form1.console.Text = "";
                    Playing            = false;
                    Form1.WriteToConsole("Completed!");
                }
            }
            catch (Exception e)
            {
                Form1.WriteToConsole("Exception on Play Thread\n" + e);
            }
        }
Exemplo n.º 2
0
        private void PlayThread()
        {
            ended = false;
            Form1.WriteToConsole("Play Thread created...");
            nPlay.Clear();
            int currentSect  = 0;
            int notesPPlayed = 0;
            int lastRendered = 0;

            try
            {
                while (true)
                {
                    if (!watch.IsRunning && Playing)
                    {
                        Form1.watchTime.Text = "Time: 0";
                        watch.Start();
                    }
                    else if (!Playing && watch.IsRunning)
                    {
                        Form1.console.Text = "";
                        watch.Reset();
                    }


                    if (!Playing)
                    {
                        Thread.Sleep(100);
                        continue;
                    }



                    int i = 0;



                    FNFSong.FNFSection sect = mBot.song.Sections[currentSect];

                    if (notesPPlayed >= sect.Notes.Count)
                    {
                        currentSect++;
                        notesPPlayed = 0;
                        sect         = mBot.song.Sections[currentSect];
                        Form1.WriteToConsole("Next section!");
                    }

                    List <FNFSong.FNFNote> notesToPlay = mBot.GetHitNotes(sect);

                    if (notesToPlay.Count == 0)
                    {
                        currentSect++;
                        Form1.WriteToConsole("Skiping to section " + currentSect);
                    }
                    else if (lastRendered != currentSect)
                    {
                        lastRendered = currentSect;
                        if (Form1.Rendering)
                        {
                            Form1.watchTime.Text = "Time: " + watch.Elapsed.TotalSeconds.ToString();
                            Thread list = new Thread(() => rBot.ListNotes(mBot.GetHitNotes(sect)));
                            Form1.currentThreads.Add(list);
                            list.Start();
                        }
                    }

                    foreach (FNFSong.FNFNote n in notesToPlay)
                    {
                        // ke default hit windows or something like em

                        if ((float)watch.Elapsed.TotalMilliseconds + kBot.offset >= (double)(n.Time - 22) && !nPlay.Contains(n))
                        {
                            HandleNote(n);
                            nPlay.Add(n);
                            notesPPlayed++;
                        }

                        i++;
                    }

                    // check if we should let go of holds

                    for (int ii = 0; ii < 4; ii++)
                    {
                        if (watch.ElapsedMilliseconds > holdTimes[ii] && holdTimes[ii] != 0)
                        {
                            holdTimes[ii] = 0;
                            switch (ii)
                            {
                            case 0:
                                simulator.Keyboard.KeyUp(VirtualKeyCode.LEFT);
                                break;

                            case 1:
                                simulator.Keyboard.KeyUp(VirtualKeyCode.DOWN);
                                break;

                            case 2:
                                simulator.Keyboard.KeyUp(VirtualKeyCode.UP);
                                break;

                            case 3:
                                simulator.Keyboard.KeyUp(VirtualKeyCode.RIGHT);
                                break;
                            }
                        }
                    }

                    if (!Playing)
                    {
                        break;
                    }


                    // Form1.WriteToConsole("Section See: " + sectionSee);
                    notesPlayed = 0;
                }
                Form1.console.Text = "";
                Playing            = false;
                Form1.WriteToConsole("Completed!");
                ended = true;
            }
            catch (Exception e)
            {
                Form1.WriteToConsole("Exception on Play Thread\n" + e);
            }
        }