Beispiel #1
0
        /// <summary>
        /// A VIRER va partir du coté de TmxMap
        /// </summary>
        /// <param name="assetTileSheetName"></param>
        /// <param name="stream"></param>
        /// <returns></returns>

        //public static List<AssetMap> Import(string assetTileSheetName, Stream stream)
        //{
        //    List<AssetMap> maps = new List<AssetMap>();
        //    TmxMap tmxMap = new TmxMap(stream);

        //    foreach(var layer in tmxMap.Layers)
        //    {
        //        AssetMap map = new AssetMap();

        //        map.Name = layer.Name;
        //        map.Tiles = new MapTileDescriptor[layer.Tiles.Count];

        //        map.MapWidth = tmxMap.Width;
        //        map.MapHeight = tmxMap.Height;

        //        map.AssetTileSheetName = assetTileSheetName;

        //        for(int index = 0; index < layer.Tiles.Count; index++)
        //        {
        //            var tile = layer.Tiles[index];

        //            int number = tile.Gid - 1;

        //            var isHidden = number == -1;

        //            if (isHidden == true)
        //            {
        //                number = 0;
        //            }

        //            if(number != 0)
        //            {

        //            }

        //            map.Tiles[index] = new MapTileDescriptor() { number = number, hidden = isHidden, isHorizontalFlipped = tile.HorizontalFlip, isVerticalFlipped = tile.VerticalFlip };
        //        }

        //        maps.Add(map);
        //    }

        //    return maps;
        //}

        public static AssetMap Import(Cartridge cartridge, string assetName, string assetTileSheetName, int mapWidth, int mapHeight, MapTileDescriptor[] tiles)
        {
            AssetMap map = new AssetMap(cartridge);

            map.Name = assetName;

            map.Tiles = tiles;

            map.MapWidth  = mapWidth;
            map.MapHeight = mapHeight;

            map.AssetTileSheetName = assetTileSheetName;

            return(map);
        }
Beispiel #2
0
        public static List <AssetMap> Import(Cartridge cartridge, string assetTileSheetName, Stream stream)
        {
            List <AssetMap> maps = new List <AssetMap>();

            TmxMap tmxMap = new TmxMap(stream);

            foreach (var layer in tmxMap.Layers)
            {
                var tiles = new MapTileDescriptor[layer.Tiles.Count];

                for (int index = 0; index < layer.Tiles.Count; index++)
                {
                    var tile = layer.Tiles[index];

                    int number = tile.Gid - 1;

                    var isHidden = number == -1;

                    if (isHidden == true)
                    {
                        number = 0;
                    }

                    if (number != 0)
                    {
                    }

                    tiles[index] = new MapTileDescriptor()
                    {
                        number = number, hidden = isHidden, isHorizontalFlipped = tile.HorizontalFlip, isVerticalFlipped = tile.VerticalFlip
                    };
                }

                AssetMap map = AssetMap.Import(
                    cartridge,
                    layer.Name,
                    assetTileSheetName,
                    tmxMap.Width,
                    tmxMap.Height,
                    tiles
                    );

                maps.Add(map);
            }

            return(maps);
        }
Beispiel #3
0
        /// <summary>
        /// uint -> bit 31 = flip horizontal
        /// uint -> bit 30 = flip vertical
        /// le reste number data
        /// </summary>
        /// <param name="assetName"></param>
        /// <param name="encodedTilesNumber"></param>
        /// <returns></returns>

        public static AssetMap Import(Cartridge cartridge, string assetName, string assetTileSheetName, int mapWidth, int mapHeight, uint[] encodedTilesNumber)
        {
            AssetMap map = new AssetMap(cartridge);

            map.Name = assetName;

            map.Tiles = new MapTileDescriptor[encodedTilesNumber.Length];

            for (int index = 0; index < encodedTilesNumber.Length; index++)
            {
                var encodedTileNumber = encodedTilesNumber[index];

                map.Tiles[index] = CreateTile(encodedTileNumber);
            }

            map.MapWidth  = mapWidth;
            map.MapHeight = mapHeight;

            map.AssetTileSheetName = assetTileSheetName;

            return(map);
        }