Ejemplo n.º 1
0
        public override void Save()
        {
            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("particleemitter");

            doc.AppendChild(root);

            root.AppendChild(doc.CreateElement("material").SimpleTag("name", Material));
            root.AppendChild(doc.CreateElement("numparticles").SimpleTag("value", NumParticles.ToString()));
            root.AppendChild(doc.CreateElement("updateinvisible").SimpleTag("enable", UpdateInvisible ? "true" : "false"));
            root.AppendChild(doc.CreateElement("relative").SimpleTag("enable", Relative ? "true" : "false"));
            root.AppendChild(doc.CreateElement("scaled").SimpleTag("enable", Scaled ? "true" : "false"));
            root.AppendChild(doc.CreateElement("sorted").SimpleTag("enable", Sorted ? "true" : "false"));
            root.AppendChild(doc.CreateElement("animlodbias").SimpleTag("value", AnimLodBias.ToString()));
            root.AppendChild(doc.CreateElement("emittertype").ValueTag(Type.ToString().ToLower()));
            if (EmitterSize != null)
            {
                root.AppendChild(doc.CreateElement("emittersize").ValueTag(EmitterSize.ToString()));
            }
            root.AppendChild(doc.CreateElement("emitterradius").ValueTag(EmitterRadius.ToString()));

            XmlElement dir = doc.CreateElement("direction");

            dir.SetAttribute("min", DirectionMin.ToString());
            dir.SetAttribute("max", DirectionMax.ToString());
            root.AppendChild(dir);

            root.AppendChild(doc.CreateElement("constantforce").ValueTag(ConstantForce.ToString()));
            root.AppendChild(doc.CreateElement("dampingforce").ValueTag(DampingForce.ToString()));
            root.AppendChild(doc.CreateElement("activetime").ValueTag(ActiveTime.ToString()));
            root.AppendChild(doc.CreateElement("inactivetime").ValueTag(InActiveTime.ToString()));
            root.AppendChild(Interval.ToElement(doc.CreateElement("interval")));
            root.AppendChild(EmissionRate.ToElement(doc.CreateElement("emissionrate")));

            XmlElement psize = doc.CreateElement("particlesize");

            psize.SetAttribute("min", MinSize.ToString());
            psize.SetAttribute("max", MaxSize.ToString());
            root.AppendChild(psize);

            root.AppendChild(TimeToLive.ToElement(doc.CreateElement("timetolive")));
            root.AppendChild(Velocity.ToElement(doc.CreateElement("velocity")));
            root.AppendChild(Rotation.ToElement(doc.CreateElement("rotation")));
            root.AppendChild(RotationSpeed.ToElement(doc.CreateElement("rotationspeed")));
            //SIZE DELTA
            XmlElement sized = doc.CreateElement("sizedelta");

            sized.SetAttribute("add", SizeDelta.X.ToString());
            sized.SetAttribute("mul", SizeDelta.Y.ToString());
            root.AppendChild(sized);

            foreach (ParticleColorFade f in ColorFade)
            {
                XmlElement e = doc.CreateElement("colorfade");
                e.SetAttribute("color", f.Color.ToString());
                e.SetAttribute("time", f.Time.ToString());
                root.AppendChild(e);
            }
            foreach (ParticleTexAnim a in TextureAnim)
            {
                XmlElement e = doc.CreateElement("texanim");
                e.SetAttribute("uv", a.Animation.ToString());
                e.SetAttribute("time", a.Time.ToString());
                root.AppendChild(e);
            }

            XmlWriterSettings xws = new XmlWriterSettings {
                OmitXmlDeclaration = true, Indent = true
            };

            using (XmlWriter xw = XmlWriter.Create(System.IO.Path.ChangeExtension(Name, "xml"), xws))
                doc.Save(xw);
        }