public static OgmoTilemap LoadLevelData(string tilesetFileName) { if (tilesetFileName.EndsWith(".json")) { tilesetFileName = tilesetFileName.Remove(tilesetFileName.Length - 5); } var assembly = Assembly.GetExecutingAssembly(); try { using (Stream stream = assembly.GetManifestResourceStream("MonoGame_Experiments.Ogmo_Project." + tilesetFileName + ".json")) using (StreamReader reader = new StreamReader(stream)) { string result = reader.ReadToEnd(); //string result = string.Empty; //result = streamReader.ReadToEnd(); OgmoTilemap tilemap = JsonSerializer.Deserialize(result, typeof(OgmoTilemap)) as OgmoTilemap; return(tilemap); } } catch { return(default);
public Tilemap(Entity entity, string tilemapName) : base(entity, SolidTypes.Tilemap) { using (OgmoTilemap tilemap = OgmoTilemapManager.LoadLevelData(tilemapName)) { RenderTarget2D = new RenderTarget2D(Game.Graphics.GraphicsDevice, tilemap.width, tilemap.height); TilemapData = tilemap; UpdateRenderTarget(); } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); RenderTarget2D?.Dispose(); RenderTarget2D = null; TilemapData?.Dispose(); TilemapData = null; }