Ejemplo n.º 1
0
        public void prase_resources_file(string file)
        {
            default_path_ = AppDomain.CurrentDomain.BaseDirectory + file.Trim();
            res_group_map_.Clear();
            loaded_groups_.Clear();

            imageset_map_.Clear();
            animation_map_.Clear();

            XDocument xmlDocument = XDocument.Load(default_path_);
            var       resources   = xmlDocument.Descendants("Resources");

            foreach (XElement resource in resources)
            {
                string resourceName = (string)resource.Attribute("Name");

                List <Base_Res> group = new List <Base_Res>();

                foreach (XElement image in resource.Descendants("Imageset"))
                {
                    Imageset_Res imageRes = new Imageset_Res();
                    get_attribute(imageRes, image);
                    group.Add(imageRes);
                }

                foreach (XElement sound in resource.Descendants("Sound"))
                {
                    Sound_Res soundRes = new Sound_Res();
                    get_attribute(soundRes, sound);
                    group.Add(soundRes);
                }

                foreach (XElement music in resource.Descendants("Music"))
                {
                    Music_Res musicRes = new Music_Res();
                    get_attribute(musicRes, music);
                    group.Add(musicRes);
                }

                foreach (XElement animation in resource.Descendants("Animation"))
                {
                    Animation_Res animationRes = new Animation_Res();
                    get_attribute(animationRes, animation);
                    group.Add(animationRes);
                }

                res_group_map_.Add(resourceName, group);
            }
        }
Ejemplo n.º 2
0
        public bool load_next_resource()
        {
            try
            {
                if (loaded_groups_.Contains(cur_res_group_) == true)
                {
                    return(false);
                }

                Base_Res baseRes = cur_res_group_listor_.Current;

                if (baseRes == null)
                {
                    return(false);
                }

                if (baseRes is Imageset_Res)
                {
                    Imageset_Res imageRes = (Imageset_Res)baseRes;

                    if (Root.instance().imageset_manager().load_imageset(imageRes) == true)
                    {
                        imageset_map_.Add(imageRes.name_, imageRes);
                    }
                }
                else if (baseRes is Animation_Res)
                {
                    Animation_Res aniRes = (Animation_Res)baseRes;

                    if (Root.instance().animation_manager().load_animation(aniRes) == true)
                    {
                        animation_map_.Add(aniRes.name_, aniRes);
                    }
                }
                else if (baseRes is Sound_Res)
                {
                    Sound_Res soundRes = (Sound_Res)baseRes;

                    if (Root.instance().sound_manager().load_sound(soundRes.name_, soundRes.path_, true) == true)
                    {
                        sound_map_.Add(soundRes.name_, soundRes);
                    }
                }
                else if (baseRes is Music_Res)
                {
                    Music_Res musicRes = (Music_Res)baseRes;

                    if (Root.instance().music_manager().load_sound(musicRes.name_, musicRes.path_, false) == true)
                    {
                        music_map_.Add(musicRes.name_, musicRes);
                    }
                }

                cur_res_group_listor_.MoveNext();

                if (cur_res_group_listor_.Current == null)
                {
                    if (this.loaded_groups_.Contains(this.cur_res_group_) == false)
                    {
                        this.loaded_groups_.Add(this.cur_res_group_);
                    }
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }