public SimpleNodesEnumerator(INode[,] grid, int x, int z) { _x = x; _z = z; _grid = grid; Reset(); }
public RandomizedNodesEnumerator(INode[,] grid, int x, int z) { _x = x; _z = z; _grid = grid; ConstructValidNeighbors(); Reset(); }
private void CreateGrid() { if (InnerGrid == null) { Logger.Debug("[{0}] Creating grid [{1},{1}]", GetType().Name, GridBounds); InnerGrid = new INode[GridBounds, GridBounds]; } }
public BaseNode(INode[,] grid, int x, int z, Vector3 position) { _grid = grid; this.x = x; this.z = z; Scale = Scale; Position = position; }
public HigherScaleNode(BaseNode[,] baseGrid, INode[,] grid, int x, int z, int scale, Vector3 position) { _baseGrid = baseGrid; _grid = grid; this.x = x; this.z = z; Scale = scale; Position = position; }
public DirectedNodesEnumerator(INode[,] grid, int x, int z, Vector3 direction) { _x = x; _z = z; _grid = grid; var roundedDirection = GetRoundedDirection(direction); _directionX = Mathf.RoundToInt(roundedDirection.x); _directionZ = Mathf.RoundToInt(roundedDirection.z); _rotationDirection = Vector3.Cross(direction, roundedDirection).y >= 0 ? 1 : -1; Reset(); }
public void Build(Vector3Int[,] posLst) { int x = posLst.GetLength(0); int y = posLst.GetLength(1); Data = new INode[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { bool passable = true; Data[i, j] = new GridNode(posLst[i, j], passable); } } }
public void init(ref INode[,] map) { this.map = map; foreach (INode node in map) { if (node.property == nodeProp.START) { start = node; } if (node.property == nodeProp.GOAL) { goal = node; } } curTile = null; isCalculating = false; if (OpenList == null) { OpenList = new List <INode>(); } else { OpenList.Clear(); } if (CloseList == null) { CloseList = new List <INode>(); } else { CloseList.Clear(); } if (PathList == null) { PathList = new List <INode>(); } else { PathList.Clear(); } }
}//GenerateGrid protected INode[,] fillEmpty(INode[,] grid, int height, int width) { for (int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { INode tile = grid[h,w]; if (tile != null) continue; //tile = new INode(); tile.SetWalkable(false); tile.SetCoord(w, h); tile.SetPosition(this.GetWorldFromNode(w, h)); tile.SetHeuristicCost(10); grid[h,w] = tile; //Debug.Log("Null Tile at [" + h + "," + w + "]"); }//for w }//for h return grid; }
public Grid(int width, int height, float defaultCost = 1.0f, Connections connections = Connections.LateralAndDiagonal) { if (width < 1) { throw new ArgumentOutOfRangeException( nameof(width), $"Argument {nameof(width)} is {width} but should be >= 1"); } if (height < 1) { throw new ArgumentOutOfRangeException( nameof(height), $"Argument {nameof(height)} is {height} but should be >= 1"); } if (defaultCost < 1.0f) { throw new ArgumentOutOfRangeException( nameof(defaultCost), $"Argument {nameof(defaultCost)} is {defaultCost} but should be >= 1.0f"); } this.Width = width; this.Height = height; this.Nodes = new INode[width, height]; this.CreateNodes(); switch (connections) { case Connections.Lateral: this.CreateLateralConnections(defaultCost); break; case Connections.Diagonal: this.CreateDiagonalConnections(defaultCost); break; default: this.CreateLateralConnections(defaultCost); this.CreateDiagonalConnections(defaultCost); break; } }
private HigherScaleNode GetHigherScaleNode(BaseNode[,] baseGrid, INode[,] grid, int scale, int x, int z) { for (var _z = z; _z <= Mathf.Min(baseGrid.GetLength(0) - 1, z + scale); _z++) { for (var _x = x; _x <= Mathf.Min(baseGrid.GetLength(1) - 1, x + scale); _x++) { if (baseGrid[_z, _x] == null) { return(null); } } } return(new HigherScaleNode(baseGrid, grid, x, z, scale, new Vector3(x + 0.5f + scale * 0.5f, 0, z + 0.5f + scale * 0.5f))); }
private void Reset(Vector3 target) { _nodesToVisit = new SortedStack(target); _visitedNodes = new INode[_map.Grid.GetLength(0), _map.Grid.GetLength(1)]; }
public Field2DGraph(bool[,] field) { nodesField = BuildNodes(field); }
public Map(INode[,] grid, int scale) { Grid = grid; _scale = scale; PathFinder = new PathFinder(this); }
public void UpdateNodes(INode[,] nodes) { this.width = nodes.GetLength(0); this.height = nodes.GetLength(1); this.nodes = nodes; }
public Grid(int width, int height) { m_Width = width; m_Height = height; m_Nodes = new INode[width, height]; }
public AStarNode2D(PMap.ICoordinate coordinate, INode[,] grid) : this(coordinate) { AStarNode2D.grid = grid; }
private void Reset() { _nodesToVisit = new List <INode>(); _visitedNodes = new INode[_map.Grid.GetLength(0), _map.Grid.GetLength(1)]; }