What is the procedure followed by game programmers for saving and resuming game state? like files/mappings. I want to save it for tower defense game and I am using unity3D game engine.
|
I generally don't think in terms of a memory snapshot, but rather I just make a list of which values need to be saved between sessions and save those values into an external file. This depends of course on the needs of your specific game, but usually I simply save the state of the current level (ie. where all the enemies are, what their health is, etc.) and then higher level stuff like what levels the player has already completed. |
|||||
|
|
This answer is Unity3d specific.
|
|||||||||
|
|
When I refer to the current state of the game I am referring the memory snapshot at the moment of saving. You need to be able to recreate that from the data you are going to store on you HDD. It is easiest just serialize all of you classes that have data that needs to be persistent and dump it to the HDD, essentially performing a memory dump. Problem with this is that altering you classes will change the number/types of serialized values and break old saves. Also because you are saving everything it increases loading times. Its more efficient to mark individual fields that are actually needed to rebuild the current "memory snapshot" with whatever attribute system your serializer/IDE uses. Then rebuild the "memory snapshot" from that saved data. Also I have never used Unity before so it may have something built in. However, this is the typical approach. |
|||||||
|
|
For a TD I'd probably save exclusively between waves. That way all you have to think about is the towers. Put some automatic save points in the levels, no more than 10 minutes between, but less is probably preferable. Of course if your levels are short enough you could simply save nothing but the campaign status. |
|||
|
|

