diff --git a/Lolighter/Algorithm/Bomb.cs b/Lolighter/Algorithm/Bomb.cs new file mode 100644 index 0000000..dc24686 --- /dev/null +++ b/Lolighter/Algorithm/Bomb.cs @@ -0,0 +1,447 @@ +using Lolighter.Data.Structure; +using System; +using System.Collections.Generic; +using System.Linq; +using static Lolighter.Info.Helper; + +namespace Lolighter.Algorithm +{ + class Bomb + { + public static List CreateBomb(List noteTemp) + { + Random random = new(); + List newBomb = new(); + ColorNote n; + + for (int i = 0; i < noteTemp.Count(); i++) //For each note + { + n = noteTemp[i]; + + if (n.direction == CutDirection.ANY) //Skip Any + { + continue; + } + + switch (n.layer) //Each layer, index and cut direction are handled manually. + { + case Layer.BOTTOM: + switch (n.line) + { + case Line.LEFT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + break; + case CutDirection.LEFT: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + case CutDirection.RIGHT: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.BOTTOM)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.BOTTOM)); + break; + case CutDirection.UP_RIGHT: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + case CutDirection.DOWN_LEFT: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.BOTTOM)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.BOTTOM)); + break; + case CutDirection.UP_LEFT: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + case CutDirection.DOWN_RIGHT: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + } + break; + case Line.RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + break; + case CutDirection.LEFT: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + case CutDirection.RIGHT: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + } + break; + } + break; + case Layer.MIDDLE: + switch (n.line) + { + case Line.LEFT: + switch (n.direction) + { + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.BOTTOM)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.BOTTOM)); + } + break; + case CutDirection.UP_LEFT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + break; + case CutDirection.UP_RIGHT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + break; + case CutDirection.DOWN_LEFT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + break; + case CutDirection.DOWN_RIGHT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + } + break; + case CutDirection.UP_LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.BOTTOM)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + } + break; + case CutDirection.UP_RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.DOWN_LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.DOWN_RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.BOTTOM)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + } + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.UP_LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.TOP)); + } + break; + case CutDirection.UP_RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.DOWN_LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.DOWN_RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.BOTTOM)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.TOP)); + } + break; + } + break; + case Line.RIGHT: + switch (n.direction) + { + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.TOP)); + } + else + { + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.BOTTOM)); + } + break; + case CutDirection.UP_LEFT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + break; + case CutDirection.UP_RIGHT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + break; + case CutDirection.DOWN_LEFT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + break; + case CutDirection.DOWN_RIGHT: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.BOTTOM)); + break; + } + break; + } + break; + case Layer.TOP: + switch (n.line) + { + case Line.LEFT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_LEFT, Layer.TOP)); + break; + case CutDirection.LEFT: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + case CutDirection.RIGHT: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.MIDDLE)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.TOP)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.LEFT, Layer.TOP)); + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.TOP)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.TOP)); + break; + } + break; + case Line.RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + break; + case CutDirection.DOWN: + newBomb.Add(new BombNote(n.beat, Line.MIDDLE_RIGHT, Layer.TOP)); + break; + case CutDirection.LEFT: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + case CutDirection.RIGHT: + newBomb.Add(new BombNote(n.beat, Line.RIGHT, Layer.MIDDLE)); + break; + } + break; + } + break; + } + } + + List compare = new(noteTemp); + + foreach (var bomb in newBomb) + { + compare.Add(new(bomb)); + } + + compare = compare.OrderBy(o => o.beat).ToList(); + + for (int i = compare.Count() - 5; i > 4; i--) //Dumb method to remove bomb that conflict with a note. + { + if (compare[i].color == 3) + { + if (compare[i].beat - compare[i - 1].beat <= 0.25 && compare[i].layer == compare[i - 1].layer && compare[i].line == compare[i - 1].line) + { + compare.Remove(compare[i]); + } + else if (compare[i].beat - compare[i - 2].beat <= 0.25 && compare[i].layer == compare[i - 2].layer && compare[i].line == compare[i - 2].line) + { + compare.Remove(compare[i]); + } + else if (compare[i].beat - compare[i - 3].beat <= 0.25 && compare[i].layer == compare[i - 3].layer && compare[i].line == compare[i - 3].line) + { + compare.Remove(compare[i]); + } + else if (compare[i].beat - compare[i - 4].beat <= 0.25 && compare[i].layer == compare[i - 4].layer && compare[i].line == compare[i - 4].line) + { + compare.Remove(compare[i]); + } + else if (compare[i + 1].beat - compare[i].beat <= 0.25 && compare[i].layer == compare[i + 1].layer && compare[i].line == compare[i + 1].line) + { + compare.Remove(compare[i]); + } + else if (compare[i + 2].beat - compare[i].beat <= 0.25 && compare[i].layer == compare[i + 2].layer && compare[i].line == compare[i + 2].line) + { + compare.Remove(compare[i]); + } + else if (compare[i + 3].beat - compare[i].beat <= 0.25 && compare[i].layer == compare[i + 3].layer && compare[i].line == compare[i + 3].line) + { + compare.Remove(compare[i]); + } + else if (compare[i + 4].beat - compare[i].beat <= 0.25 && compare[i].layer == compare[i + 4].layer && compare[i].line == compare[i + 4].line) + { + compare.Remove(compare[i]); + } + } + } + + newBomb.Clear(); + + foreach (var bomb in compare) + { + if(bomb.color == 3) + { + newBomb.Add(new(bomb)); + } + } + + return newBomb; + } + } +} diff --git a/Lolighter/Algorithm/Chain.cs b/Lolighter/Algorithm/Chain.cs new file mode 100644 index 0000000..32b0567 --- /dev/null +++ b/Lolighter/Algorithm/Chain.cs @@ -0,0 +1,382 @@ +using Lolighter.Data.Structure; +using System.Collections.Generic; +using System.Linq; +using static Lolighter.Info.Helper; + +namespace Lolighter.Algorithm +{ + class Chain + { + static public (List, List) Chains(List noteTemp, int size = 4) + { + List burstSliders = new(); + + List red = new(); + List blue = new(); + + foreach (ColorNote note in noteTemp) + { + if (note.color == ColorType.BLUE) + { + blue.Add(note); + } + else if (note.color == ColorType.RED) + { + red.Add(note); + } + } + + List> others = new(); + List other = new(); + bool found = false; + + // Find all blue sliders/stack/window/tower + for (int i = 0; i < blue.Count; i++) + { + if (i == blue.Count - 1) + { + if (found) + { + other.Add(new(blue[i])); + blue.RemoveAt(i); + others.Add(new(other)); + found = false; + } + break; + } + ColorNote now = blue[i]; + ColorNote next = blue[i + 1]; + + if (next.beat - now.beat >= 0 && next.beat - now.beat < 0.1) + { + if (!found) + { + other = new(); + found = true; + } + other.Add(new(blue[i])); + blue.RemoveAt(i); + i--; + } + else + { + if (found) + { + other.Add(new(blue[i])); + blue.RemoveAt(i); + i--; + others.Add(new(other)); + } + + found = false; + } + } + + // find all red sliders/stack/window/tower + for (int i = 0; i < red.Count; i++) + { + if (i == red.Count - 1) + { + if (found) + { + other.Add(new(red[i])); + red.RemoveAt(i); + others.Add(new(other)); + } + break; + } + ColorNote now = red[i]; + ColorNote next = red[i + 1]; + + if (next.beat - now.beat >= 0 && next.beat - now.beat < 0.1) + { + if (!found) + { + other = new(); + found = true; + } + other.Add(new(red[i])); + red.RemoveAt(i); + i--; + } + else + { + if (found) + { + other.Add(new(red[i])); + red.RemoveAt(i); + i--; + others.Add(new(other)); + } + + found = false; + } + } + + List temp = new(blue); + temp.AddRange(red); + + // Create chain for the remaining notes + foreach (ColorNote now in temp) + { + switch (now.layer) //Process the note into a sliders depending on layer, lane and cut direction manually. This is pretty Pepega. + { + case Layer.BOTTOM: + switch (now.line) + { + case Line.LEFT: + switch (now.direction) + { + case CutDirection.UP: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 2, size, 0.8f)); + break; + case CutDirection.RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 0, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 1, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 1, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 0, size, 0.8f)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (now.direction) + { + case CutDirection.UP: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 2, size, 0.8f)); + break; + case CutDirection.LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 0, size, 0.8f)); + break; + case CutDirection.RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 0, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 1, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 1, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 0, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 0, size, 0.8f)); + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (now.direction) + { + case CutDirection.UP: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 2, size, 0.8f)); + break; + case CutDirection.LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 0, size, 0.8f)); + break; + case CutDirection.RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 0, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 1, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 1, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 0, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 0, size, 0.8f)); + break; + } + break; + case Line.RIGHT: + switch (now.direction) + { + case CutDirection.UP: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 2, size, 0.8f)); + break; + case CutDirection.LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 0, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 1, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 1, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 0, size, 0.8f)); + break; + } + break; + } + break; + case Layer.MIDDLE: + switch (now.line) + { + case Line.LEFT: + switch (now.direction) + { + case CutDirection.UP: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 2, size, 0.8f)); + break; + case CutDirection.DOWN: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 0, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 2, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 0, size, 0.8f)); + break; + } + break; + case Line.RIGHT: + switch (now.direction) + { + case CutDirection.UP: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 2, size, 0.8f)); + break; + case CutDirection.DOWN: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 0, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 2, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 0, size, 0.8f)); + break; + } + break; + } + break; + case Layer.TOP: + switch (now.line) + { + case Line.LEFT: + switch (now.direction) + { + case CutDirection.DOWN: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 0, size, 0.8f)); + break; + case CutDirection.RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 2, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 2, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 1, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 1, size, 0.8f)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (now.direction) + { + case CutDirection.DOWN: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 0, size, 0.8f)); + break; + case CutDirection.LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 2, size, 0.8f)); + break; + case CutDirection.RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 2, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 2, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 2, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 1, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 1, size, 0.8f)); + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (now.direction) + { + case CutDirection.DOWN: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 0, size, 0.8f)); + break; + case CutDirection.LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 0, 2, size, 0.8f)); + break; + case CutDirection.RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 2, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 2, size, 0.8f)); + break; + case CutDirection.UP_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 2, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 1, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 1, size, 0.8f)); + break; + } + break; + case Line.RIGHT: + switch (now.direction) + { + case CutDirection.DOWN: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 0, size, 0.8f)); + break; + case CutDirection.LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 1, 2, size, 0.8f)); + break; + case CutDirection.UP_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 2, size, 0.8f)); + break; + case CutDirection.DOWN_LEFT: + burstSliders.Add(new(now, now.beat + 0.125f, 2, 1, size, 0.8f)); + break; + case CutDirection.DOWN_RIGHT: + burstSliders.Add(new(now, now.beat + 0.125f, 3, 1, size, 0.8f)); + break; + } + break; + } + break; + } + } + + // Turn all sliders/stack/window/tower into chain + for (int i = 0; i < others.Count; i++) + { + if (others[i].First().color == ColorType.BLUE) + { + blue.Add(others[i].First()); + } + else if (others[i].First().color == ColorType.RED) + { + red.Add(others[i].First()); + } + + BurstSliderData newSlider = new(others[i].First(), others[i].Last().beat, others[i].Last().line, others[i].Last().layer, size, 0.8f); + burstSliders.Add(newSlider); + } + + noteTemp = new(blue); + noteTemp.AddRange(red); + + return (burstSliders, noteTemp); + } + } +} diff --git a/Lolighter/Algorithm/DoubleDirectional.cs b/Lolighter/Algorithm/DoubleDirectional.cs new file mode 100644 index 0000000..5a7c091 --- /dev/null +++ b/Lolighter/Algorithm/DoubleDirectional.cs @@ -0,0 +1,316 @@ +using Lolighter.Data.Structure; +using System; +using System.Collections.Generic; +using System.Linq; +using static Lolighter.Info.Helper; + +namespace Lolighter.Algorithm +{ + class DoubleDirectional + { + static public (List, List) Emilia(List noteTemp, bool IsLimited, bool removeSide) + { + List burstSliders = new(); + + List red = new(); + List blue = new(); + + 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; + } + } + + foreach (ColorNote note in noteTemp) + { + if(note.color == ColorType.BLUE) + { + blue.Add(note); + } + else if (note.color == ColorType.RED) + { + red.Add(note); + } + } + + List> sliders = new(); + List slider = new(); + bool found = false; + + // Find all blue sliders + 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 sliders + 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; + } + } + + // Fix sliders + 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 = 4; + BurstSliderData newSlider = new(sliders[i].First(), sliders[i].Last().beat, sliders[i].Last().line, sliders[i].Last().layer, size, 0.8f); + burstSliders.Add(newSlider); + } + + noteTemp = new(blue); + noteTemp.AddRange(red); + + noteTemp = noteTemp.OrderBy(x => x.beat).ToList(); + + return (noteTemp, burstSliders); + } + } +} diff --git a/Lolighter/Algorithm/Invert.cs b/Lolighter/Algorithm/Invert.cs new file mode 100644 index 0000000..e6ab747 --- /dev/null +++ b/Lolighter/Algorithm/Invert.cs @@ -0,0 +1,83 @@ +using Lolighter.Data.Structure; +using System.Collections.Generic; +using static Lolighter.Info.Helper; + +namespace Lolighter.Algorithm +{ + class Invert + { + static public List MakeInvert(List noteTemp, double Limiter, bool IsLimited) + { + ColorNote n; + bool found; + + for (int i = noteTemp.Count - 1; i > -1; i--) //For each note in reverse-order + { + n = noteTemp[i]; + + found = false; + + foreach (ColorNote temp in noteTemp) //For each note + { + if (n.beat == temp.beat && n.color == temp.color && n.direction == temp.direction && !IsLimited) + { + //Loloppe notes + break; + } + if (((n.beat - temp.beat < Limiter && n.beat - temp.beat > 0) || (temp.beat - n.beat < Limiter && temp.beat - n.beat > 0)) && temp.color == n.color) + { + found = true; + break; + } + else if (temp.beat == n.beat && temp.color == n.color && n != temp) + { + found = true; + break; + } + else if (temp.beat == n.beat && temp.color != n.color && n != temp && (temp.line == n.line || temp.layer == n.layer)) + { + found = true; + break; + } + } + + if (found) //If found, then skip + { + continue; + } + + switch (n.direction) //Based on the cut direction, change the layer of the note. + { + case CutDirection.UP: + n.layer = Layer.BOTTOM; + break; + case CutDirection.DOWN: + n.layer = Layer.TOP; + break; + case CutDirection.LEFT: + n.line = Line.RIGHT; + break; + case CutDirection.RIGHT: + n.line = Line.LEFT; + break; + case CutDirection.UP_LEFT: + n.layer = Layer.BOTTOM; + break; + case CutDirection.UP_RIGHT: + n.layer = Layer.BOTTOM; + break; + case CutDirection.DOWN_LEFT: + n.layer = Layer.TOP; + break; + case CutDirection.DOWN_RIGHT: + n.layer = Layer.TOP; + break; + case CutDirection.ANY: + break; + } + } + + return noteTemp; + } + } +} diff --git a/Lolighter/Algorithm/Light.cs b/Lolighter/Algorithm/Light.cs index 269c5b7..d833ada 100644 --- a/Lolighter/Algorithm/Light.cs +++ b/Lolighter/Algorithm/Light.cs @@ -178,10 +178,12 @@ internal static (List, List) CreateLight(Li if(boost) { boostEvent.Add(new ColorBoostEventData(offset, false)); + boost = false; } else { boostEvent.Add(new ColorBoostEventData(offset, true)); + boost = true; } } @@ -331,10 +333,13 @@ internal static (List, List) CreateLight(Li { for (int i = Timing.FindIndex(n => n == note); i < Timing.Count - 1; i++) { - if (Timing[i] == Timing[i - 1]) + if(i != 0) { - nextfloat = Timing[i]; - break; + if (Timing[i] == Timing[i - 1]) + { + nextfloat = Timing[i]; + break; + } } } } @@ -346,20 +351,23 @@ internal static (List, List) CreateLight(Li for (int i = Timing.FindIndex(n => n == note); i < Timing.Count - 1; i++) { - // Between 1/8 and 0, same cut direction or dots - if (Timing[i] - Timing[i - 1] <= 0.125 && Timing[i] - Timing[i - 1] > 0 && (Timing[i] == Timing[i - 1] || Timing[i] == 8)) + if(i != 0) { - // Search for the last note of the slider - if (sliderNoteCount == 0) + // Between 1/8 and 0, same cut direction or dots + if (Timing[i] - Timing[i - 1] <= 0.125 && Timing[i] - Timing[i - 1] > 0 && (Timing[i] == Timing[i - 1] || Timing[i] == 8)) { - // This is the first note of the slider - nextSlider = Timing[i - 1]; + // Search for the last note of the slider + if (sliderNoteCount == 0) + { + // This is the first note of the slider + nextSlider = Timing[i - 1]; + } + sliderNoteCount++; + } + else if (sliderNoteCount != 0) + { + break; } - sliderNoteCount++; - } - else if (sliderNoteCount != 0) - { - break; } } } diff --git a/Lolighter/Algorithm/Loloppe.cs b/Lolighter/Algorithm/Loloppe.cs new file mode 100644 index 0000000..8ec8d14 --- /dev/null +++ b/Lolighter/Algorithm/Loloppe.cs @@ -0,0 +1,412 @@ +using Lolighter.Data.Structure; +using System; +using System.Collections.Generic; +using System.Linq; +using static Lolighter.Info.Helper; + +namespace Lolighter.Algorithm +{ + class Loloppe + { + static public List LoloppeGen(List noteTemp) + { + Random random = new(); + List newNote = new(); + ColorNote n; + + for (int i = 0; i < noteTemp.Count; i++) //For each note -> Big Pepega + { + n = noteTemp[i]; + + if (n.direction == CutDirection.ANY) //If Any, skip + { + continue; + } + + switch (n.layer) //Process each note using their layer, lane and cut direction manually. + { + case Layer.BOTTOM: + switch (n.line) + { + case Line.LEFT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + } + break; + case Line.RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + } + break; + } + break; + case Layer.MIDDLE: + switch (n.line) + { + case Line.LEFT: + switch (n.direction) + { + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.UP_LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.BOTTOM, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + } + break; + case CutDirection.UP_RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.DOWN_LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.DOWN_RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.BOTTOM, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + } + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.UP_LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.TOP, n.direction)); + } + break; + case CutDirection.UP_RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.DOWN_LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.DOWN_RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.BOTTOM, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.TOP, n.direction)); + } + break; + } + break; + case Line.RIGHT: + switch (n.direction) + { + case CutDirection.LEFT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.RIGHT: + if (random.Next(1) == 0) + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.TOP, n.direction)); + } + else + { + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.BOTTOM, n.direction)); + } + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, n.direction)); + break; + } + break; + } + break; + case Layer.TOP: + switch (n.line) + { + case Line.LEFT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_LEFT, Layer.TOP, n.direction)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.MIDDLE, n.direction)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.TOP, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.LEFT, Layer.TOP, n.direction)); + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.TOP, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.TOP, n.direction)); + break; + } + break; + case Line.RIGHT: + switch (n.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(n.beat, n.color, Line.MIDDLE_RIGHT, Layer.TOP, n.direction)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(n.beat, n.color, Line.RIGHT, Layer.MIDDLE, n.direction)); + break; + } + break; + } + break; + } + } + + newNote = newNote.OrderBy(o => o.beat).ToList(); + + //Here we remove notes that ended up stacked because of the silly algorithm. + for (int i = newNote.Count - 1; i > -1; i--) //For each note in reverse-order + { + foreach (var note in noteTemp) //For each note + { + if (newNote[i].beat - note.beat < 0.125 && newNote[i].beat - note.beat > 0 && newNote[i].layer == note.layer && newNote[i].line == note.line) + { + newNote.Remove(newNote[i]); + break; + } + else if (newNote[i].beat == note.beat && newNote[i].layer == note.layer && newNote[i].line == note.line) + { + newNote.Remove(newNote[i]); + break; + } + } + } + + newNote.AddRange(noteTemp); + List sorted = newNote.OrderBy(o => o.beat).ToList(); + + return sorted; + } + } +} diff --git a/Lolighter/Algorithm/Sliders.cs b/Lolighter/Algorithm/Sliders.cs new file mode 100644 index 0000000..73e5da1 --- /dev/null +++ b/Lolighter/Algorithm/Sliders.cs @@ -0,0 +1,484 @@ +using Lolighter.Data.Structure; +using System.Collections.Generic; +using System.Linq; +using static Lolighter.Info.Helper; + +namespace Lolighter.Algorithm +{ + class Sliders + { + static public List MakeSliders(List noteTemp, double Limiter, bool IsLimited) + { + List newNote = new(); + List toRemove = new(); + ColorNote now; + ColorNote lastNote; + bool wrong = false; + + for (int i = noteTemp.Count - 1; i > 0; i--) // We try to find if the current note is part of a slider or can be slidified. + { + now = noteTemp[i]; + + if (now.direction == CutDirection.ANY) //If ANY, skip + { + continue; + } + + wrong = false; //If wrong, skip + + foreach (ColorNote temp in noteTemp) //For each note + { + if (now == temp) continue; // Same note + else if (now.beat == temp.beat && now.color == temp.color && now.direction == temp.direction && !IsLimited) break; // Loloppe + else if (((now.beat - temp.beat < Limiter * 2 && now.beat - temp.beat > 0) || (temp.beat - now.beat < Limiter * 2 && temp.beat - now.beat > 0)) && temp.color == now.color) + { + // Already a slider, tower, stack or issue with mapping? + wrong = true; + break; + } + else if (temp.beat == now.beat && temp.color == now.color && now != temp) + { + // Already a slider, tower, stack or issue with mapping? + wrong = true; + break; + } + else if (now.beat == temp.beat && now.color != temp.color && now.direction == temp.direction && (now.direction == CutDirection.UP_LEFT || now.direction == CutDirection.UP_RIGHT)) + { + // Diagonal double + wrong = true; + break; + } + else if (now.beat == temp.beat && temp.color != now.color && ((temp.line == Line.LEFT && now.line == Line.MIDDLE_LEFT) || (temp.line == Line.RIGHT && now.line == Line.MIDDLE_RIGHT))) + { + // Collision issue + wrong = true; + break; + } + } + + if (wrong) //If wrong, then skip + { + continue; + } + + switch (now.layer) //Process the note into a sliders depending on layer, lane and cut direction manually. This is pretty Pepega. + { + case Layer.BOTTOM: + switch (now.line) + { + case Line.LEFT: + switch (now.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + if (now.color == ColorType.RED) + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + } + else + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.DOWN: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.TOP)) + { + now.layer = Layer.TOP; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_LEFT)) + { + now.line = Line.MIDDLE_LEFT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.UP_LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_LEFT)) + { + now.line = Line.MIDDLE_LEFT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + } + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN_LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_LEFT)) + { + now.line = Line.MIDDLE_LEFT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (now.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.DOWN_RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.LEFT && x.layer == Layer.MIDDLE)) + { + now.layer = Layer.MIDDLE; + now.line = Line.LEFT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (now.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN_LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.RIGHT && x.layer == Layer.MIDDLE)) + { + now.layer = Layer.MIDDLE; + now.line = Line.RIGHT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + } + break; + case Line.RIGHT: + switch (now.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + if (now.color == ColorType.RED) + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + } + else + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.DOWN: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.TOP)) + { + now.layer = Layer.TOP; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_RIGHT)) + { + now.line = Line.MIDDLE_RIGHT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.UP_RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_RIGHT)) + { + now.line = Line.MIDDLE_RIGHT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + } + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.DOWN_RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_RIGHT)) + { + now.line = Line.MIDDLE_RIGHT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + } + break; + } + break; + case Layer.MIDDLE: + switch (now.line) + { + case Line.LEFT: + switch (now.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + } + break; + case Line.RIGHT: + switch (now.direction) + { + case CutDirection.UP: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + } + break; + } + break; + case Layer.TOP: + switch (now.line) + { + case Line.LEFT: + switch (now.direction) + { + case CutDirection.UP: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.BOTTOM)) + { + now.layer = Layer.BOTTOM; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + if (now.color == ColorType.RED) + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + } + else + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_LEFT)) + { + now.line = Line.MIDDLE_LEFT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.UP_LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.MIDDLE)) + { + now.layer = Layer.MIDDLE; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.UP_RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.MIDDLE)) + { + now.layer = Layer.MIDDLE; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + } + break; + case Line.MIDDLE_LEFT: + switch (now.direction) + { + case CutDirection.DOWN: + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.UP_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.UP_RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.LEFT && x.layer == Layer.MIDDLE)) + { + now.line = Line.LEFT; + now.layer = Layer.MIDDLE; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.MIDDLE, CutDirection.ANY)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + } + break; + case Line.MIDDLE_RIGHT: + switch (now.direction) + { + case CutDirection.DOWN: + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.UP_LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.RIGHT && x.layer == Layer.MIDDLE)) + { + now.line = Line.RIGHT; + now.layer = Layer.MIDDLE; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.UP_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + break; + } + break; + case Line.RIGHT: + switch (now.direction) + { + case CutDirection.UP: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.BOTTOM)) + { + now.layer = Layer.BOTTOM; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.DOWN: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + if (now.color == ColorType.BLUE) + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.RIGHT, Layer.BOTTOM, CutDirection.ANY)); + } + else + { + newNote.Add(new ColorNote(now.beat + 0.0625f, now.color, Line.MIDDLE_RIGHT, Layer.BOTTOM, CutDirection.ANY)); + } + break; + case CutDirection.LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_RIGHT, Layer.TOP, CutDirection.ANY)); + break; + case CutDirection.RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.line == Line.MIDDLE_RIGHT)) + { + now.line = Line.MIDDLE_RIGHT; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.UP_LEFT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.MIDDLE)) + { + now.layer = Layer.MIDDLE; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.UP_RIGHT: + if (!noteTemp.Any(x => x != now && x.beat == now.beat && x.layer == Layer.MIDDLE)) + { + now.layer = Layer.MIDDLE; + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.TOP, CutDirection.ANY)); + } + break; + case CutDirection.DOWN_LEFT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.MIDDLE_LEFT, Layer.BOTTOM, CutDirection.ANY)); + break; + case CutDirection.DOWN_RIGHT: + newNote.Add(new ColorNote(now.beat + 0.03125f, now.color, Line.RIGHT, Layer.MIDDLE, CutDirection.ANY)); + break; + } + break; + } + break; + } + + lastNote = now; + } + + noteTemp.RemoveAll(item => toRemove.Contains(item)); + newNote.AddRange(noteTemp); + List sorted = newNote.OrderBy(o => o.beat).ToList(); + + for (int i = 0; i < sorted.Count; i++) + { + if (sorted.Any(x => x != sorted[i] && x.line == sorted[i].line && x.layer == sorted[i].layer && x.beat == sorted[i].beat)) + { + sorted.Remove(sorted[i]); + i--; + } + } + + return sorted; + } + } +} diff --git a/Lolighter/Data/Structure/BaseSliderData.cs b/Lolighter/Data/Structure/BaseSliderData.cs index 66c77da..07e6d6d 100644 --- a/Lolighter/Data/Structure/BaseSliderData.cs +++ b/Lolighter/Data/Structure/BaseSliderData.cs @@ -4,6 +4,19 @@ namespace Lolighter.Data.Structure { internal class BaseSliderData { + [JsonConstructor] + public BaseSliderData(float beat, int color, int line, int layer, int direction, float tailBeat, int tailLine, int tailLayer) + { + this.beat = beat; + this.color = color; + this.line = line; + this.layer = layer; + this.direction = direction; + this.tailBeat = tailBeat; + this.tailLine = tailLine; + this.tailLayer = tailLayer; + } + [JsonInclude] [JsonPropertyName("b")] public float beat { get; set; } diff --git a/Lolighter/Data/Structure/BombNote.cs b/Lolighter/Data/Structure/BombNote.cs index 61e616e..215dbb9 100644 --- a/Lolighter/Data/Structure/BombNote.cs +++ b/Lolighter/Data/Structure/BombNote.cs @@ -4,18 +4,27 @@ namespace Lolighter.Data.Structure { internal class BombNote { - public BombNote(float beat, int index, int layer) + [JsonConstructor] + public BombNote(float beat, int line, int layer) { this.beat = beat; - this.index = index; + this.line = line; this.layer = layer; } + + public BombNote(ColorNote note) + { + this.beat = note.beat; + this.line = note.line; + this.layer = note.layer; + } + [JsonInclude] [JsonPropertyName("b")] public float beat { get; set; } [JsonInclude] [JsonPropertyName("x")] - public int index { get; set; } + public int line { get; set; } [JsonInclude] [JsonPropertyName("y")] public int layer { get; set; } diff --git a/Lolighter/Data/Structure/BurstSliderData.cs b/Lolighter/Data/Structure/BurstSliderData.cs index 2daad51..4cf45fb 100644 --- a/Lolighter/Data/Structure/BurstSliderData.cs +++ b/Lolighter/Data/Structure/BurstSliderData.cs @@ -4,6 +4,21 @@ namespace Lolighter.Data.Structure { internal class BurstSliderData : BaseSliderData { + [JsonConstructor] + public BurstSliderData(float beat, int color, int line, int layer, int direction, float tailBeat, int tailLine, int tailLayer, int sliceCount, float squishAmount) : + base(beat, color, line, layer, direction, tailBeat, tailLine, tailLayer) + { + this.sliceCount = sliceCount; + this.squishAmount = squishAmount; + } + + public BurstSliderData(ColorNote note, float tailBeat, int tailLine, int tailLayer, int sliceCount, float squishAmount) : + base(note.beat, note.color, note.line, note.layer, note.direction, tailBeat, tailLine, tailLayer) + { + this.sliceCount = sliceCount; + this.squishAmount = squishAmount; + } + [JsonInclude] [JsonPropertyName("sc")] public int sliceCount { get; set; } diff --git a/Lolighter/Data/Structure/ColorNote.cs b/Lolighter/Data/Structure/ColorNote.cs index 1f348c3..7c00227 100644 --- a/Lolighter/Data/Structure/ColorNote.cs +++ b/Lolighter/Data/Structure/ColorNote.cs @@ -14,6 +14,37 @@ public ColorNote(float beat, int color, int line, int layer, int direction, int this.direction = direction; this.angle = angle; } + + public ColorNote(float beat, int color, int line, int layer, int direction) + { + this.beat = beat; + this.color = color; + this.line = line; + this.layer = layer; + this.direction = direction; + this.angle = 0; + } + + public ColorNote(ColorNote note) + { + this.beat = note.beat; + this.color = note.color; + this.line = note.line; + this.layer = note.layer; + this.direction = note.direction; + this.angle = note.angle; + } + + public ColorNote(BombNote bomb) + { + this.beat = bomb.beat; + this.color = 3; + this.line = bomb.line; + this.layer = bomb.layer; + this.direction = 0; + this.angle = 0; + } + [JsonInclude] [JsonPropertyName("b")] public float beat { get; set; } diff --git a/Lolighter/Data/Structure/SliderData.cs b/Lolighter/Data/Structure/SliderData.cs index 32c44d1..0fc2d7e 100644 --- a/Lolighter/Data/Structure/SliderData.cs +++ b/Lolighter/Data/Structure/SliderData.cs @@ -4,7 +4,18 @@ namespace Lolighter.Data.Structure { internal class SliderData : BaseSliderData { - [JsonInclude] + [JsonConstructor] + public SliderData(float beat, int color, int line, int layer, int direction, float tailBeat, int tailLine, int tailLayer, + float headControlPointLengthMultiplier, float tailControlPointLengthMultiplier, int tailCutDirection, int midAnchorMode) : + base(beat, color, line, layer, direction, tailBeat, tailLine, tailLayer) + { + this.headControlPointLengthMultiplier = headControlPointLengthMultiplier; + this.tailControlPointLengthMultiplier = tailControlPointLengthMultiplier; + this.tailCutDirection = tailCutDirection; + this.midAnchorMode = midAnchorMode; + } + + [JsonInclude] [JsonPropertyName("mu")] public float headControlPointLengthMultiplier { get; set; } diff --git a/Lolighter/MainWindow.xaml b/Lolighter/MainWindow.xaml index b67fe81..9e2ae52 100644 --- a/Lolighter/MainWindow.xaml +++ b/Lolighter/MainWindow.xaml @@ -15,19 +15,19 @@ -