예제 #1
0
        private SuperLayer ProcessTileLayer(GameObject goParent, XElement xLayer)
        {
            Assert.IsNotNull(xLayer);
            Assert.IsNotNull(goParent);

            // Create the game object that contains the layer and add it to the grid parent
            var layerComponent = goParent.AddSuperLayerGameObject <SuperTileLayer>(new SuperTileLayerLoader(xLayer), SuperImportContext);

            AddSuperCustomProperties(layerComponent.gameObject, xLayer.Element("properties"));
            RendererSorter.BeginTileLayer(layerComponent);

            using (SuperImportContext.BeginIsTriggerOverride(layerComponent.gameObject))
            {
                // Process the data for the layer
                var xData = xLayer.Element("data");
                if (xData != null)
                {
                    ProcessLayerData(layerComponent.gameObject, xData);
                }
            }

            RendererSorter.EndTileLayer(layerComponent);

            return(layerComponent);
        }
예제 #2
0
        private void ProcessMap(XElement xMap)
        {
            Assert.IsNotNull(xMap);
            Assert.IsNull(m_MapComponent);
            Assert.IsNull(m_GlobalTileDatabase);

            m_TilePolygonDatabase      = new Dictionary <uint, TilePolygonCollection>();
            RendererSorter.SortingMode = m_SortingMode;

            // Create our map and fill it out
            bool success = true;

            success = success && PrepareMainObject();
            success = success && ProcessMapAttributes(xMap);
            success = success && ProcessGridObject(xMap);
            success = success && ProcessTilesetElements(xMap);

            if (success)
            {
                // Custom properties need to be in place before we process the map layers
                AddSuperCustomProperties(m_MapComponent.gameObject, xMap.Element("properties"));

                using (SuperImportContext.BeginIsTriggerOverride(m_MapComponent.gameObject))
                {
                    // Add layers to our grid object
                    ProcessMapLayers(m_GridComponent.gameObject, xMap);
                    PostProccessMapLayers(m_GridComponent.gameObject);
                }
            }
        }
        private SuperLayer ProcessObjectLayer(GameObject goParent, XElement xObjectLayer)
        {
            // Have our super object layer loader take care of things
            var loader = new SuperObjectLayerLoader(xObjectLayer);

            loader.AnimationFramerate = SuperImportContext.Settings.AnimationFramerate;
            loader.ColliderFactory    = CreateColliderFactory();
            loader.SuperMap           = m_MapComponent;
            loader.Importer           = this;
            loader.GlobalTileDatabase = m_GlobalTileDatabase;

            // Create our layer and objects
            var objectLayer = goParent.AddSuperLayerGameObject <SuperObjectLayer>(loader, SuperImportContext);

            AddSuperCustomProperties(objectLayer.gameObject, xObjectLayer.Element("properties"));

            RendererSorter.BeginObjectLayer(objectLayer);

            using (SuperImportContext.BeginIsTriggerOverride(objectLayer.gameObject))
            {
                loader.CreateObjects();
            }

            RendererSorter.EndObjectLayer(objectLayer);

            return(objectLayer);
        }
        private SuperLayer ProcessGroupLayer(GameObject goParent, XElement xGroup)
        {
            var groupLayerComponent = goParent.AddSuperLayerGameObject<SuperGroupLayer>(new SuperGroupLayerLoader(xGroup), SuperImportContext);
            AddSuperCustomProperties(groupLayerComponent.gameObject, xGroup.Element("properties"));

            // Group layers can contain other layers
            RendererSorter.BeginGroupLayer(groupLayerComponent);

            using (SuperImportContext.BeginIsTriggerOverride(groupLayerComponent.gameObject))
            {
                ProcessMapLayers(groupLayerComponent.gameObject, xGroup);
            }

            RendererSorter.EndGroupLayer();

            return groupLayerComponent;
        }