Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.9" tiledversion="1.9.0" orientation="orthogonal" renderorder="right-down" width="25" height="15" tilewidth="16" tileheight="16" infinite="0" nextlayerid="8" nextobjectid="17">
<map version="1.9" tiledversion="1.9.2" orientation="orthogonal" renderorder="right-down" width="25" height="15" tilewidth="16" tileheight="16" infinite="0" nextlayerid="8" nextobjectid="17">
<tileset firstgid="1" source="Zoria Tileset/water.tsx"/>
<tileset firstgid="229" source="Zoria Tileset/tiles.tsx"/>
<tileset firstgid="709" source="Zoria Tileset/scraps.tsx"/>
<tileset firstgid="1189" source="Zoria Tileset/overhead-objects.tsx"/>
<tileset firstgid="206" source="Zoria Tileset/tiles.tsx"/>
<tileset firstgid="646" source="Zoria Tileset/scraps.tsx"/>
<tileset firstgid="647" source="Zoria Tileset/overhead-objects.tsx"/>
<layer id="1" name="Ground" width="25" height="15">
<data encoding="csv">
600,601,602,709,709,709,709,709,709,709,709,709,709,629,630,630,630,630,630,630,631,193,193,193,193,
632,665,634,709,709,709,709,709,709,709,709,709,709,629,630,630,630,630,630,630,631,193,193,193,193,
632,633,634,709,709,709,709,709,709,709,709,709,709,629,630,630,630,630,630,630,631,193,193,193,193,
632,633,634,709,709,709,709,709,709,709,709,709,709,629,630,630,630,630,630,630,631,193,193,193,193,
632,633,634,709,709,709,709,709,709,709,709,709,709,629,630,630,630,630,630,630,631,193,193,193,193,
632,633,634,709,709,709,709,709,709,709,709,709,709,661,662,662,662,662,662,662,663,205,205,205,205,
632,633,634,709,709,709,709,709,709,709,709,709,709,709,25,26,26,26,26,26,26,26,26,26,26,
632,633,634,709,709,709,709,709,709,709,709,709,709,709,37,1,1,1,1,1,1,1,1,1,1,
632,633,634,709,709,709,709,709,709,709,709,709,709,709,306,306,1,1,1,1,1,1,1,1,38,
632,633,634,709,709,709,709,709,709,709,709,709,709,709,37,1,1,1,1,1,1,1,1,1,1,
632,665,634,709,709,709,709,709,709,709,709,709,709,709,49,123,1,1,1,1,38,1,1,1,1,
632,633,634,709,709,709,709,709,709,709,709,709,709,709,709,49,50,123,1,1,1,1,1,1,1,
632,633,634,536,537,537,537,537,537,537,537,538,709,709,709,709,709,49,123,1,1,1,1,1,1,
632,665,634,568,633,633,633,633,633,633,633,570,709,709,709,709,709,709,49,50,123,1,1,1,1,
600,601,602,600,601,601,601,601,601,601,601,602,627,598,598,598,598,598,598,628,49,50,50,50,50
577,578,579,646,646,646,646,646,646,646,646,646,646,606,607,607,607,607,607,607,608,193,193,193,193,
609,642,611,646,646,646,646,646,646,646,646,646,646,606,607,607,607,607,607,607,608,193,193,193,193,
609,610,611,646,646,646,646,646,646,646,646,646,646,606,607,607,607,607,607,607,608,193,193,193,193,
609,610,611,646,646,646,646,646,646,646,646,646,646,606,607,607,607,607,607,607,608,193,193,193,193,
609,610,611,646,646,646,646,646,646,646,646,646,646,606,607,607,607,607,607,607,608,193,193,193,193,
609,610,611,646,646,646,646,646,646,646,646,646,646,638,639,639,639,639,639,639,640,205,205,205,205,
609,610,611,646,646,646,646,646,646,646,646,646,646,646,25,26,26,26,26,26,26,26,26,26,26,
609,610,611,646,646,646,646,646,646,646,646,646,646,646,37,1,1,1,1,1,1,1,1,1,1,
609,610,611,646,646,646,646,646,646,646,646,646,646,646,283,283,1,1,1,1,1,1,1,1,38,
609,610,611,646,646,646,646,646,646,646,646,646,646,646,37,1,1,1,1,1,1,1,1,1,1,
609,642,611,646,646,646,646,646,646,646,646,646,646,646,49,123,1,1,1,1,38,1,1,1,1,
609,610,611,646,646,646,646,646,646,646,646,646,646,646,646,49,50,123,1,1,1,1,1,1,1,
609,610,611,513,514,514,514,514,514,514,514,515,646,646,646,646,646,49,123,1,1,1,1,1,1,
609,642,611,545,610,610,610,610,610,610,610,547,646,646,646,646,646,646,49,50,123,1,1,1,1,
577,578,579,577,578,578,578,578,578,578,578,579,604,575,575,575,575,575,575,605,49,50,50,50,50
</data>
</layer>
<layer id="2" name="Trim" width="25" height="15">
<data encoding="csv">
0,0,0,585,0,0,0,0,0,0,0,586,587,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,585,0,0,0,0,0,0,0,586,587,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,585,0,0,0,0,0,0,0,586,587,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,267,0,0,265,0,266,0,560,557,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,0,0,0,265,0,0,0,0,589,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,0,0,0,265,265,265,265,265,589,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,0,0,0,265,0,0,0,265,0,560,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,267,0,267,265,267,0,550,265,0,266,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,0,0,0,265,265,265,265,265,265,265,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,0,267,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,591,592,496,496,496,496,496,496,496,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,586,586,586,586,586,586,586,586,586,591,0,266,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,591,0,0,0,269,0,0,0,0,0,0,0,0,
0,0,0,0,271,0,550,0,242,243,243,0,495,496,496,496,496,496,0,0,0,0,0,0,0,
0,0,0,562,0,0,0,0,0,0,0,563,564,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,562,0,0,0,0,0,0,0,563,564,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,562,0,0,0,0,0,0,0,563,564,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,244,0,0,242,0,243,0,537,534,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,0,0,0,242,0,0,0,0,566,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,0,0,0,242,242,242,242,242,566,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,0,0,0,242,0,0,0,242,0,537,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,244,0,244,242,244,0,527,242,0,243,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,0,0,0,242,242,242,242,242,242,242,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,0,244,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,568,569,473,473,473,473,473,473,473,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,563,563,563,563,563,563,563,563,563,568,0,243,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,568,0,0,0,246,0,0,0,0,0,0,0,0,
0,0,0,0,248,0,527,0,219,220,220,0,472,473,473,473,473,473,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
<layer id="3" name="Deco" width="25" height="15">
<data encoding="csv">
0,0,0,316,317,318,319,320,321,322,323,324,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,275,0,348,349,350,351,352,353,354,355,356,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,380,381,382,383,668,385,386,387,388,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,244,0,0,0,0,0,0,0,0,244,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,293,294,295,296,297,298,299,300,301,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,252,0,325,326,327,328,329,330,331,332,333,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,357,358,359,360,645,362,363,364,365,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,221,0,0,0,0,0,0,0,0,221,0,0,0,0,0,0,0,0,0,0,0,0,
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,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Expand All @@ -82,6 +82,14 @@
</layer>
<objectgroup id="4" name="Objects">
<object id="3" name="Spawn" x="120" y="128">
<properties>
<property name="PlaintInt" type="int" value="0"/>
<property name="TestProperty" type="class" propertytype="TestClass">
<properties>
<property name="Field3" value="new String prop"/>
</properties>
</property>
</properties>
<point/>
</object>
</objectgroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<objecttypes>
<objecttype name="Script" color="#aa0000">
<property name="CorrespondType" type="int" propertytype="TriggerType" default="0"/>
<property name="ScriptFile" type="file" default=""/>
</objecttype>
<objecttype name="TestClass" color="#a0a0a4">
<property name="Field1" type="int" default="0"/>
<property name="Field2" type="int" default="0"/>
<property name="Field3" type="string" default="a string"/>
<property name="SubClass" type="class" propertytype="TestSubClass" default=""/>
</objecttype>
<objecttype name="TestSubClass" color="#a0a0a4">
<property name="Value" type="string" default="the value"/>
</objecttype>
</objecttypes>
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
using System;
using System.Collections.Generic;
using Unity.Plastic.Newtonsoft.Json.Linq;
using UnityEngine;

namespace SuperTiled2Unity
{
[Serializable]
public class CustomProperty
{
private static Dictionary<string, JObject> JObjectDictionary_ = new Dictionary<string, JObject>();

public string m_Name;
public string m_Type;
public string m_Value;

public JObject m_JObject
{
get => JObjectDictionary_[m_Name];
set => JObjectDictionary_[m_Name] = value;
}

public CustomProperty CloneProperty()
{
var newObject = new CustomProperty();
newObject.m_Name = m_Name;
newObject.m_Type = m_Type;
newObject.m_JObject = m_JObject;

return newObject;
}

public bool IsEmpty
{
get { return string.IsNullOrEmpty(m_Name); }
get { return string.IsNullOrEmpty(m_Name) && m_JObject != null; }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MonoBehaviour:
m_AnimationFramerate: 20
m_DefaultMaterial: {fileID: 0}
m_MaterialMatchings: []
m_ObjectTypesXml: {fileID: 0}
m_ObjectTypesXml: {fileID: 4900000, guid: 3f5cc66e901a6884e889e72b17751b14, type: 3}
m_ParseXmlError:
m_CollisionGeometryType: 1
m_LayerColors:
Expand Down Expand Up @@ -53,5 +53,35 @@ MonoBehaviour:
- {r: 1, g: 0.64705884, b: 0, a: 1}
- {r: 0, g: 1, b: 1, a: 1}
- {r: 0.7372549, g: 0.56078434, b: 0.56078434, a: 1}
m_CustomObjectTypes: []
m_CustomObjectTypes:
- m_Name: Script
m_Color: {r: 0.6666667, g: 0, b: 0, a: 1}
m_CustomProperties:
- m_Name: CorrespondType
m_Type: int
m_Value:
- m_Name: ScriptFile
m_Type: file
m_Value:
- m_Name: TestClass
m_Color: {r: 0.627451, g: 0.627451, b: 0.6431373, a: 1}
m_CustomProperties:
- m_Name: Field1
m_Type: int
m_Value:
- m_Name: Field2
m_Type: int
m_Value:
- m_Name: Field3
m_Type: string
m_Value:
- m_Name: SubClass
m_Type: class
m_Value:
- m_Name: TestSubClass
m_Color: {r: 0.627451, g: 0.627451, b: 0.6431373, a: 1}
m_CustomProperties:
- m_Name: Value
m_Type: string
m_Value:
m_PrefabReplacements: []
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ namespace SuperTiled2Unity.Editor
{
public static class CustomPropertyExtensions
{
public static CustomProperty CloneProperty(this CustomProperty property)
{
var cloned = new CustomProperty();
cloned.m_Name = property.m_Name;
cloned.m_Type = property.m_Type;
cloned.m_Value = property.m_Value;

return cloned;
}

public static int CombineFromSource(this List<CustomProperty> list, List<CustomProperty> source)
{
int numAdded = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static void BroadcastProperty(this GameObject go, CustomProperty property
}
else
{
objValue = property.GetValueAsString();
objValue = property.m_JObject.ToString();
}

// Use properties on all types in hierary that inherit from MonoBehaviour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public static Vector2[] GetAttributeAsVector2Array(this XElement element, string
}

var vectors = from v in data.Split(' ')
let a = v.Split(',').ToArray()
let x = Convert.ToSingle(a[0], CultureInfo.InvariantCulture)
let y = Convert.ToSingle(a[1], CultureInfo.InvariantCulture)
select new Vector2(x, y);
let a = v.Split(',').ToArray()
let x = Convert.ToSingle(a[0], CultureInfo.InvariantCulture)
let y = Convert.ToSingle(a[1], CultureInfo.InvariantCulture)
select new Vector2(x, y);
return vectors.ToArray();
}

Expand Down Expand Up @@ -76,22 +76,24 @@ public static T GetAttributeAs<T>(this XElement element, string name, T defaultV
}
}

return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
return (T) Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
}

public static T GetAttributeAs<T>(this XElement element, string name) where T : IConvertible
{
return element.GetAttributeAs<T>(name, default(T));
}

public static T GetPropertyAttributeAs<T>(this XElement element, string name, T defaultValue) where T : IConvertible
public static T GetPropertyAttributeAs<T>(this XElement element, string name, T defaultValue)
where T : IConvertible
{
var xProperties = element.Element("properties");
if (xProperties != null)
{
foreach (var xProperty in xProperties.Elements("property"))
{
if (string.Equals(xProperty.GetAttributeAs<string>("name"), name, StringComparison.OrdinalIgnoreCase))
if (string.Equals(xProperty.GetAttributeAs<string>("name"), name,
StringComparison.OrdinalIgnoreCase))
{
return xProperty.GetAttributeAs<T>("value", defaultValue);
}
Expand Down Expand Up @@ -134,16 +136,22 @@ public static void CombineWithTemplate(this XElement xObject, string template)
// Combine the properties from source and template
var properties = new Dictionary<string, XElement>();

// Collect the properties from the template first, by named key
foreach (var prop in xTemplate.Descendants("property"))
if (xTemplate.Element("properties") is { } propertiesTemplate)
{
properties.Add(prop.GetAttributeAs<string>("name"), prop);
// Collect the properties from the template first, by named key
foreach (var prop in propertiesTemplate.Elements("property"))
{
properties.Add(prop.GetAttributeAs<string>("name"), prop);
}
}

// Collect the properties on the source, overriding by named key
foreach (var prop in xObject.Descendants("property"))
if (xObject.Element("properties") is { } propertiesElem)
{
properties[prop.GetAttributeAs<string>("name")] = prop;
// Collect the properties on the source, overriding by named key
foreach (var prop in propertiesElem.Elements("property"))
{
properties[prop.GetAttributeAs<string>("name")] = prop;
}
}

// Put the combined properties into the object
Expand All @@ -161,4 +169,4 @@ public static void CombineWithTemplate(this XElement xObject, string template)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void AddSuperCustomProperties(GameObject go, XElement xProperties, SuperT
{
// Load our "local" properties first
var component = go.AddComponent<SuperCustomProperties>();
var properties = CustomPropertyLoader.LoadCustomPropertyList(xProperties);
var properties = CustomPropertyLoader.LoadCustomPropertyListWithExpansion(xProperties, SuperImportContext);

// Do we have any properties from a tile to add?
if (tile != null)
Expand All @@ -55,7 +55,7 @@ public void AddSuperCustomProperties(GameObject go, XElement xProperties, SuperT
}

// Add properties from our object type (this should be last)
properties.AddPropertiesFromType(typeName, SuperImportContext);
// properties.AddPropertiesFromType(typeName, SuperImportContext);

// Sort the properties alphabetically
component.m_Properties = properties.OrderBy(p => p.m_Name).ToList();
Expand Down Expand Up @@ -140,7 +140,7 @@ protected void AssignUnityTag(SuperCustomProperties properties)
CustomProperty prop;
if (properties.TryGetCustomProperty(StringConstants.Unity_Tag, out prop))
{
string tag = prop.m_Value;
string tag = prop.GetValueAsString();
CheckTagName(tag);
properties.gameObject.tag = tag;
}
Expand All @@ -152,7 +152,7 @@ protected void AssignUnityLayer(SuperCustomProperties properties)
CustomProperty prop;
if (properties.TryGetCustomProperty(StringConstants.Unity_Layer, out prop))
{
string layer = prop.m_Value;
string layer = prop.GetValueAsString();
if (!UnityEditorInternal.InternalEditorUtility.layers.Contains(layer))
{
string report = string.Format("Layer '{0}' is not defined in the Tags and Layers settings.", layer);
Expand Down
Loading