Click here to Skip to main content

Carl Sr asked:

Open original thread
I am building a world editor for a game and I need help with the process of loading a map file. Everything is complete except for the map loading. I know how to load xml in c++ using tinyxml but my c# is really rusty. I just need to know how to take data from each of the elements so I can use them in the world editor. Any help would be massively appreciated.
 
this is an example of the file I am trying to load into my editor.
I know the layout of the xml is pretty poorly designed but I cannot modify it because I can not change the game client's LoadMap function.
 
<?xml version="1.0" encoding="UTF-8"?>
-<Map> -<tileset progPath="../../../../../../../../Desktop/TestTileset.png" 
	path="Desktop/TestTileset.png" tileSetSizeY="20" tileSetSizeX="20" tileHeigh="32" tileWidth="32" GridSizeH="5" GridSizeW="5">
		tilesetinfo
		<tileset index="0" y="0" x="0">tile</tileset>
		<tileset index="0" y="1" x="0">tile</tileset>
		<tileset index="0" y="2" x="0">tile</tileset>
		<tileset index="0" y="0" x="1">tile</tileset>
		<tileset index="0" y="1" x="1">tile</tileset>
		<tileset index="0" y="2" x="1">tile</tileset>
</tileset> 
 <item y="36" x="40" lane="2">waypoint</item>
 <item y="116" x="23" lane="2">waypoint</item>
 <item y="116" x="23" lane="2">node</item>
 <item y="120" x="72" lane="2">waypoint</item>
 <item y="120" x="72" lane="2">node</item>
 <item y="114" x="120" lane="2">waypoint</item>
 <item y="114" x="120" lane="2">node</item>
 <item y="70" x="138" lane="2">waypoint</item>
 <item y="116" x="23" lane="2" owner="1">tower</item>
 <item y="114" x="120" lane="2" owner="2">tower</item>
 <item y="30" x="117" owner="1">avatar</item>
 <item y="126" x="125" owner="2">avatar</item>
</Map>
Tags: C#, XML, Game

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100