Пример #1
0
        /// <summary>
        /// Verify if the note placement match the situation and return the value
        /// </summary>
        /// <param name="lastLine">Last note line</param>
        /// <param name="lastLayer">Last note layer</param>
        /// <param name="type">Note color</param>
        /// <returns>Line, Layer</returns>
        static public (int, int) PlacementCheck(int direction, int type, ColorNote lastNote, ColorNote lastColor)
        {
            // Next possible line and layer
            int line  = -1;
            int layer = -1;
            int rand;

            do
            {
                if (type == ColorType.RED)
                {
                    rand  = RandNumber(0, PossibleRedPlacement.placement[direction].Count());
                    line  = PossibleRedPlacement.placement[direction][rand][0];
                    layer = PossibleRedPlacement.placement[direction][rand][1];
                }
                else if (type == ColorType.BLUE)
                {
                    rand  = RandNumber(0, PossibleBluePlacement.placement[direction].Count());
                    line  = PossibleBluePlacement.placement[direction][rand][0];
                    layer = PossibleBluePlacement.placement[direction][rand][1];
                }

                // Fix possible fused notes
                if (lastNote.line == line && lastNote.layer == layer)
                {
                    continue;
                }

                return(line, layer);
            } while (true);
        }
Пример #2
0
        /// <summary>
        /// Method to find specific pattern and remove the notes of the pattern from the main list of note
        /// </summary>
        /// <param name="notes">List of ColorNote</param>
        /// <returns>List of list of ColorNote (Pattern) and modified List of ColorNote</returns>
        static public (List <List <ColorNote> >, List <ColorNote>) FindPattern(List <ColorNote> notes)
        {
            // List of list to keep thing like sliders/stack/window/tower etc
            List <List <ColorNote> > patterns = new();

            // Stock pattern notes
            List <ColorNote> pattern = new();

            // To know if a pattern was found
            bool found = false;

            // Find all notes sliders/stack/window/tower
            for (int i = 0; i < notes.Count; i++)
            {
                if (i == notes.Count - 1)
                {
                    if (found)
                    {
                        pattern.Add(new(notes[i]));
                        notes.RemoveAt(i);
                        patterns.Add(new(pattern));
                        found = false;
                    }
                    break;
                }

                ColorNote now  = notes[i];
                ColorNote next = notes[i + 1];

                if (next.beat - now.beat >= 0 && next.beat - now.beat < 0.1)
                {
                    if (!found)
                    {
                        pattern = new();
                        found   = true;
                    }
                    pattern.Add(new(notes[i]));
                    notes.RemoveAt(i);
                    i--;
                }
                else
                {
                    if (found)
                    {
                        pattern.Add(new(notes[i]));
                        notes.RemoveAt(i);
                        i--;
                        patterns.Add(new(pattern));
                    }

                    found = false;
                }
            }

            return(patterns, notes);
        }
Пример #3
0
        /// <summary>
        /// Method to find the possible Head of a chain
        /// </summary>
        /// <param name="note">Current note</param>
        /// <param name="next">Next note</param>
        /// <param name="direction">Cut direction</param>
        /// <returns>True = Current note win over the next one as head</returns>
        internal static bool PossibleHead(ColorNote note, ColorNote next, int direction)
        {
            if (note.direction == CutDirection.ANY && next.direction == CutDirection.ANY && direction != 8)
            {
                if (next.line > note.line && (direction == 3 || direction == 5 || direction == 7))
                {
                    return(true);
                }
                if (next.line < note.line && (direction == 2 || direction == 4 || direction == 6))
                {
                    return(true);
                }
                if (next.layer > note.layer && (direction == 0 || direction == 4 || direction == 5))
                {
                    return(true);
                }
                if (next.layer < note.layer && (direction == 1 || direction == 6 || direction == 7))
                {
                    return(true);
                }
            }
            else if (note.direction == CutDirection.DOWN || note.direction == CutDirection.DOWN_LEFT || note.direction == CutDirection.DOWN_RIGHT)
            {
                if (next.direction == CutDirection.ANY || next.layer < note.layer)
                {
                    return(true);
                }
            }
            if (note.direction == CutDirection.UP || note.direction == CutDirection.UP_LEFT || note.direction == CutDirection.UP_RIGHT)
            {
                if (next.direction == CutDirection.ANY || next.layer > note.layer)
                {
                    return(true);
                }
            }
            if (note.direction == CutDirection.LEFT || note.direction == CutDirection.UP_LEFT || note.direction == CutDirection.DOWN_LEFT)
            {
                if (next.direction == CutDirection.ANY || next.line < note.line)
                {
                    return(true);
                }
            }
            if (note.direction == CutDirection.RIGHT || note.direction == CutDirection.UP_RIGHT || note.direction == CutDirection.DOWN_RIGHT)
            {
                if (next.direction == CutDirection.ANY || next.line > note.line)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #4
0
 public void Play(ColorNote note, int toneFreq, int durationInMS)
 {
     _con.Display(note.ToColor());
     if (toneFreq != 0)
     {
         Console.Beep(toneFreq, durationInMS);
     }
     else
     {
         Thread.Sleep(durationInMS);
     }
     _con.Display(BlynclightController.Color.Off);
     Thread.Sleep(10); // so we can actually see the off state...
 }
Пример #5
0
        static public (ColorNote, ColorNote) FixDoublePlacement(ColorNote red, ColorNote blue)
        {
            // Both on same layer
            if (red.layer == blue.layer && red.line != blue.line)
            {
                // Change the layer of one of the note
                if (SwingType.Horizontal.Contains(red.direction))
                {
                    if (red.layer == Layer.BOTTOM)
                    {
                        if (red.line == Line.LEFT)
                        {
                            red.layer++;
                        }
                        else if (red.line == Line.MIDDLE_LEFT || red.line == Line.MIDDLE_RIGHT)
                        {
                            red.layer = Layer.TOP;
                        }
                        else
                        {
                            if (SwingType.Up.Contains(blue.direction))
                            {
                                blue.layer = Layer.TOP;
                            }
                            else
                            {
                                red.layer++;
                            }
                        }
                    }
                    else if (red.layer == Layer.TOP)
                    {
                        if (red.line == Line.LEFT)
                        {
                            red.layer--;
                        }
                        else if (red.line == Line.MIDDLE_LEFT || red.line == Line.MIDDLE_RIGHT)
                        {
                            red.layer = Layer.BOTTOM;
                        }
                        else
                        {
                            red.layer--;
                        }
                    }
                }
                else if (SwingType.Horizontal.Contains(blue.direction))
                {
                    if (blue.layer == Layer.BOTTOM)
                    {
                        if (blue.line == Line.RIGHT)
                        {
                            blue.layer++;
                        }
                        else if (blue.line == Line.MIDDLE_LEFT || blue.line == Line.MIDDLE_RIGHT)
                        {
                            blue.layer = Layer.TOP;
                        }
                        else
                        {
                            if (SwingType.Up.Contains(red.direction))
                            {
                                red.layer = Layer.TOP;
                            }
                            else
                            {
                                blue.layer++;
                            }
                        }
                    }
                    else if (blue.layer == Layer.TOP)
                    {
                        if (blue.line == Line.RIGHT)
                        {
                            blue.layer--;
                        }
                        else if (blue.line == Line.MIDDLE_LEFT || blue.line == Line.MIDDLE_RIGHT)
                        {
                            blue.layer = Layer.BOTTOM;
                        }
                        else if (blue.layer == Layer.TOP)
                        {
                            if (blue.line == Line.LEFT)
                            {
                                blue.layer--;
                            }
                            else if (blue.line == Line.MIDDLE_LEFT || blue.line == Line.MIDDLE_RIGHT)
                            {
                                blue.layer = Layer.BOTTOM;
                            }
                            else
                            {
                                blue.layer--;
                            }
                        }
                    }
                }
            }
            // Both on the same line
            else if (red.line == blue.line && red.layer != blue.layer)
            {
                if (SwingType.Vertical.Contains(red.direction))
                {
                    // Change the line of one of the notes
                    if (red.line > 1)
                    {
                        if (red.layer != Layer.MIDDLE)
                        {
                            if (red.line != Line.LEFT)
                            {
                                red.line--;
                            }
                            else
                            {
                                red.line++;
                            }
                        }
                        else if (blue.layer == 0)
                        {
                            red.layer = 2;
                            if (red.line != Line.LEFT)
                            {
                                red.line--;
                            }
                            else
                            {
                                red.line++;
                            }
                        }
                        else if (blue.layer == 2)
                        {
                            red.layer = 0;
                            if (red.line != Line.LEFT)
                            {
                                red.line--;
                            }
                            else
                            {
                                red.line++;
                            }
                        }
                    }
                    else
                    {
                        if (blue.line != Line.RIGHT)
                        {
                            blue.line++;
                        }
                        else if (red.line != Line.LEFT)
                        {
                            red.line--;
                        }
                    }
                }
                else if (SwingType.Vertical.Contains(blue.direction))
                {
                    if (blue.line < 2)
                    {
                        if (blue.layer != Layer.MIDDLE)
                        {
                            if (blue.line != Line.RIGHT)
                            {
                                blue.line++;
                            }
                            else
                            {
                                blue.line--;
                            }
                        }
                        else if (red.layer == 0)
                        {
                            blue.layer = 2;
                            if (blue.line != Line.RIGHT)
                            {
                                blue.line++;
                            }
                            else
                            {
                                blue.line--;
                            }
                        }
                        else if (red.layer == 2)
                        {
                            blue.layer = 0;
                            if (blue.line != Line.RIGHT)
                            {
                                blue.line++;
                            }
                            else
                            {
                                blue.line--;
                            }
                        }
                    }
                    else
                    {
                        if (red.line != Line.LEFT)
                        {
                            red.line--;
                        }
                        else if (blue.line != Line.RIGHT)
                        {
                            blue.line++;
                        }
                    }
                }
            }

            // Diagonal
            if (SwingType.Diagonal.Contains(red.direction) || SwingType.Diagonal.Contains(blue.direction))
            {
                if (red.line == blue.line - 1 && red.layer == blue.layer - 1)
                {
                    if (blue.layer != 2)
                    {
                        blue.layer++;
                    }
                    else
                    {
                        red.layer--;
                    }
                }
                else if (red.line == blue.line - 1 && red.layer == blue.layer + 1)
                {
                    if (blue.layer != 0)
                    {
                        blue.layer--;
                    }
                    else
                    {
                        red.layer++;
                    }
                }
                else if (red.line == blue.line + 1 && red.layer == blue.layer + 1)
                {
                    if (blue.layer != 2)
                    {
                        (red.line, blue.line)   = (blue.line, red.line);
                        (red.layer, blue.layer) = (blue.layer, red.layer);
                        blue.layer++;
                    }
                    else
                    {
                        (red.line, blue.line)   = (blue.line, red.line);
                        (red.layer, blue.layer) = (blue.layer, red.layer);
                        red.layer--;
                    }
                }
                else if (red.line == blue.line + 1 && red.layer == blue.layer - 1)
                {
                    if (blue.layer != 0)
                    {
                        (red.line, blue.line)   = (blue.line, red.line);
                        (red.layer, blue.layer) = (blue.layer, red.layer);
                        blue.layer--;
                    }
                    else
                    {
                        (red.line, blue.line)   = (blue.line, red.line);
                        (red.layer, blue.layer) = (blue.layer, red.layer);
                        red.layer++;
                    }
                }
            }

            return(red, blue);
        }
Пример #6
0
        static public (List <ColorNote>, List <BurstSliderData>) Emilia(List <ColorNote> noteTemp, bool IsLimited, bool removeSide)
        {
            // List to keep new Chain (converted from pattern)
            List <BurstSliderData> burstSliders = new();

            // List to hold note per type
            List <ColorNote> red  = new();
            List <ColorNote> blue = new();

            // Remove all "up swing", otherwise modify their direction
            for (int i = 0; i < noteTemp.Count; i++)
            {
                ColorNote note = noteTemp[i];

                switch (note.direction)
                {
                case CutDirection.UP: if (IsLimited)
                    {
                        noteTemp.Remove(note); i--;
                    }
                    else
                    {
                        note.direction = CutDirection.DOWN;
                    } break;

                case CutDirection.UP_LEFT: if (IsLimited)
                    {
                        noteTemp.Remove(note); i--;
                    }
                    else
                    {
                        note.direction = CutDirection.DOWN_LEFT;
                    } break;

                case CutDirection.UP_RIGHT: if (IsLimited)
                    {
                        noteTemp.Remove(note); i--;
                    }
                    else
                    {
                        note.direction = CutDirection.DOWN_RIGHT;
                    } break;

                case CutDirection.LEFT: if (removeSide)
                    {
                        noteTemp.Remove(note); i--;
                    }
                    else
                    {
                        note.direction = CutDirection.DOWN_LEFT;
                    } break;

                case CutDirection.RIGHT: if (removeSide)
                    {
                        noteTemp.Remove(note); i--;
                    }
                    else
                    {
                        note.direction = CutDirection.DOWN_RIGHT;
                    } break;
                }
            }

            // Separate note per type
            foreach (ColorNote note in noteTemp)
            {
                if (note.color == ColorType.BLUE)
                {
                    blue.Add(note);
                }
                else if (note.color == ColorType.RED)
                {
                    red.Add(note);
                }
            }

            // Find all sliders, stacks, tower, etc. to turn them into down Chain or to modify them accordingly
            List <List <ColorNote> > sliders = new();
            List <ColorNote>         slider  = new();
            bool found = false;

            // Find all blue pattern
            for (int i = 0; i < blue.Count; i++)
            {
                if (i == blue.Count - 1)
                {
                    if (found)
                    {
                        slider.Add(new(blue[i]));
                        blue.RemoveAt(i);
                        sliders.Add(new(slider));
                    }
                    break;
                }
                ColorNote now  = blue[i];
                ColorNote next = blue[i + 1];

                if (next.beat - now.beat > 0 && next.beat - now.beat < 0.1)
                {
                    if (!found)
                    {
                        slider = new();
                        found  = true;
                    }
                    slider.Add(new(blue[i]));
                    blue.RemoveAt(i);
                    i--;
                }
                else if (next.beat - now.beat == 0 && next.direction == now.direction) // Stack/Window/Tower
                {
                    if (next.line > now.line && next.layer < now.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        int temp = next.layer;
                        next.layer = now.layer;
                        now.layer  = temp;
                    }
                    else if (next.line > now.line && next.layer == now.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        if (next.layer != 2)
                        {
                            next.layer++;
                        }
                        else
                        {
                            now.layer--;
                        }
                    }
                    else if (now.line > next.line && now.layer < next.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        int temp = now.layer;
                        now.layer  = next.layer;
                        next.layer = temp;
                    }
                    else if (now.line > next.line && now.layer == next.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        if (now.layer != 2)
                        {
                            now.layer++;
                        }
                        else
                        {
                            next.layer--;
                        }
                    }
                    else if (next.line > now.line && next.layer > now.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        int temp = next.layer;
                        next.layer = now.layer;
                        now.layer  = temp;
                    }
                    else if (next.line > now.line && next.layer == now.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        if (next.layer != 0)
                        {
                            next.layer--;
                        }
                        else
                        {
                            now.layer++;
                        }
                    }
                    else if (now.line > next.line && now.layer < next.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        int temp = now.layer;
                        now.layer  = next.layer;
                        next.layer = temp;
                    }
                    else if (now.line > next.line && now.layer == next.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        if (now.layer != 0)
                        {
                            now.layer--;
                        }
                        else
                        {
                            next.layer++;
                        }
                    }
                }
                else
                {
                    if (found)
                    {
                        slider.Add(new(blue[i]));
                        blue.RemoveAt(i);
                        i--;
                        sliders.Add(new(slider));
                    }

                    found = false;
                }
            }

            // Find all red patterns
            for (int i = 0; i < red.Count; i++)
            {
                if (i == red.Count - 1)
                {
                    if (found)
                    {
                        slider.Add(new(red[i]));
                        red.RemoveAt(i);
                        sliders.Add(new(slider));
                    }
                    break;
                }
                ColorNote now  = red[i];
                ColorNote next = red[i + 1];

                if (next.beat - now.beat > 0 && next.beat - now.beat < 0.1)
                {
                    if (!found)
                    {
                        slider = new();
                        found  = true;
                    }
                    slider.Add(new(red[i]));
                    red.RemoveAt(i);
                    i--;
                }
                else if (next.beat - now.beat == 0 && next.direction == now.direction) // Stack/Window/Tower
                {
                    if (next.line > now.line && next.layer < now.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        int temp = next.layer;
                        next.layer = now.layer;
                        now.layer  = temp;
                    }
                    else if (next.line > now.line && next.layer == now.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        if (next.layer != 2)
                        {
                            next.layer++;
                        }
                        else
                        {
                            now.layer--;
                        }
                    }
                    else if (now.line > next.line && now.layer < next.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        int temp = now.layer;
                        now.layer  = next.layer;
                        next.layer = temp;
                    }
                    else if (now.line > next.line && now.layer == next.layer && now.direction == CutDirection.DOWN_LEFT)
                    {
                        if (now.layer != 2)
                        {
                            now.layer++;
                        }
                        else
                        {
                            next.layer--;
                        }
                    }
                    else if (next.line > now.line && next.layer > now.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        int temp = next.layer;
                        next.layer = now.layer;
                        now.layer  = temp;
                    }
                    else if (next.line > now.line && next.layer == now.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        if (next.layer != 0)
                        {
                            next.layer--;
                        }
                        else
                        {
                            now.layer++;
                        }
                    }
                    else if (now.line > next.line && now.layer < next.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        int temp = now.layer;
                        now.layer  = next.layer;
                        next.layer = temp;
                    }
                    else if (now.line > next.line && now.layer == next.layer && now.direction == CutDirection.DOWN_RIGHT)
                    {
                        if (now.layer != 0)
                        {
                            now.layer--;
                        }
                        else
                        {
                            next.layer++;
                        }
                    }
                }
                else
                {
                    if (found)
                    {
                        slider.Add(new(red[i]));
                        red.RemoveAt(i);
                        i--;
                        sliders.Add(new(slider));
                    }

                    found = false;
                }
            }

            // Turn slider into chain
            for (int i = 0; i < sliders.Count; i++)
            {
                if (sliders[i].First().color == ColorType.BLUE)
                {
                    blue.Add(sliders[i].First());
                }
                else if (sliders[i].First().color == ColorType.RED)
                {
                    red.Add(sliders[i].First());
                }

                if (sliders[i].Last().layer > sliders[i].First().layer)
                {
                    int temp = sliders[i].Last().layer;
                    sliders[i].Last().layer  = sliders[i].First().layer;
                    sliders[i].First().layer = temp;
                }
                if (sliders[i].Last().line > sliders[i].First().line&& sliders[i].First().direction == CutDirection.DOWN_LEFT)
                {
                    int temp = sliders[i].Last().line;
                    sliders[i].Last().line  = sliders[i].First().line;
                    sliders[i].First().line = temp;
                }
                if (sliders[i].Last().line < sliders[i].First().line&& sliders[i].First().direction == CutDirection.DOWN_RIGHT)
                {
                    int temp = sliders[i].Last().line;
                    sliders[i].Last().line  = sliders[i].First().line;
                    sliders[i].First().line = temp;
                }

                int             size      = Utils.RandNumber(4, 9);
                BurstSliderData newSlider = new(sliders[i].First(), sliders[i].Last().beat, sliders[i].Last().line, sliders[i].Last().layer, size, 0.8f);
                burstSliders.Add(newSlider);
            }

            // Create a new list with the new notes
            noteTemp = new(blue);
            noteTemp.AddRange(red);

            noteTemp = noteTemp.OrderBy(x => x.beat).ToList();

            return(noteTemp, burstSliders);
        }
Пример #7
0
 public BlinkNote(ColorNote note, int toneFreq, int duration)
 {
     _note     = note;
     _tone     = toneFreq;
     _duration = duration;
 }