Beispiel #1
0
        public static WorldPoint FindShortest(string typesAlowed, bool UsseDeffculty, params WorldPoint[] points)
        {
            if (points.Length < 2)
            {
                return(points[0]);
            }
            WorldPoint startP  = points[0];
            WorldPoint Closest = points[1];

            index = 1;
            Int64  Lenght = 99999999999999;
            double Def    = 1;

            string[] typs = typesAlowed.Split(',');
            for (int i = 0; i < points.Length; i++)
            {
                if (UsseDeffculty)
                {
                    Def = points[i].Difficulty;
                }
                if (!points[i].Contains(typs))
                {
                    continue;
                }
                Int64 len = GetDist(startP.X, startP.Y, points[i].X, points[i].Y);
                if (len * Def < Lenght)
                {
                    Lenght  = len;
                    Closest = points[i];
                    Def     = Closest.Difficulty;
                    index   = i;
                }
            }
            return(Closest);
        }
Beispiel #2
0
        public static WorldPoint GetRandLocation()
        {
            Random     rand = new Random();
            WorldPoint wp   = new WorldPoint(rand.Next(3600), rand.Next(3600));

            return(wp);
        }
Beispiel #3
0
        public static Bringer FindShortest(string typesAlowed, bool UsseDeffculty, WorldPoint StartPoint, params Bringer[] UserPoints)
        {
            List <WorldPoint> WP = new List <WorldPoint>();

            WP.Add(StartPoint);
            foreach (Bringer item in UserPoints)
            {
                WP.Add(item.Location);
            }
            WorldPoint wpf = FindShortest(typesAlowed, UsseDeffculty, WP.ToArray());

            return(UserPoints[index - 1]);
        }
Beispiel #4
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            WorldPoint obj = (WorldPoint)value;

            writer.WriteValue(obj.ToString());
        }