I am trying to serialize my player data and save it to an xml document. Inside my player class, I have a list of skills.
| private List<Skill> m_skills = new List<Skill>(); |
My skill class branches into specific skills such as MeleeAttack. These classes contain references to the player data. For example I have a stats class within my player class.
| public class MeleeAttack : Skill |
| { |
| #region VARIABLES |
| |
| PhysicsObject m_physics; |
| InputStates m_movement; |
| Stats m_stats; |
| Orientation m_orientation; |
|
| #endregion |
|
|
| #region CONSTRUCTORS |
| |
| public MeleeAttack() |
| { |
| } |
| |
| public MeleeAttack(InputStates movement, PhysicsObject physics, Stats stats, Orientation orientation) |
| { |
| m_movement = movement; |
| m_physics = physics; |
| m_stats = stats; |
| m_orientation = orientation; |
| } |
|
| #endregion |
When I serialize my player, the xml document just stores the list of skill types, not the data within them. So when I load my game, the skills are remade using the empty constructor, and the variables are all null.
I searched Shawn Hargreaves' blog again, and I could only find an example to serialize shared data using the IntermediateSerializer, and I am using the XmlSerializer.
Is it possible to properly serialize the references in this class, or is this just a poor choice of design?