Search Unity

Roguelike Saving Serialization

Discussion in 'Scripting' started by LostMystic, Jan 28, 2015.

  1. LostMystic

    LostMystic

    Joined:
    May 14, 2012
    Posts:
    5
    I'm playing around with a roguelike and although there's a million ways to serialize, I realize I'd like some direction on the best way given this criteria:

    1. Every move (turn) the data is saved / serialized automatically. (There is no save game command, the game automatically saves)
    2. Some of the data is in traditional class data structures, others are in game objects with components.
    3. I'd like to do as little retranslation (converting from a specialized save game form to working game form), and back as possible.
    4. Saving is constant and causes no pausing. (There's some real time elements in gameplay as well.)
    Data Structures
    • Current Level
      • Tiles
        • Unmoveable Interactable Objects (Features)
        • Items (On ground)
        • Persistant Effects
      • List of Active Creatures
        • Player Character
        • Followers
        • Items Possessed
    • Old Levels
      • Notable Creatures Killed
      • Modifications to geometry/features
      • Persistant Effects
    • Game Stats
      • Plots/Quests
      • Anything else not relivant to current level or old areas.

    A random seed can regenerate the level no problem, but it cannot remember any modifications the player did to it. For many levels after the player leaves, this is fine. A number of them need to either deteriorate, or remember large aspects about them. (Who was killed, walls destroyed, treasure gathered etc.)

    The imperfect solutions I have so far:

    Scriptable Objects - I'm actually loving scriptable objects. One blog said something about them not remembering after you shut down the unity editor and start it back up again. Apparently this doesn't happen for me.
    Unity Serializer - This is an awesome product. It seems to be designed for active saving. Not round by round saving. Moreover, I'm playing with some real time elements, and this causes a considerable pause.
    Convert to Save Format - This involves converting things to save game format and back. This is both a lot of work, and as soon as any part of the data structure changes, all this stuff has to change too. Old save games have little hope of working after. It works, but it's just causing a lot of pain in the future.

    I'm up for any other suggestions, or what you guys would suggest.
     
  2. Fydar

    Fydar

    Joined:
    Feb 23, 2014
    Posts:
    69
    Do you have all of this in a single array somewhere? People say XML saving is easy, ignore what other people. I would save it in Steaming Assets so people can export their game.
     
  3. LostMystic

    LostMystic

    Joined:
    May 14, 2012
    Posts:
    5
    The data isn't in a single array. It's in a mixture of game objects and data classes. (Essentially structures). Although I can convert it to XML, I'd rather avoid it. For the Convert to Save Format reasons I listed above.