bool ParseContentXMLFile(string path)
    {
        bool     runningResult = true;
        XElement doc           = XElement.Load(path, LoadOptions.SetBaseUri);

        while (doc != null)
        {
            switch (doc.Name.LocalName)
            {
            case "colors":
                if (ColorConfiguration == null)
                {
                    ColorConfiguration = ContentConfiguration <ColorContent> .GetFromRootElement(doc, "color");
                }
                ColorConfiguration.AddSingleContentConfig(doc);
                break;

            case "materialTextures":
                if (MaterialTextureConfiguration == null)
                {
                    MaterialTextureConfiguration = ContentConfiguration <TextureContent> .GetFromRootElement(doc, "materialTexture");
                }
                MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage);
                break;

            case "shapeTextures":
                if (ShapeTextureConfiguration == null)
                {
                    ShapeTextureConfiguration = ContentConfiguration <NormalContent> .GetFromRootElement(doc, "shapeTexture");
                }
                ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage);
                break;

            case "tileMeshes":
                if (TileMeshConfiguration == null)
                {
                    TileMeshConfiguration = ContentConfiguration <MeshContent> .GetFromRootElement(doc, "tileMesh");
                }
                TileMeshConfiguration.AddSingleContentConfig(doc);
                break;

            case "materialLayers":
                if (MaterialLayerConfiguration == null)
                {
                    MaterialLayerConfiguration = ContentConfiguration <LayerContent> .GetFromRootElement(doc, "materialLayer");
                }
                MaterialLayerConfiguration.AddSingleContentConfig(doc);
                break;

            default:
                break;
            }
            doc = doc.NextNode as XElement;
        }
        return(runningResult);
    }
Beispiel #2
0
    IEnumerator ParseContentXMLFile(string path)
    {
        Debug.Log("Loading XML File: " + path);
        XElement doc = XElement.Load(path, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo);

        while (doc != null)
        {
            switch (doc.Name.LocalName)
            {
            case "colors":
                if (ColorConfiguration == null)
                {
                    ColorConfiguration = TileConfiguration <ColorContent> .GetFromRootElement(doc, "color");
                }
                ColorConfiguration.AddSingleContentConfig(doc, null, MaterialColors);
                break;

            case "materialTextures":
                if (MaterialTextureConfiguration == null)
                {
                    MaterialTextureConfiguration = TileConfiguration <TextureContent> .GetFromRootElement(doc, "materialTexture");
                }
                MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage, MaterialTextures);
                break;

            case "shapeTextures":
                if (ShapeTextureConfiguration == null)
                {
                    ShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "shapeTexture");
                }
                ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage);
                break;

            case "terrainTextures":
                if (TerrainShapeTextureConfiguration == null)
                {
                    TerrainShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "terrainTexture");
                }
                TerrainShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage);
                break;

            case "tileMeshes":
                if (TileMeshConfiguration == null)
                {
                    TileMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "tileMesh");
                }
                TileMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "materialLayers":
                if (MaterialLayerConfiguration == null)
                {
                    MaterialLayerConfiguration = TileConfiguration <LayerContent> .GetFromRootElement(doc, "materialLayer");
                }
                MaterialLayerConfiguration.AddSingleContentConfig(doc);
                break;

            //case "buildingMeshes":
            //    if (BuildingMeshConfiguration == null)
            //        BuildingMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "buildingMesh");
            //    BuildingMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
            //    break;
            //case "buildingShapeTextures":
            //    if (BuildingShapeTextureConfiguration == null)
            //        BuildingShapeTextureConfiguration = TileConfiguration<NormalContent>.GetFromRootElement(doc, "buildingShapeTexture");
            //    BuildingShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage);
            //    break;
            case "growthMeshes":
                if (GrowthMeshConfiguration == null)
                {
                    GrowthMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "growthMesh");
                }
                GrowthMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "designationMeshes":
                if (DesignationMeshConfiguration == null)
                {
                    DesignationMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "designationMesh");
                }
                DesignationMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "collisionMeshes":
                if (CollisionMeshConfiguration == null)
                {
                    CollisionMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "collisionMesh");
                }
                CollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            //case "buildingCollisionMeshes":
            //    if (BuildingCollisionMeshConfiguration == null)
            //        BuildingCollisionMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "buildingCollisionMesh");
            //    BuildingCollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
            //    break;
            case "itemMeshes":
                if (ItemMeshConfiguration == null)
                {
                    ItemMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "itemMesh");
                }
                ItemMeshConfiguration.AddSingleContentConfig(doc, null);
                break;

            case "grassTextures":
                if (GrassTextureConfiguration == null)
                {
                    GrassTextureConfiguration = TileConfiguration <GrassContent> .GetFromRootElement(doc, "grassTexture");
                }
                GrassTextureConfiguration.AddSingleContentConfig(doc, new GrassContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage));
                break;

            default:
                break;
            }
            doc = doc.NextNode as XElement;
        }
        yield return(null);
    }
Beispiel #3
0
    bool ParseContentXMLFile(string path)
    {
        bool     runningResult = true;
        XElement doc           = XElement.Load(path, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo);

        while (doc != null)
        {
            switch (doc.Name.LocalName)
            {
            case "colors":
                if (ColorConfiguration == null)
                {
                    ColorConfiguration = TileConfiguration <ColorContent> .GetFromRootElement(doc, "color");
                }
                ColorConfiguration.AddSingleContentConfig(doc, null, materialColors);
                break;

            case "materialTextures":
                if (MaterialTextureConfiguration == null)
                {
                    MaterialTextureConfiguration = TileConfiguration <TextureContent> .GetFromRootElement(doc, "materialTexture");
                }
                MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage, materialTextures);
                break;

            case "shapeTextures":
                if (ShapeTextureConfiguration == null)
                {
                    ShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "shapeTexture");
                }
                ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage);
                break;

            case "tileMeshes":
                if (TileMeshConfiguration == null)
                {
                    TileMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "tileMesh");
                }
                TileMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "materialLayers":
                if (MaterialLayerConfiguration == null)
                {
                    MaterialLayerConfiguration = TileConfiguration <LayerContent> .GetFromRootElement(doc, "materialLayer");
                }
                MaterialLayerConfiguration.AddSingleContentConfig(doc);
                break;

            case "buildingMeshes":
                if (BuildingMeshConfiguration == null)
                {
                    BuildingMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "buildingMesh");
                }
                BuildingMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "buildingShapeTextures":
                if (BuildingShapeTextureConfiguration == null)
                {
                    BuildingShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "buildingShapeTexture");
                }
                BuildingShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage);
                break;

            case "creatureMeshes":
                if (CreatureMeshConfiguration == null)
                {
                    CreatureMeshConfiguration = CreatureConfiguration <MeshContent> .GetFromRootElement(doc, "creatureMesh");
                }
                CreatureMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "growthMeshes":
                if (GrowthMeshConfiguration == null)
                {
                    GrowthMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "growthMesh");
                }
                GrowthMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "designationMeshes":
                if (DesignationMeshConfiguration == null)
                {
                    DesignationMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "designationMesh");
                }
                DesignationMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "collisionMeshes":
                if (CollisionMeshConfiguration == null)
                {
                    CollisionMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "collisionMesh");
                }
                CollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            case "buildingCollisionMeshes":
                if (BuildingCollisionMeshConfiguration == null)
                {
                    BuildingCollisionMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "buildingCollisionMesh");
                }
                BuildingCollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage));
                break;

            default:
                break;
            }
            doc = doc.NextNode as XElement;
        }
        return(runningResult);
    }