Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Deserialize XML to object for game editor

$
0
0

@mgtaa wrote:

Hello! I'm trying to write a game editor. I can already load my Map class from my game project with Content.Load<>.

I'm running into issues trying to find a way to deserialize the XML file. I'm not too sure which method to use, but every one I try runs into one problem or another.

If I try to use the IntermediateSerializer.Deserialize method, it says it doesn't support multi-dimentional arrays.

Trying to use the deserialize method of an XmlSerializer returns errors reflecting the type(Map)

This is the code for the Map class:
public class Map
{
#region Variables/Properties

        public string BGpath { get; set; }        

        public string collisionMaskFile;   


        [XmlArray("Events")]
        public List<Scene> Events;

        [XmlArray("Entities")]
        [XmlArrayItem("NPC", typeof(NPC))]
        public List<Entity> Entities;

        [XmlArray("MapObjects")]
        public List<MapObject> MapObjects;
        #endregion

        //public List<MapLayer> Layers { get; set; }

        //public CollisionLayer collisionLayer;

    }

Example of one of the XML files without much data in it:

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Practice_RPG="Practice_RPG">
  <Asset Type="Practice_RPG:Map">
    <BGpath>C:\STUFF</BGpath>
    <collisionMaskFile>TestText</collisionMaskFile>
    <Events>    </Events>
    <Entities></Entities>
    <MapObjects> </MapObjects>
  </Asset>
</XnaContent>

Any help would be appreciated.

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles