public bool LoadTileSheets() { string[] files = null; try { files = Directory.GetFiles(Constants.Paths.TileDirectory); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Exception while reading directory: " + e.Message); return(false); } if (files != null) { foreach (string file in files) { if (file.EndsWith(".jts", StringComparison.OrdinalIgnoreCase)) { TileSheet newTileSheet = TileSheet.ReadFromFile(file); if (newTileSheet != null) { try { TileContent.Load <Texture2D>(newTileSheet.TextureKey); } catch (ContentLoadException e) { System.Diagnostics.Debug.WriteLine("Error while reading file" + newTileSheet.TextureKey + ": " + e.Message); Exit(); } TileSheets.Add(newTileSheet.TextureKey, newTileSheet); newTileSheet.GetTexture = GetTileSheet; } } } } return(true); }
public bool LoadTileSheetFromFile() { try { if (File.Exists(TileSheetUrl)) { LoadedTileSheet = TileSheet.ReadFromFile(TileSheetUrl); if (LoadedImage != null) { LoadedImage.Dispose(); } Image newImage = null; if (File.Exists(ImageUrl)) { newImage = Image.FromFile(ImageUrl, true); } if (newImage != null) { LoadedImage = newImage; LoadedTileSheet.TextureKey = Path.GetFileNameWithoutExtension(ImageUrl); } else { LoadedImage = null; LoadedTileSheet.TextureKey = ""; } UpdateSizeInFrames(); } } catch (Exception e) { System.Console.WriteLine("Exception while reading file: " + e.Message); return(false); } return(true); }
static void Main(string[] args) { string response; int intResponse; pnn("TileSheet: "); response = getLine(); TileSheet tileSheet = TileSheet.ReadFromFile(response + ".jts"); if (tileSheet == null) { pln("FAIL!"); return; } pln(" -- Static Frames --"); pnn("North Facing: "); Int32.TryParse(getLine(), out intResponse); int north = intResponse; pnn("East Facing: "); Int32.TryParse(getLine(), out intResponse); int east = intResponse; pnn("South Facing: "); Int32.TryParse(getLine(), out intResponse); int south = intResponse; pnn("West Facing: "); Int32.TryParse(getLine(), out intResponse); int west = intResponse; pln(" -- Animations -- "); foreach (var anim in tileSheet.AnimationKeys) { pln(anim); } pnn("North Anim: "); string northAnim = getLine(); pnn("East Anim: "); string eastAnim = getLine(); pnn("South Anim: "); string southAnim = getLine(); pnn("West Anim: "); string westAnim = getLine(); AnimationSet res = new AnimationSet(); res.SetStaticFrames(north, east, south, west); res.SetMovingAnimations(northAnim, eastAnim, southAnim, westAnim); pnn("Output base file name: "); response = getLine(); if (response.Length > 0) { AnimationSet.WriteToFile(response + ".jas", res); } pln("Done."); }