Example #1
0
 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);
 }
Example #2
0
 public Texture2D GetTileSheet(string filename)
 {
     return(TileContent.Load <Texture2D>(filename));
 }