Esempio n. 1
0
        private static void BuildIntGridValue(LDtkDataLayer layer, LDtkDataIntGridValue intValueData, LDtkIntGridValueAssetCollection valueAssets, Tilemap tilemap)
        {
            LDtkDefinitionIntGridValue definition = layer.Definition.intGridValues[intValueData.v];

            LDtkIntGridValueAsset asset = valueAssets.GetAssetByIdentifier(definition.identifier);

            if (asset == null)
            {
                return;
            }

            Vector2Int cellCoord = LDtkToolOriginCoordConverter.GetTopLeftOriginCellCoordFromCoordID(intValueData.coordId, layer.__cWid);
            Vector2    coord     = LDtkToolOriginCoordConverter.ConvertCell(cellCoord, layer.__cHei);
            Tile       tileAsset = LDtkProviderTile.GetTile(asset, definition.color.ToColor());

            Vector3Int c = new Vector3Int((int)coord.x, (int)coord.y, 0);

            tilemap.SetTile(c, tileAsset);
        }
Esempio n. 2
0
        private static void BuildTile(LDtkDataLayer layer, LDtkDataTile tileData, LDtkTilesetAsset asset, Tilemap tilemap)
        {
            Vector2Int coord = tileData.LayerPixelPosition / layer.__gridSize;

            coord = LDtkToolOriginCoordConverter.ConvertCell(coord, layer.__cHei);

            Sprite tileSprite = GetTileFromTileset(asset.ReferencedAsset, tileData.SourcePixelPosition, layer.__gridSize);

            Tile tile = ScriptableObject.CreateInstance <Tile>();

            tile.colliderType = Tile.ColliderType.None;
            tile.sprite       = tileSprite;

            Vector3Int co = new Vector3Int(coord.x, coord.y, 0);



            //Tilemap mapToBuildOn = tilemap;

            tilemap.SetTile(co, tile);
            SetTileFlips(tilemap, tileData, coord);
        }
Esempio n. 3
0
 protected Vector2Int ConvertCellCoord(Vector2Int cellCoord)
 {
     return(LDtkToolOriginCoordConverter.ConvertCell(cellCoord, (int)Layer.CHei));
 }