Beispiel #1
0
        public static uint DistanceToPoint(short a, short b)
        {
            Point point1 = PathingUtils.CellIdToCoord(a);
            Point point2 = PathingUtils.CellIdToCoord(b);

            return((uint)Math.Sqrt((point1.X - point2.X) * (point1.X - point2.X) + (point1.Y - point2.Y) * (point1.Y - point2.Y)));
        }
Beispiel #2
0
        public static short[] CellsByDistance(short[] cells, short current)
        {
            Dictionary <int, int> distances = new Dictionary <int, int>();

            for (int i = 0; i < cells.Length; i++)
            {
                distances[cells[i]] = (short)PathingUtils.DistanceToPoint2(PathingUtils.CellIdToCoord(cells[i]), PathingUtils.CellIdToCoord(current));
            }
            return(cells.OrderByDescending(elem => distances[elem]).ToArray());
        }