// Use this for placing tiles at runtime.
        public void PlaceTile(Tile tile, Point2I location, int layer, bool initializeTile = true)
        {
            tile.Location			= location;
            tile.PreviousLocation	= location;
            tile.Layer				= layer;
            Rectangle2I area = GetTileArea(tile);
            tile.TileGridArea	= area;

            for (int x = area.Left; x < area.Right; x++) {
                for (int y = area.Top; y < area.Bottom; y++) {
                    tiles[x, y, layer] = tile;
                }
            }
            if (initializeTile)
                tile.Initialize(roomControl);

            // Check for covered tiles.
            Rectangle2F tileBounds = tile.Bounds;
            foreach (Tile t in GetTilesTouching(tileBounds)) {
                if (t != tile) {
                    t.OnCoverBegin(tile);
                    if (tileBounds.Contains(t.Bounds))
                        t.OnCoverComplete(tile);
                }
            }
        }
Exemple #2
0
 // Use this for placing tiles at runtime.
 public void PlaceTile(Tile tile, int x, int y, int layer)
 {
     tile.Initialize(this);
     tiles[x, y, layer] = tile;
 }