Exemple #1
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);
    }
    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);
    }
Exemple #3
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 "shapeTextures":
                if (ShapeTextureConfiguration == null)
                {
                    ShapeTextureConfiguration = TileConfiguration <NormalContent> .GetFromRootElement(doc, "shapeTexture");
                }
                yield return(StartCoroutine(ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage)));

                break;

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

            case "itemMeshes":
                if (ItemMeshConfiguration == null)
                {
                    ItemMeshConfiguration = TileConfiguration <MeshContent> .GetFromRootElement(doc, "itemMesh");
                }
                yield return(StartCoroutine(ItemMeshConfiguration.AddSingleContentConfig(doc, null)));

                break;

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