public void TiledMapImporter_Import_Test() { const string filename = @"TestData\level01.tmx"; var importer = new TiledMapImporter(); var data = importer.Import(filename, Substitute.For<ContentImporterContext>()); Assert.AreEqual("Tile Layer 2", data.Layers[0].Name); }
private static TmxMap ImportAndProcessMap(string filename) { var importer = new TiledMapImporter(); var processor = new TiledMapProcessor(); var import = importer.Import(filename, Substitute.For <ContentImporterContext>()); var result = processor.Process(import, Substitute.For <ContentProcessorContext>()); return(result.Map); }
void OnGUI() { GUILayout.Label("Choose file map to load", EditorStyles.boldLabel); mapObjectName = EditorGUILayout.TextField("Map object name", mapObjectName); string path = ""; if (GUILayout.Button("Load Tiled Map", new GUILayoutOption[] { GUILayout.Width(300) })) { path = EditorUtility.OpenFilePanel("Load Tiled map file", "", "tmx"); Debug.Log(">>> value " + mapObjectName); TiledMapImporter tmi = new TiledMapImporter(path); } }
private static TmxMap ImportAndProcessMap(string filename) { var logger = Substitute.For <ContentBuildLogger>(); var importer = new TiledMapImporter(); var importerContext = Substitute.For <ContentImporterContext>(); importerContext.Logger.Returns(logger); var processor = new TiledMapProcessor(); var processorContext = Substitute.For <ContentProcessorContext>(); processorContext.Logger.Returns(logger); var import = importer.Import(filename, importerContext); var result = processor.Process(import, processorContext); return(result.Map); }
private static TmxMap ImportAndProcessMap(string filename) { var importer = new TiledMapImporter(); var processor = new TiledMapProcessor(); var import = importer.Import(filename, Substitute.For<ContentImporterContext>()); var result = processor.Process(import, Substitute.For<ContentProcessorContext>()); return result.Map; }
public void TiledMapImporter_Import_Test() { const string filename = @"TestData\level01.tmx"; var importer = new TiledMapImporter(); var map = importer.Import(filename, Substitute.For<ContentImporterContext>()); Assert.AreEqual("1.0", map.Version); Assert.AreEqual(TmxOrientation.Orthogonal, map.Orientation); Assert.AreEqual(TmxRenderOrder.RightDown, map.RenderOrder); Assert.AreEqual(20, map.Width); Assert.AreEqual(10, map.Height); Assert.AreEqual(128, map.TileWidth); Assert.AreEqual(128, map.TileHeight); Assert.AreEqual("#7d7d7d", map.BackgroundColor); Assert.AreEqual("awesome", map.Properties[0].Name); Assert.AreEqual("42", map.Properties[0].Value); Assert.AreEqual(1, map.Tilesets.Count); Assert.AreEqual(3, map.Layers.Count); Assert.AreEqual(TmxOrientation.Orthogonal,map.Orientation); var tileset = map.Tilesets.First(); Assert.AreEqual(1, tileset.FirstGid); Assert.AreEqual("free-tileset.png", tileset.Image.Source); Assert.AreEqual(652, tileset.Image.Width); Assert.AreEqual(783, tileset.Image.Height); Assert.AreEqual(2, tileset.Margin); Assert.AreEqual("free-tileset", tileset.Name); Assert.AreEqual(null, tileset.Source); Assert.AreEqual(2, tileset.Spacing); Assert.AreEqual(0, tileset.TerrainTypes.Count); Assert.AreEqual(0, tileset.Properties.Count); Assert.AreEqual(128, tileset.TileHeight); Assert.AreEqual(128, tileset.TileWidth); Assert.AreEqual(0, tileset.TileOffset.X); Assert.AreEqual(0, tileset.TileOffset.Y); var tileLayer2 = (TmxTileLayer) map.Layers[0]; Assert.AreEqual("Tile Layer 2", tileLayer2.Name); Assert.AreEqual(1, tileLayer2.Opacity); Assert.AreEqual(0, tileLayer2.Properties.Count); Assert.AreEqual(true, tileLayer2.Visible); Assert.AreEqual(200, tileLayer2.Data.Tiles.Count); Assert.AreEqual(0, tileLayer2.X); Assert.AreEqual(0, tileLayer2.Y); var imageLayer = (TmxImageLayer)map.Layers[1]; Assert.AreEqual("Image Layer 1", imageLayer.Name); Assert.AreEqual(1, imageLayer.Opacity); Assert.AreEqual(0, imageLayer.Properties.Count); Assert.AreEqual(true, imageLayer.Visible); Assert.AreEqual("hills.png", imageLayer.Image.Source); Assert.AreEqual(100, imageLayer.X); Assert.AreEqual(100, imageLayer.Y); var tileLayer1 = (TmxTileLayer)map.Layers[2]; Assert.AreEqual("Tile Layer 1", tileLayer1.Name); Assert.AreEqual(2, tileLayer1.Properties.Count); Assert.AreEqual("customlayerprop", tileLayer1.Properties[0].Name); Assert.AreEqual("1", tileLayer1.Properties[0].Value); Assert.AreEqual("customlayerprop2", tileLayer1.Properties[1].Name); Assert.AreEqual("2", tileLayer1.Properties[1].Value); }
public void TiledMapImporter_Import_Test() { const string filename = @"TestData\level01.tmx"; var importer = new TiledMapImporter(); var map = importer.Import(filename, Substitute.For <ContentImporterContext>()); Assert.AreEqual("1.0", map.Version); Assert.AreEqual(TmxOrientation.Orthogonal, map.Orientation); Assert.AreEqual(TmxRenderOrder.RightDown, map.RenderOrder); Assert.AreEqual(20, map.Width); Assert.AreEqual(10, map.Height); Assert.AreEqual(128, map.TileWidth); Assert.AreEqual(128, map.TileHeight); Assert.AreEqual("#7d7d7d", map.BackgroundColor); Assert.AreEqual("awesome", map.Properties[0].Name); Assert.AreEqual("42", map.Properties[0].Value); Assert.AreEqual(1, map.Tilesets.Count); Assert.AreEqual(3, map.Layers.Count); var tileset = map.Tilesets.First(); Assert.AreEqual(1, tileset.FirstGid); Assert.AreEqual("free-tileset.png", tileset.Image.Source); Assert.AreEqual(652, tileset.Image.Width); Assert.AreEqual(783, tileset.Image.Height); Assert.AreEqual(2, tileset.Margin); Assert.AreEqual("free-tileset", tileset.Name); Assert.AreEqual(null, tileset.Source); Assert.AreEqual(2, tileset.Spacing); Assert.AreEqual(0, tileset.TerrainTypes.Count); Assert.AreEqual(0, tileset.Properties.Count); Assert.AreEqual(128, tileset.TileHeight); Assert.AreEqual(128, tileset.TileWidth); Assert.AreEqual(0, tileset.TileOffset.X); Assert.AreEqual(0, tileset.TileOffset.Y); var tileLayer2 = (TmxTileLayer)map.Layers[0]; Assert.AreEqual("Tile Layer 2", tileLayer2.Name); Assert.AreEqual(1, tileLayer2.Opacity); Assert.AreEqual(0, tileLayer2.Properties.Count); Assert.AreEqual(true, tileLayer2.Visible); Assert.AreEqual(200, tileLayer2.Data.Tiles.Count); Assert.AreEqual(0, tileLayer2.X); Assert.AreEqual(0, tileLayer2.Y); var imageLayer = (TmxImageLayer)map.Layers[1]; Assert.AreEqual("Image Layer 1", imageLayer.Name); Assert.AreEqual(1, imageLayer.Opacity); Assert.AreEqual(0, imageLayer.Properties.Count); Assert.AreEqual(true, imageLayer.Visible); Assert.AreEqual("hills.png", imageLayer.Image.Source); Assert.AreEqual(100, imageLayer.X); Assert.AreEqual(100, imageLayer.Y); var tileLayer1 = (TmxTileLayer)map.Layers[2]; Assert.AreEqual("Tile Layer 1", tileLayer1.Name); Assert.AreEqual(2, tileLayer1.Properties.Count); Assert.AreEqual("customlayerprop", tileLayer1.Properties[0].Name); Assert.AreEqual("1", tileLayer1.Properties[0].Value); Assert.AreEqual("customlayerprop2", tileLayer1.Properties[1].Name); Assert.AreEqual("2", tileLayer1.Properties[1].Value); }
public void TiledMapImporter_Import_Test() { var filePath = PathExtensions.GetApplicationFullPath("TestData", "level01.tmx"); var logger = Substitute.For <ContentBuildLogger>(); var importer = new TiledMapImporter(); var importerContext = Substitute.For <ContentImporterContext>(); importerContext.Logger.Returns(logger); var contentItem = importer.Import(filePath, importerContext); var map = contentItem.Data; Assert.Equal("1.0", map.Version); Assert.Equal(TiledMapOrientationContent.Orthogonal, map.Orientation); Assert.Equal(TiledMapTileDrawOrderContent.RightDown, map.RenderOrder); Assert.Equal(20, map.Width); Assert.Equal(10, map.Height); Assert.Equal(128, map.TileWidth); Assert.Equal(128, map.TileHeight); Assert.Equal("#7d7d7d", map.BackgroundColor); Assert.Equal("awesome", map.Properties[0].Name); Assert.Equal("42", map.Properties[0].Value); Assert.Single(map.Tilesets); Assert.Equal(3, map.Layers.Count); Assert.Equal(TiledMapOrientationContent.Orthogonal, map.Orientation); var tileset = map.Tilesets.First(); Assert.Equal(1, tileset.FirstGlobalIdentifier); Assert.Equal("free-tileset.png", Path.GetFileName(tileset.Image.Source)); Assert.Equal(652, tileset.Image.Width); Assert.Equal(783, tileset.Image.Height); Assert.Equal(2, tileset.Margin); Assert.Equal(30, tileset.TileCount); Assert.Equal("free-tileset", tileset.Name); Assert.Null(tileset.Source); Assert.Equal(2, tileset.Spacing); //Assert.Equal(0, tileset.TerrainTypes.Count); Assert.Empty(tileset.Properties); Assert.Equal(128, tileset.TileHeight); Assert.Equal(128, tileset.TileWidth); Assert.Equal(0, tileset.TileOffset.X); Assert.Equal(0, tileset.TileOffset.Y); var tileLayer2 = (TiledMapTileLayerContent)map.Layers[0]; Assert.Equal("Tile Layer 2", tileLayer2.Name); Assert.Equal(1, tileLayer2.Opacity); Assert.Empty(tileLayer2.Properties); Assert.True(tileLayer2.Visible); Assert.Equal(200, tileLayer2.Data.Tiles.Count); Assert.Equal(0, tileLayer2.X); Assert.Equal(0, tileLayer2.Y); var imageLayer = (TiledMapImageLayerContent)map.Layers[1]; Assert.Equal("Image Layer 1", imageLayer.Name); Assert.Equal(1, imageLayer.Opacity); Assert.Empty(imageLayer.Properties); Assert.True(imageLayer.Visible); Assert.Equal("hills.png", Path.GetFileName(imageLayer.Image.Source)); Assert.Equal(100, imageLayer.X); Assert.Equal(100, imageLayer.Y); var tileLayer1 = (TiledMapTileLayerContent)map.Layers[2]; Assert.Equal("Tile Layer 1", tileLayer1.Name); Assert.Equal(2, tileLayer1.Properties.Count); Assert.Equal("customlayerprop", tileLayer1.Properties[0].Name); Assert.Equal("1", tileLayer1.Properties[0].Value); Assert.Equal("customlayerprop2", tileLayer1.Properties[1].Name); Assert.Equal("2", tileLayer1.Properties[1].Value); }
private static TmxMap ImportAndProcessMap(string filename) { var logger = Substitute.For<ContentBuildLogger>(); var importer = new TiledMapImporter(); var importerContext = Substitute.For<ContentImporterContext>(); importerContext.Logger.Returns(logger); var processor = new TiledMapProcessor(); var processorContext = Substitute.For<ContentProcessorContext>(); processorContext.Logger.Returns(logger); var import = importer.Import(filename, importerContext); var result = processor.Process(import, processorContext); return result.Map; }