protected void ParseAssetElement(XmlReader r, string assetType)
        {
            AssetDesc asset = new AssetDesc();

            asset.Type = assetType;

            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "assetName":
                    asset.AssetName = r.Value;
                    break;

                case "name":
                    asset.Name = r.Value;
                    break;

                case "subType":
                    asset.SubType = r.Value;
                    break;
                }
            }
            r.MoveToElement();             //Moves the reader back to the element node.

            assets[asset.Name] = asset;
            //models.Add(model);
            return;
        }
        public AssetDesc assetFromName(string name)
        {
            AssetDesc asset = null;

            foreach (KeyValuePair <String, AssetDesc> kvp in assets)
            {
                asset = kvp.Value;
                if (asset.Name == name)
                {
                    break;
                }
            }
            return(asset);
        }
        // return a list of all assets of the specified type and subtype
        public List <AssetDesc> Select(string type, string subType)
        {
            List <AssetDesc> ret = new List <AssetDesc>();

            foreach (KeyValuePair <String, AssetDesc> kvp in assets)
            {
                AssetDesc asset = kvp.Value;
                if ((asset.Type == type) && (asset.SubType == subType))
                {
                    ret.Add(asset);
                }
            }

            return(ret);
        }
        // return a list of subtypes available for the given type
        public List <String> SubTypes(string type)
        {
            List <String> ret = new List <String>();

            foreach (KeyValuePair <String, AssetDesc> kvp in assets)
            {
                AssetDesc asset = kvp.Value;
                if (asset.Type == type)
                {
                    if ((asset.SubType != null) && (asset.SubType.Length != 0))
                    {
                        if (!ret.Contains(asset.SubType))
                        {
                            ret.Add(asset.SubType);
                        }
                    }
                }
            }

            return(ret);
        }
        // Import asset definitions using the asset repository
        protected void ImportAssetDefinitions()
        {
            Dictionary <string, AssetDefinition> .ValueCollection defs = RepositoryClass.Instance.AssetDefinitions;
            foreach (AssetDefinition def in defs)
            {
                string type    = "";
                string subType = "";
                switch (def.TypeEnum)
                {
                case AssetTypeEnum.Mesh:
                    type = "Model";
                    break;

                case AssetTypeEnum.Sound:
                    type = "Sound";
                    break;

                case AssetTypeEnum.SpeedTree:
                    type = "SpeedTree";
                    break;

                case AssetTypeEnum.ParticleScript:
                    type = "ParticleFX";
                    break;

                case AssetTypeEnum.Material:
                    if (def.Category == "Skybox")
                    {
                        type = "Skybox";
                    }
                    break;

                case AssetTypeEnum.SpeedWind:
                    type = "SpeedWind";
                    break;

                case AssetTypeEnum.PlantType:
                    type = "Vegitation";
                    break;

                case AssetTypeEnum.Movie:
                    type = "Movie";
                    break;

                case AssetTypeEnum.Texture:
                    foreach (AssetProperty prop in def.Properties)
                    {
                        if (String.Equals(prop.Name, "TerrainTexture") && String.Equals(prop.Value.ToLower(), "true"))
                        {
                            subType = "TerrainTexture";
                        }
                        if (String.Equals(prop.Name, "TerrainDecal") && String.Equals(prop.Value.ToLower(), "true"))
                        {
                            subType = "TerrainDecal";
                        }
                    }
                    type = "Texture";
                    break;

                default:
                    break;
                }
                if (type != "")
                {
                    AssetDesc asset = new AssetDesc();
                    asset.Name = (def.Description == "" ? def.Name : def.Description);

                    string assetName = null;

                    // look for asset name property
                    foreach (AssetProperty prop in def.Properties)
                    {
                        if (prop.Name == "AssetName")
                        {
                            assetName = prop.Value;
                            break;
                        }
                    }

                    // if no AssetName property was found, then use the filename
                    if (assetName == null)
                    {
                        assetName = Path.GetFileName(def.Files[0].TargetFile);
                    }

                    asset.AssetName = assetName;
                    asset.Type      = type;
                    if (String.Equals(subType, ""))
                    {
                        asset.SubType = def.Category;
                    }
                    else
                    {
                        asset.SubType = subType;
                    }
                    assets[asset.Name] = asset;
                }
            }
        }
        protected void ParseAssetElement(XmlReader r, string assetType)
        {
            AssetDesc asset = new AssetDesc();
            asset.Type = assetType;

            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch ( r.Name )
                {
                    case "assetName":
                        asset.AssetName = r.Value;
                        break;
                    case "name":
                        asset.Name = r.Value;
                        break;
                    case "subType":
                        asset.SubType = r.Value;
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            assets[asset.Name] = asset;
            //models.Add(model);
            return;
        }
        // Import asset definitions using the asset repository
        protected void ImportAssetDefinitions()
        {
            Dictionary<string, AssetDefinition>.ValueCollection defs = RepositoryClass.Instance.AssetDefinitions;
            foreach (AssetDefinition def in defs) {
                string type = "";
                string subType ="";
                switch (def.TypeEnum) {
                case AssetTypeEnum.Mesh:
                    type = "Model";
                    break;
                case AssetTypeEnum.Sound:
                    type = "Sound";
                    break;
                case AssetTypeEnum.SpeedTree:
                    type = "SpeedTree";
                    break;
                case AssetTypeEnum.ParticleScript:
                    type = "ParticleFX";
                    break;
                case AssetTypeEnum.Material:
                    if (def.Category == "Skybox")
                        type = "Skybox";
                    break;
                case AssetTypeEnum.SpeedWind:
                    type = "SpeedWind";
                    break;
                case AssetTypeEnum.PlantType:
                    type = "Vegitation";
                    break;
                case AssetTypeEnum.Movie:
                    type = "Movie";
                    break;
                case AssetTypeEnum.Texture:
                    foreach (AssetProperty prop in def.Properties)
                    {
                        if (String.Equals(prop.Name, "TerrainTexture") && String.Equals(prop.Value.ToLower(), "true"))
                        {
                            subType = "TerrainTexture";
                        }
                        if (String.Equals(prop.Name, "TerrainDecal") && String.Equals(prop.Value.ToLower(), "true"))
                        {
                            subType = "TerrainDecal";
                        }
                    }
                    type = "Texture";
                    break;
                default:
                    break;
                }
                if (type != "") {
                    AssetDesc asset = new AssetDesc();
                    asset.Name = (def.Description == "" ? def.Name : def.Description);

                    string assetName = null;

                    // look for asset name property
                    foreach (AssetProperty prop in def.Properties)
                    {
                        if (prop.Name == "AssetName")
                        {
                            assetName = prop.Value;
                            break;
                        }
                    }

                    // if no AssetName property was found, then use the filename
                    if (assetName == null)
                    {
                        assetName = Path.GetFileName(def.Files[0].TargetFile);
                    }

                    asset.AssetName = assetName;
                    asset.Type = type;
                    if (String.Equals(subType, ""))
                    {
                        asset.SubType = def.Category;
                    }
                    else
                    {
                        asset.SubType = subType;
                    }
                    assets[asset.Name] = asset;
                }
            }
        }