mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-14 17:09:31 +07:00
parsing tmx data done
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b96dccad0a464c0c8462411423c292a
|
||||
timeCreated: 1453320478
|
||||
timeCreated: 1453389527
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
</tileset>
|
||||
<layer name="Tile Layer 2" width="25" height="25" visible="0" offsetx="32" offsety="16">
|
||||
<properties>
|
||||
<property name="em" value=""/>
|
||||
<property name="layer prop" value="765"/>
|
||||
</properties>
|
||||
<data>
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace IsoTools.Tiled.Internal {
|
||||
}
|
||||
|
||||
static void LoadTiledMapLayerFromTmxLayerElem(XElement layer_elem, TiledMapLayerData layer) {
|
||||
layer.Name = SafeLoadStrFromElemAttr (layer_elem, "name" , string.Empty);
|
||||
layer.Name = SafeLoadStrFromElemAttr (layer_elem, "name" , layer.Name);
|
||||
layer.Width = SafeLoadIntFromElemAttr (layer_elem, "width" , layer.Width);
|
||||
layer.Height = SafeLoadIntFromElemAttr (layer_elem, "height" , layer.Height);
|
||||
layer.OffsetX = SafeLoadIntFromElemAttr (layer_elem, "offsetx", layer.OffsetX);
|
||||
@@ -138,7 +138,7 @@ namespace IsoTools.Tiled.Internal {
|
||||
|
||||
static int SafeLoadIntFromElemAttr(XElement elem, string attr_name, int def_value) {
|
||||
int value;
|
||||
if ( int.TryParse(SafeLoadStrFromElemAttr(elem, attr_name, ""), out value) ) {
|
||||
if ( elem != null && int.TryParse(SafeLoadStrFromElemAttr(elem, attr_name, ""), out value) ) {
|
||||
return value;
|
||||
}
|
||||
return def_value;
|
||||
@@ -146,7 +146,7 @@ namespace IsoTools.Tiled.Internal {
|
||||
|
||||
static bool SafeLoadBoolFromElemAttr(XElement elem, string attr_name, bool def_value) {
|
||||
int value;
|
||||
if ( int.TryParse(SafeLoadStrFromElemAttr(elem, attr_name, ""), out value) ) {
|
||||
if ( elem != null && int.TryParse(SafeLoadStrFromElemAttr(elem, attr_name, ""), out value) ) {
|
||||
return value != 0;
|
||||
}
|
||||
return def_value;
|
||||
@@ -158,8 +158,10 @@ namespace IsoTools.Tiled.Internal {
|
||||
foreach ( var prop_elem in props_elem.Elements("property") ) {
|
||||
var prop_name = SafeLoadStrFromElemAttr(prop_elem, "name" , string.Empty);
|
||||
var prop_value = SafeLoadStrFromElemAttr(prop_elem, "value", string.Empty);
|
||||
props.Add(prop_name);
|
||||
props.Add(prop_value);
|
||||
if ( !string.IsNullOrEmpty(prop_name) && prop_value != string.Empty ) {
|
||||
props.Add(prop_name);
|
||||
props.Add(prop_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace IsoTools.Tiled {
|
||||
|
||||
[System.Serializable]
|
||||
public class TiledMapLayerData {
|
||||
public string Name = string.Empty;
|
||||
public string Name = "";
|
||||
public int Width = 0;
|
||||
public int Height = 0;
|
||||
public int OffsetX = 0;
|
||||
@@ -21,7 +21,7 @@ namespace IsoTools.Tiled {
|
||||
[System.Serializable]
|
||||
public class TiledMapTilesetData {
|
||||
public int FirstGid = 0;
|
||||
public string Name = string.Empty;
|
||||
public string Name = "";
|
||||
public int Margin = 0;
|
||||
public int Spacing = 0;
|
||||
public int TileWidth = 0;
|
||||
@@ -29,7 +29,7 @@ namespace IsoTools.Tiled {
|
||||
public int TileCount = 0;
|
||||
public int TileOffsetX = 0;
|
||||
public int TileOffsetY = 0;
|
||||
public string Image = string.Empty;
|
||||
public string Image = "";
|
||||
public int ImageWidth = 0;
|
||||
public int ImageHeight = 0;
|
||||
public List<string> Properties = new List<string>();
|
||||
|
||||
Reference in New Issue
Block a user