- Revamped level initialization. At some point, the ability to start over after dying stopped working. I ignored it because I was working on other things. Now, as I’m getting ready for the second developer release (Release 2), I needed to fix this bug. Understanding how levels were being initialized was difficult; code was running across multiple scripts on multiple Unity GameObjects, triggered by different events at different times. Some of the game state was stored in objects that persisted across scenes, so the solution wasn’t as simple as reloading the scene. The solution I came up with was largely based on event handling. The various game managers (game turn manager, actor manager, etc.) now listen for significant events, such as setting the map size (required to set the tilemap sizes), generating the map, and creating the player, and do the appropriate initialization at the point that the required objects become available. The procedural initialization logic that was spread out across multiple scripts has been removed. I also made some changes to the game managers to reduce or eliminate their reliance on other managers. It’s not perfect but it’s a lot cleaner and easier to follow.
- Remember the last known position for tracked actors. Actors now remember the last known position of the actors they are tracking and have previously seen. This is useful for when the player can no longer be seen by the actor, for example if the player moves into another room or drinks an invisibility potion. The actor will now move to the player’s last known position and determine what to do next.
- Bug fixes and code clean up.
Next week, more play testing and bug fixes to close out Release 2.