public static int GetRange(int start, int end)
        {
            var startCell = CoordCells.GetCell(start);
            var endCell   = CoordCells.GetCell(end);

            return(Math.Abs(startCell.X - endCell.X) + Math.Abs(startCell.Y - endCell.Y));
        }
Пример #2
0
        public static List <Node> GetNodes(MapRecord map)
        {
            var nodes = new List <Node>();

            for (short cell = 0; cell < 560; cell++)
            {
                var node = new Node(CoordCells.GetCell(cell));
                if (map.WalkableCells.Contains(cell))
                {
                    node.Walkable = true;
                }
                else
                {
                    node.Walkable = false;
                }

                nodes.Add(node);
            }
            return(nodes);
        }
        public static List <_cell> GetRectangleCells(_cell start, _cell end)
        {
            int minX = Math.Min(start.X, end.X),
                minY = Math.Min(start.Y, end.Y),
                maxX = Math.Max(start.X, end.X),
                maxY = Math.Max(start.Y, end.Y);

            var cells = new List <_cell>();

            for (var x = minX; x <= maxX; x++)
            {
                for (var y = minY; y <= maxY; y++)
                {
                    var cell = CoordCells.GetCell(x, y);
                    if (cell != null)
                    {
                        cells.Add(cell);
                    }
                }
            }
            return(cells);
        }