Game and Level State Logic

I’m trying to find the best way to implement a general script that will temporarily store variables from the player, inventory, level specific scripts (possibly), etc. Currently, I have a script that stores all the information of my player (and is connected to my player’s prefab) as well as the contents of the inventory.

I haven’t thought of a way to program/collect information from each level (mainly because each level will have there own set of variables.

I created a graph of the logic that I intend to use, everything with an asterisk I’m not entirely sure how I should implement it.

alt text

So, is this a good implementation? Should I have a “Game State” class? And any specific way I can do a “Temp Save” Container?
I would also like to “prepare” this information when I need to save.

Any advice would be appreciated.

If you work with interfaces (c#), you could define an interface for your storing/loading.

Then you could replace the implementation in each level based on the specific needs.

For example:

public interface ISavegameManager { 
yourSaveGameDataStructure load();
void save(yourSaveGameDataStructure savegamedata);
}

then you could go and implement a different SavegameManager for every scene:

public Level1SaveGameManager : ISavegameManager
{
   public yourSaveGameDataStructure load()
   {
       //read data from whatever datasource you stored it..
   }

   public void save(yourSaveGameDataStructure savegamedata) 
   {
       //save your data to whatever source you like
   }
}

In the end you can simply exchange the SavegameManager on your “global” GameManager Script on level loading, or whenever you need to change it.