public MultiTileGridLayer(LevelX.MultiTileGridLayerX proxy, Level level, Dictionary<int, Guid> tileIndex) : base(proxy.Name, proxy.TileWidth, proxy.TileHeight, level) { _tiles = new TileStack[TilesHigh, TilesWide]; Opacity = proxy.Opacity; IsVisible = proxy.Visible; RasterMode = proxy.RasterMode; Level = level; foreach (var blockProxy in proxy.Blocks) ParseTileBlockString(blockProxy.Data); if (proxy.Properties != null) { foreach (var propertyProxy in proxy.Properties) CustomProperties.Add(Property.FromXmlProxy(propertyProxy)); } }
public ObjectLayer(LevelX.ObjectLayerX proxy, Level level) : this(proxy.Name, level) { Opacity = proxy.Opacity; IsVisible = proxy.Visible; RasterMode = proxy.RasterMode; GridColor = Color.ParseArgbHex(proxy.GridColor); GridWidth = proxy.GridWidth; GridHeight = proxy.GridHeight; Level = level; IResourceCollection<ObjectPool> pools = Level.Project.ObjectPoolManager.Pools; foreach (var objProxy in proxy.Objects) { ObjectInstance inst = ObjectInstance.FromXProxy(objProxy, Level.Project.ObjectPoolManager); if (inst != null) AddObject(inst); } if (proxy.Properties != null) { foreach (var propertyProxy in proxy.Properties) PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy)); } }
private ObjectInstance(LevelX.ObjectInstanceX proxy, ObjectClass objClass) : this(objClass, proxy.X, proxy.Y) { _uid = proxy.Uid; _rotation = MathEx.DegToRad(proxy.Rotation); if (proxy.Properties != null) { foreach (var propertyProxy in proxy.Properties) PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy)); } UpdateBounds(); }
public static ObjectInstance FromXProxy(LevelX.ObjectInstanceX proxy, IObjectPoolManager manager) { if (proxy == null) return null; ObjectPool pool = manager.PoolFromItemKey(proxy.Class); if (pool == null) return null; ObjectClass objClass = pool.Objects[proxy.Class]; if (objClass == null) return null; return new ObjectInstance(proxy, objClass); }
private void Initialize (LevelX proxy, Project project) { if (proxy.PropertyGroup != null) { Extra = proxy.PropertyGroup.Extra; } _project = project; _x = proxy.OriginX; _y = proxy.OriginY; _width = Math.Max(1, proxy.Width); _height = Math.Max(1, proxy.Height); _indexSequence = proxy.TileIndex.Sequence; Dictionary<int, Guid> tileIndex = new Dictionary<int, Guid>(); foreach (var entry in proxy.TileIndex.Entries) { _localTileIndex.Add(entry.Id, entry.Uid); tileIndex.Add(entry.Id, entry.Uid); if (entry.Id >= _indexSequence) _indexSequence = entry.Id + 1; } foreach (LevelX.LayerX layerProxy in proxy.Layers) { if (layerProxy is LevelX.MultiTileGridLayerX) Layers.Add(new MultiTileGridLayer(layerProxy as LevelX.MultiTileGridLayerX, this, tileIndex)); else if (layerProxy is LevelX.ObjectLayerX) Layers.Add(new ObjectLayer(layerProxy as LevelX.ObjectLayerX, this)); } foreach (var propertyProxy in proxy.Properties) CustomProperties.Add(Property.FromXmlProxy(propertyProxy)); }
public static Level FromXProxy (LevelX proxy, Project project) { if (proxy == null) return null; Guid uid = proxy.PropertyGroup != null ? proxy.PropertyGroup.LevelGuid : Guid.NewGuid(); Level level = new Level(uid, proxy.Name); level.Initialize(proxy, project); return level; }