-
Notifications
You must be signed in to change notification settings - Fork 1
Serialization Design
Isaac Abrahamson edited this page Nov 7, 2018
·
7 revisions
An overview of how serialization and deserialization will work in this project.
Interface ISerializer that contains following method stubs:
string Serialize();
ISerializer Deserialize(string serialized);Abstract classes will inherit ISerializer. Abstract classes will implement Serialize() but not Deserialize().
Classes inheriting from abstract classes will implement Deserialize() and return their own object type as an ISerializer. The class that calls Deserialize() must cast it to the correct type. Example:
CharacterEnemy enemy = new CharacterEnemy();
enemy = (CharacterEnemy) enemy.Deserialize(data);The data will be stored in a textfile inside a hidden .data folder in the game's directory. The data file will have the following format:
Key=Value;Key=Value1=|Key=value|,Value2;Key=Value1=|Key=value1,value2|,Value2;
The key for this is as follows:
| Symbol | Meaning |
|---|---|
| | | Object or group |
| = | Key is equal to a value |
| , | Separates list of values in a key |
| ; | Seperates keys in an object |
Example data file (pending model implementation):
PlayerCharacter=CharacterPlayer.Scout;Characters=|Character1=CharacterPlayer.Scout|,|Character2=CharacterPlayer.Scout|,|Character3=CharacterPlayer.Scout|;