Exemplo n.º 1
0
        public static CharacterRouteInfo operator *(CharacterRouteInfo a, double b)
        {
            if (a.Kind == CharacterKind.General)
            {
                var routes = a.Routes.Select((RelativeRoute route) =>
                {
                    var r = new RelativeRoute(route.StartX * b, route.StartY * b, route.EndX * b, route.EndY * b);
                    Console.WriteLine(string.Format("From {0} to {1}", route, r));
                    return(r);
                });
                var newInfo = new CharacterRouteInfo(optimizationRoute(routes.ToList()));
                return(newInfo);
            }

            return(a);
        }
Exemplo n.º 2
0
        public static CharacterRouteInfo GetRouteByChar(char c)
        {
            if (c == ' ' || c == '\n' || c == '\t')
            {
                var info = new CharacterRouteInfo(new List <RelativeRoute>());
                if (c == ' ')
                {
                    info.Kind = CharacterKind.Space;
                }
                else if (c == '\t')
                {
                    info.Kind = CharacterKind.Space;
                    info.Num  = 4;
                }
                else if (c == '\n')
                {
                    info.Kind = CharacterKind.NextLine;
                }
                return(info);
            }
            var file  = NewCharFile(c);
            var paths = new List <RelativeRoute>();

            if (!file.Exists || file.Length % 16 != 0)
            {
                throw new Exception("TODO");
            }
            var reader = file.OpenRead();

            byte[] b = new byte[4];
            for (var i = 0; i < reader.Length / 16; i++)
            {
                int sx, sy, ex, ey;
                reader.Read(b, 0, 4);
                sx = BitConverter.ToInt32(b, 0);
                reader.Read(b, 0, 4);
                sy = BitConverter.ToInt32(b, 0);
                reader.Read(b, 0, 4);
                ex = BitConverter.ToInt32(b, 0);
                reader.Read(b, 0, 4);
                ey = BitConverter.ToInt32(b, 0);
                paths.Add(new RelativeRoute(sx, sy, ex, ey));
            }
            return(new CharacterRouteInfo(paths));
        }