Beispiel #1
0
        public TileMap(int width, int height, int numberOfEntityLayers, Distance distanceMeasurement, string defaultTileBlueprint = "wall",
                       uint layersBlockingWalkability           = uint.MaxValue, uint layersBlockingTransparency = uint.MaxValue,
                       uint entityLayersSupportingMultipleItems = uint.MaxValue)
            : base(width, height, numberOfEntityLayers, distanceMeasurement, layersBlockingWalkability, layersBlockingTransparency,
                   entityLayersSupportingMultipleItems)
        {
            Regions = new List <Maps.Region>();

            // Be efficient by not using factory.Create each tile below. Instead, get the blueprint and use that to create each tile.
            IBlueprint <TileBlueprintConfig, Tile> defaultTile = Tile.Factory.GetBlueprint(defaultTileBlueprint);

            // Configure to set up event forwarding properly on tile add/remove
            ObjectAdded   += TileMap_ObjectAdded;
            ObjectRemoved += TileMap_ObjectRemoved;

            // Fill the map with walls
            foreach (Coord pos in this.Positions())
            {
                SetTerrain(defaultTile.Create(pos));
            }
        }