As I mentioned in the very first Dev Log, the reason for all the level loading work was because of issues with the minimap. Now that the level loading code is out of the way, I could focus on making the minimap functional.
Here’s what it looks like:
Since this is the third post about this process, I’m going to try and keep it short.
I can now load any level in the game with a simple variable switch! There’s still a few things that have to be fixed for it to be ready for prime time, but the basic functionality is there.
I still need to:
- Make the minimap work. The map itself loads, but I need to write a manager for the icons to load/unload
- The loading changes broke using traps. I need to refactor how I’m handing them so that the UI will manage showing/hiding the trap icons in inventory.
- I still need to make the camera dynamic for the larger levels. It needs to scroll up and down based on the location of the robber.
- There is no cleanup at the end of the level. I was relying on having one level per scene and letting Unity do the cleanup. Since I’m using a single scene for all levels now, I need to do my own cleanup.
So last time I talked about how .plist’s wouldn’t import into Unity without an excessive amount of work and needing to use .txt files instead. I now have the text files brought into Unity as a Text Asset, and created a container class to parse them. The class itself is simple: public variables for the data in the text file, and it uses StreamReader to parse each line of text.
So, my experiments with using the .plist files from the iOS version of Cops ‘n Robbers have met with failure. Unity throws “unexpected xml” errors when trying to read the files. XML was a bit overkill for level data (a 2D arrary and a few parameters); but using the existing files would have been nice. I’ll have to use text files and add the extra parameters that I want to use.
Here’s what was in the plist files: