RemoveTile() public method

public RemoveTile ( int x, int y, Tile tile ) : void
x int
y int
tile Tile
return void
Example #1
0
        private Tile InnerApply(TileGridLayer tileLayer, int x, int y)
        {
            TileCoord[] coordSet  = NeighborCoordSet(x, y);
            List <int>  neighbors = new List <int>();

            for (int i = 0; i < coordSet.Length; i++)
            {
                if (ContainsMemberTile(tileLayer.TilesAt(coordSet[i])))
                {
                    neighbors.Add(i + 1);
                }
            }

            List <LocatedTile> targetStack = new List <LocatedTile>();

            foreach (LocatedTile tile in tileLayer.TilesAt(new TileCoord(x, y)))
            {
                targetStack.Add(tile);
            }

            foreach (LocatedTile tile in targetStack)
            {
                if (IsMemberTile(tile))
                {
                    tileLayer.RemoveTile(x, y, tile.Tile);
                }
            }

            int  index   = _brushClass.ApplyRules(neighbors);
            Tile newTile = null;

            if (index >= 0 && index < _tiles.Count && _tiles[index].Tile != null)
            {
                newTile = _tiles[index].Tile;
            }

            if (newTile != null)
            {
                tileLayer.AddTile(x, y, newTile);
            }

            return(newTile);
        }
Example #2
0
        private Tile InnerApply(TileGridLayer tileLayer, int x, int y)
        {
            TileCoord[] coordSet = NeighborCoordSet(x, y);
            List<int> neighbors = new List<int>();

            for (int i = 0; i < coordSet.Length; i++) {
                if (ContainsMemberTile(tileLayer.TilesAt(coordSet[i])))
                    neighbors.Add(i + 1);
            }

            List<LocatedTile> targetStack = new List<LocatedTile>();
            foreach (LocatedTile tile in tileLayer.TilesAt(new TileCoord(x, y)))
                targetStack.Add(tile);

            foreach (LocatedTile tile in targetStack) {
                if (IsMemberTile(tile))
                    tileLayer.RemoveTile(x, y, tile.Tile);
            }

            int index = _brushClass.ApplyRules(neighbors);
            Tile newTile = null;

            if (index >= 0 && index < _tiles.Count && _tiles[index].Tile != null)
                newTile = _tiles[index].Tile;

            if (newTile != null)
                tileLayer.AddTile(x, y, newTile);

            return newTile;
        }