Capstone: Month 2 Week 4

This post covers the 8th week of our Capstone project.

This Week’s Tasks

This week I was tasked with:

  • Save/Load System
  • AI Drone Enemy
  • Screen Damage FX

For the purposes of this post, I will be focusing on the Save/Load System

Save/Load System

For our save/load system, I decided to go with a classic slot-based system. This includes 3 manual slots, as well as a planned autosave slot in the future. I beleive this will be more than sufficient for our game.

The actual savefile is implemented as a serializable C# class known as SaveData, with many variables that are set in it’s constructor. Upon saving via our SaveManager class, we create an instance of the SaveData class, which due to its constructor already has all needed data, and then we use the built-in class BinaryFormatter to format the data into a byte array, which is then saved to a file.

These files can be located at %userprofile%\appdata\locallow\DefaultCompany\TheEscape on Windows. This path is determined via Unity’s Application.persistentDataPath variable.

Finally, these variables are loaded back into the game in a very similar way. Our SaveManager class creates a new instance of SaveData, and then uses the BinaryFormatter to load the data from the file. This data is created as an instance of the SaveData class, and finally we read all of our saved variables and apply them to the relevant systems.