예제 #1
0
        /// <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;
            }
        }
예제 #2
0
    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;
    }
예제 #3
0
        /// <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;
            }
        }
예제 #4
0
파일: TileMap.cs 프로젝트: rzubek/MKULTRA
    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;
    }