public XmlStaticSpriteElement(StaticSpriteElement staticSpriteElement)
 {
     if (staticSpriteElement != null) {
         Instance = new XmlStaticSpriteInstance(staticSpriteElement.Instance);
         Sprites = new XmlSpriteListElement(staticSpriteElement.Sprites);
     }
 }
 public XmlCounterElement(CounterElement counterElement)
 {
     if (counterElement != null) {
         Instance = new XmlCounterInstance(counterElement.Instance);
         Sprites = new XmlSpriteListElement(counterElement.Sprites);
     }
 }
 public XmlAnimatedSpriteElement(AnimatedSpriteElement animatedSpriteElement)
 {
     if (animatedSpriteElement != null) {
         Instance = new XmlAnimatedSpriteInstance(animatedSpriteElement.Instance);
         Sprites = new XmlSpriteListElement(animatedSpriteElement.Sprites);
         Animation = new XmlAnimationElement(animatedSpriteElement.Animation);
     }
 }
        public XmlDirectionalAnimatedSpriteElement(DirectionalAnimatedSpriteElement spriteElement)
        {
            if (spriteElement != null) {
                Instance = new XmlDirectionalAnimatedSpriteInstance(spriteElement.Instance);
                Sprites = new XmlSpriteListElement(spriteElement.Sprites);

                foreach (IDirectionElement directionElement in spriteElement.Directions) {
                    Directions.Add(new XmlDirectionElement(directionElement));
                }
            }
        }
        public XmlDirectionalAnimationSetElement(DirectionalAnimationSetElement spriteElement)
        {
            if (spriteElement != null) {
                Instance = new XmlDirectionalAnimationSetInstance(spriteElement.Instance);
                Sprites = new XmlSpriteListElement(spriteElement.Sprites);

                foreach (IAnimationSetElement animationElement in spriteElement.AnimationSets) {
                    AnimationSets.Add(new XmlAnimationSetElement(animationElement));
                }

                ActivityMap = new XmlActivityMapElement(spriteElement.ActivityMap);
            }
        }
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) {
                reader.ReadStartElement();
                return;
            }

            reader.ReadStartElement();
            while (!reader.EOF) {
                if (reader.IsStartElement()) {
                    switch (reader.Name) {
                        case "Instance":
                            XmlDirectionalAnimationSetInstance instance = new XmlDirectionalAnimationSetInstance();
                            instance.ReadXml(reader);
                            Instance = instance;
                            break;

                        case "Sprites":
                            XmlSpriteListElement sprites = new XmlSpriteListElement();
                            sprites.ReadXml(reader);
                            Sprites = sprites;
                            break;

                        case "AnimationSets":
                            ReadAnimationSetsXml(reader);
                            break;

                        case "ActivityMap":
                            XmlActivityMapElement activityMap = new XmlActivityMapElement();
                            activityMap.ReadXml(reader);
                            ActivityMap = activityMap;
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement) {
                    reader.ReadEndElement();
                    break;
                }
                else
                    reader.Read();
            }
        }
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) {
                reader.ReadStartElement();
                return;
            }

            reader.ReadStartElement();
            while (!reader.EOF) {
                if (reader.IsStartElement()) {
                    switch (reader.Name) {
                        case "Instance":
                            XmlAnimatedSpriteInstance instance = new XmlAnimatedSpriteInstance();
                            instance.ReadXml(reader);
                            Instance = instance;
                            break;

                        case "Sprites":
                            XmlSpriteListElement sprites = new XmlSpriteListElement();
                            sprites.ReadXml(reader);
                            Sprites = sprites;
                            break;

                        case "Animation":
                            XmlAnimationElement animation = new XmlAnimationElement();
                            animation.ReadXml(reader);
                            Animation = animation;
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement) {
                    reader.ReadEndElement();
                    break;
                }
                else
                    reader.Read();
            }
        }
        public void WriteXml(XmlWriter writer)
        {
            if (Instance != null) {
                XmlStaticSpriteInstance elem = Instance as XmlStaticSpriteInstance;
                if (elem == null)
                    elem = new XmlStaticSpriteInstance(Instance);

                writer.WriteStartElement("Instance");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (Sprites != null) {
                XmlSpriteListElement elem = Sprites as XmlSpriteListElement;
                if (elem == null)
                    elem = new XmlSpriteListElement(Sprites);

                writer.WriteStartElement("Sprites");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }
        }
        public void WriteXml(XmlWriter writer)
        {
            if (Instance != null) {
                XmlDirectionalAnimationSetInstance elem = Instance as XmlDirectionalAnimationSetInstance;
                if (elem == null)
                    elem = new XmlDirectionalAnimationSetInstance(Instance);

                writer.WriteStartElement("Instance");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (Sprites != null) {
                XmlSpriteListElement elem = Sprites as XmlSpriteListElement;
                if (elem == null)
                    elem = new XmlSpriteListElement(Sprites);

                writer.WriteStartElement("Sprites");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (AnimationSets != null) {
                writer.WriteStartElement("AnimationSets");

                foreach (IAnimationSetElement animationSet in AnimationSets) {
                    XmlAnimationSetElement elem = animationSet as XmlAnimationSetElement;
                    if (elem == null)
                        elem = new XmlAnimationSetElement(animationSet);

                    writer.WriteStartElement("AnimationSet");
                    elem.WriteXml(writer);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }

            if (ActivityMap != null) {
                XmlActivityMapElement elem = ActivityMap as XmlActivityMapElement;
                if (elem == null)
                    elem = new XmlActivityMapElement(ActivityMap);

                writer.WriteStartElement("ActivityMap");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }
        }
        public void WriteXml(XmlWriter writer)
        {
            if (Instance != null) {
                XmlDirectionalAnimatedSpriteInstance elem = Instance as XmlDirectionalAnimatedSpriteInstance;
                if (elem == null)
                    elem = new XmlDirectionalAnimatedSpriteInstance(Instance);

                writer.WriteStartElement("Instance");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (Sprites != null) {
                XmlSpriteListElement elem = Sprites as XmlSpriteListElement;
                if (elem == null)
                    elem = new XmlSpriteListElement(Sprites);

                writer.WriteStartElement("Sprites");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (Directions != null) {
                writer.WriteStartElement("Directions");

                foreach (IDirectionElement direction in Directions) {
                    XmlDirectionElement elem = direction as XmlDirectionElement;
                    if (elem == null)
                        elem = new XmlDirectionElement(direction);

                    writer.WriteStartElement("Direction");
                    elem.WriteXml(writer);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }
        }