I'm currently trying to load game objects from a Tiled (Tiled map editor) map file into a game engine I'm making in C#. I'm using TiledSharp (Link to github here). It uses a dictionary to hold properties about each individual tile (or 'game object') I'm trying to load. But for some reason I get an error when I loop through the properties, and I also get an error if I check if it's null
Here's a snippet of the code I'm using:
for (int l = 0; l < tmxMap.Tilesets[k].Tiles.Count; l++)
// This line throws an error
if (tmxMap.Tilesets[k].Tiles[l].Properties != null)
// and if I remove the above line, this line throws an error
for (int m = 0; m < tmxMap.Tilesets[k].Tiles[l].Properties.Count; m++)
The error I get says The given key was not present in the dictionary. But... I'm not even checking for a key.
Am I missing something?
Any help would be appreciated.