/// <summary> /// Overwrites overlay with the tiles in the computed path. /// </summary> /// <param name="o">The overlay to reset</param> /// <param name="end">The endpoint of the path</param> public void SetOverlayToComputedPath(TileSetOverlay o, Node end) { Node node = end; o.Clear(); while (node != null) { o.Add(node.Position); node = node.Predecessor; } }
IEnumerator MakeWalls() { var walls = GameObject.Find("Map/Walls"); var remainingWallTiles = WallTiles; #if DEBUG_MAKEWALLS var allWallsOverlay = new TileSetOverlay(Color.green); var currentWallOverlay = new TileSetOverlay(Color.yellow); this.AddOverlay(allWallsOverlay); this.AddOverlay(currentWallOverlay); allWallsOverlay.Set(remainingWallTiles); yield return(new WaitForSeconds(1)); #endif while (remainingWallTiles.Count > 0) { var seed = remainingWallTiles.First(); var vwall = this.ScanVertically(seed, remainingWallTiles); var hwall = this.ScanHorizontally(seed, remainingWallTiles); var selectedWall = vwall.Area > hwall.Area ? vwall : hwall; foreach (var p in selectedWall) { remainingWallTiles.Remove(p); } var bcollider = walls.AddComponent <BoxCollider2D>(); bcollider.offset = selectedWall.WorldCenter; bcollider.size = selectedWall.Size; #if DEBUG_MAKEWALLS allWallsOverlay.Clear(); allWallsOverlay.Set(remainingWallTiles); currentWallOverlay.Clear(); currentWallOverlay.Set(selectedWall); yield return(new WaitForSeconds(2.0f)); #endif } yield break; }
IEnumerator MakeWalls() { var walls = GameObject.Find("Map/Walls"); var remainingWallTiles = WallTiles; #if DEBUG_MAKEWALLS var allWallsOverlay = new TileSetOverlay(Color.green); var currentWallOverlay = new TileSetOverlay(Color.yellow); this.AddOverlay(allWallsOverlay); this.AddOverlay(currentWallOverlay); allWallsOverlay.Set(remainingWallTiles); yield return new WaitForSeconds(1); #endif while (remainingWallTiles.Count > 0) { var seed = remainingWallTiles.First(); var vwall = this.ScanVertically(seed, remainingWallTiles); var hwall = this.ScanHorizontally(seed, remainingWallTiles); var selectedWall = vwall.Area > hwall.Area ? vwall : hwall; foreach (var p in selectedWall) remainingWallTiles.Remove(p); var bcollider = walls.AddComponent<BoxCollider2D>(); bcollider.center = selectedWall.WorldCenter; bcollider.size = selectedWall.Size; #if DEBUG_MAKEWALLS allWallsOverlay.Clear(); allWallsOverlay.Set(remainingWallTiles); currentWallOverlay.Clear(); currentWallOverlay.Set(selectedWall); yield return new WaitForSeconds(2.0f); #endif } yield break; }