Esempio n. 1
0
        public BorderMap(TiledMap map, CompilerContext context, string mapPath)
        {
            Child          = map;
            BorderMapTiles = new List <uint>();

            BorderLayer = Child.Layers.GetObjectByMatchingProperties(Resources.STR_PROPERTY_LTYPE_NAME, Resources.STR_PROPERTY_LTYPE_BORDER, context);
            if (BorderLayer == null)
            {
                context.ExitError("could not find border layer in border map file");
            }

            foreach (TiledTilesetDefinition def in Child.TilesetDefinitions)
            {
                def.LoadTileset(mapPath, context);
            }
            Csv.AddDataToMapList(BorderMapTiles, BorderLayer.Data.MapDataText, context);
        }
Esempio n. 2
0
        public void LoadTileData(CompilerContext context)
        {
            /* we do not need layers without properties, they will be ignored anyways */
            List <TiledLayer> flaggedRemove = new List <TiledLayer>();

            foreach (TiledLayer layer in Child.Layers)
            {
                if (layer.Properties == null)
                {
                    flaggedRemove.Add(layer);
                    //TODO: Add Warning to warning stack
                }
            }
            foreach (TiledLayer removeLayer in flaggedRemove)
            {
                Child.Layers.Remove(removeLayer);
            }
            TiledLayer collisionLayer = Child.Layers.GetObjectByMatchingProperties(Resources.STR_PROPERTY_LTYPE_NAME, Resources.STR_PROPERTY_LTYPE_COLLISION, context);
            TiledLayer mapLayer       = Child.Layers.GetObjectByMatchingProperties(Resources.STR_PROPERTY_LTYPE_NAME, Resources.STR_PROPERTY_LTYPE_MAP, context);

            if (collisionLayer == null)
            {
                context.ExitError("could not find collision layer, specify custom property '{0}' as '{1}'", Resources.STR_PROPERTY_LTYPE_NAME, Resources.STR_PROPERTY_LTYPE_COLLISION);
            }
            if (mapLayer == null)
            {
                context.ExitError("could not find map layer, specify custom property '{0}' as '{1}'", Resources.STR_PROPERTY_LTYPE_NAME, Resources.STR_PROPERTY_LTYPE_MAP);
            }
            if (mapLayer.Data.Encoding != Resources.STR_ENCODING_CSV)
            {
                context.ExitError("encoding of map layer is not csv");
            }
            if (collisionLayer.Data.Encoding != Resources.STR_ENCODING_CSV)
            {
                context.ExitError("encoding of collision layer is not csv");
            }

            MapTiles       = new List <uint>();
            CollisionTiles = new List <uint>();

            Csv.AddDataToMapList(MapTiles, mapLayer.Data.MapDataText, context);
            Csv.AddDataToMapList(CollisionTiles, collisionLayer.Data.MapDataText, context);

            MapLayer       = mapLayer;
            CollisionLayer = collisionLayer;
        }