Example #1
0
 private static string TryConvert(LineConverter processor, string result)
 {
     try
     {
         return(processor.Convert(result));
     }
     catch
     {
         return(null);
     }
 }
Example #2
0
        public static SvgMeshData GetBorderMesh(List <float[]> points, float width, Color color)
        {
            var finalPoints = points.Select(a => new float[] { a[0], a[1], 0 }).ToList();

            var polygonalLine = LineConverter.GetPolygonalLine(finalPoints, width);

            finalPoints.AddRange(polygonalLine.Item1);

            return(new SvgMeshData()
            {
                Vertices = finalPoints.Select(a => new MeshHelper.PositionColorVertex()
                {
                    PosX = a[0],
                    PosY = a[1],
                    PosZ = a[2],
                    R = color.R / 255f,
                    G = color.G / 255f,
                    B = color.B / 255f,
                    A = color.A / 255f
                }).ToList(),
                Indices = polygonalLine.Item2
            });
        }
Example #3
0
        public Talk ConvertTalk(string data)
        {
            LineConverter parser = lineConverters.First(p => p.CanParse(data));

            return(parser.Parse(data));
        }
Example #4
0
        public static void Parse(string filename, out List <Note> notes, out List <LongNote> lns, int keys)
        {
            LineConverter converter = new LineConverter(keys);

            notes = new List <Note>();
            lns   = new List <LongNote>();

            using (var reader = new StreamReader(filename))
            {
                string currentLine;

                //  Find HitObjects tag.
                while ((currentLine = reader.ReadLine()) != null)
                {
                    if (currentLine == "[HitObjects]")
                    {
                        break;
                    }
                }

                //  Parsing notes.
                while ((currentLine = reader.ReadLine()) != null)
                {
                    //  Split current line with ','.
                    var splitLine = currentLine.Split(',');

                    if (splitLine.Length != 6)
                    {
                        throw new InvalidBeatmapException("Wrong HitObject format.");
                    }

                    //  x, y, time, 1, hitsound, addition for simple note.
                    //  x, y, time, 5, hitsound, addition for the first simple note.
                    if (Convert.ToInt32(splitLine[3]) == 1 || Convert.ToInt32(splitLine[3]) == 5)
                    {
                        var temp = new Note
                        {
                            Line = converter.GetLine(Convert.ToInt32(splitLine[0])),
                            Time = Convert.ToInt32(splitLine[2])
                        };

                        notes.Add(temp);
                    }

                    //  x, y, time, 128, hitsound, endtime:addition for long note.
                    else if (Convert.ToInt32(splitLine[3]) == 128 || (Convert.ToInt32(splitLine[3]) == 132))
                    {
                        var temp = new LongNote
                        {
                            Line    = converter.GetLine(Convert.ToInt32(splitLine[0])),
                            Time    = Convert.ToInt32(splitLine[2]),
                            Endtime = Convert.ToInt32(splitLine[5].Split(':')[0])
                        };

                        lns.Add(temp);
                    }

                    //  Any other types are unkown notes.
                    else
                    {
                        throw new InvalidBeatmapException("Unknown note type.");
                    }
                }
            }
        }
 public void SetUp()
 {
     _parserGetter  = new ParserGetter();
     _lineConverter = new LineConverter(_parserGetter);
 }