Ejemplo n.º 1
0
        public List <Node> GetNeighbors(Node node)
        {
            List <Node> neighbors = new List <Node>();

            UnityExtensions.MapNeighborIndexes(node.x, node.y, _map.GetLength(0), _map.GetLength(1), (x, y) =>
            {
                var ox                   = x - node.x;
                var oy                   = y - node.y;
                var isDiagonal           = ox != 0 && oy != 0;
                var isDiagonallyWalkable = !isDiagonal || (_map[x, y - oy].isWalkable || _map[x - ox, y].isWalkable);
                if (_map[x, y].isWalkable && isDiagonallyWalkable)
                {
                    neighbors.Add(_map[x, y]);
                }
            });
            return(neighbors);
        }