Ejemplo n.º 1
0
        public override void Deserialize(XElement element)
        {
            Color color = new Color();

            if (element.Element("filledColor") != null)
            {
                color = color.ConvertColorFromString(element.Element("filledColor").Value);
            }

            Offset = Offset.DeserializeOffset(element.Element("offset"));

            //Retrieve the asset elements
            List <XElement> elements = element.Elements("renderable").ToList();

            RenderableFactory factory = (RenderableFactory)GameServiceManager.GetService(typeof(RenderableFactory));

            for (int i = 0; i < elements.Count; i++)
            {
                if (elements[i].Attribute("name") != null)
                {
                    //Loading the bar element...
                    if (elements[i].Attribute("name").Value.Equals("bar", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Bar        = (ITexturedRenderable)factory.GenerateRenderable(elements[i], this);
                        Bar.Parent = this;
                        Bar.Offset = Offset;
                    }
                    else if (elements[i].Attribute("name").Value.Equals("border",
                                                                        StringComparison.InvariantCultureIgnoreCase))
                    {
                        Border        = (ITexturedRenderable)factory.GenerateRenderable(elements[i], this);
                        Border.Parent = this;
                        Border.Offset = Offset;
                    }
                }
            }

            FilledColor  = color;
            this.Visible = true;
        }