private WalkableNode[,] ParseGrid(Tilemap wallTilemap) { int width = wallTilemap.size.x; int height = wallTilemap.size.y; WalkableNode[,] grid = new WalkableNode[width, height]; for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { bool isWall = IsCollision(x, y); grid[x, y] = new WalkableNode() { IsWall = isWall, X = x, Y = y, }; if (m_IsVerbose && isWall) { Debug.Log("NavTilemapController.ParseGrid: (" + x + ", " + y + ") is a wall."); } if (isWall || onPassableCreated == null) { continue; } onPassableCreated(GridToWorld2D(x, y)); } } return(grid); }
private void SetNextStep() { int index = 0; WalkableNode nextNode = null; // XXX It would be more efficient if path were a list or an array rather than IEnumerable. foreach (WalkableNode node in m_Path) { if (index == 1) { nextNode = node; break; } ++index; } if (nextNode == null) { if (m_IsVerbose) { DebugUtil.Log(this + ".SetNextStep: Arrived at destination=" + m_NextStep); } position = m_NextStep; m_Path = null; m_HasDestination = false; if (hasDestinationLoop) { SetNextDestinationInLoop(); } return; } Vector2Int cell = new Vector2Int(nextNode.X, nextNode.Y); m_PreviousStep = m_NextStep; m_NextStep = m_Nav.GridToWorld(cell); }