コード例 #1
0
        public virtual void SaveToXML(XmlElement objOrbit)
        {
            var nfi = System.Globalization.NumberFormatInfo.InvariantInfo;

            var xePlanet = objOrbit.OwnerDocument.CreateElement("Planet");

            objOrbit.AppendChild(xePlanet);
            Common.CreateTextNode(xePlanet, "Type", PlanetType.ToString());
            Common.CreateTextNode(xePlanet, "Dense", Dense.ToString());
            Common.CreateTextNode(xePlanet, "Mass", Mass.ToString());
            Common.CreateTextNode(xePlanet, "Gravity", Grav.ToString());
            Common.CreateTextNode(xePlanet, "Pressure", Pressure.ToString());
            Common.CreateTextNode(xePlanet, "MaxPop", Maxpop.ToString());
            Common.CreateTextNode(xePlanet, "OrbitRange", OrbitRange.ToString());
            Common.CreateTextNode(xePlanet, "OrbitNumber", OrbitNumber.ToString());
            Common.CreateTextNode(xePlanet, "Tilt", Tilt.ToString());
            Common.CreateTextNode(xePlanet, "Ecc", Ecc.ToString());
            Common.CreateTextNode(xePlanet, "Rotation", Rotation.ToString());
            Common.CreateTextNode(xePlanet, "TidallyLocked", TidallyLocked.ToString());
            Common.CreateTextNode(xePlanet, "Temp", Temp.ToString());
            Common.CreateTextNode(xePlanet, "Diameter", Diameter.ToString());
            Common.CreateTextNode(xePlanet, "NumSats", Satellites.Count.ToString());
            Common.CreateTextNode(xePlanet, "Mainworld", MainWorld.ToString());
            Common.CreateTextNode(xePlanet, "NormalUWP", Normal.DisplayString(PlanetType, Diameter));
            Common.CreateTextNode(xePlanet, "CollapseUWP", Collapse.DisplayString(PlanetType, Diameter));
            Common.CreateTextNode(xePlanet, "Life", Life.ToString());
            Common.CreateTextNode(xePlanet, "LifeFactor", LifeFactor.ToString());
            Common.CreateTextNode(xePlanet, "Name", Name);

            var xeChild = objOrbit.OwnerDocument.CreateElement("Temperature");

            for (var i = 0; i < (Constants.NUM_HEX_ROWS * 2) - 1; i += 2)
            {
                var xeTemp = objOrbit.OwnerDocument.CreateElement("Row" + (i / 2 + 1).ToString());

                Common.CreateTextNode(xeTemp, "Summer", Summer[i].ToString("N", nfi) + "/" + Summer[i + 1].ToString("N", nfi));
                Common.CreateTextNode(xeTemp, "Fall", Fall[i].ToString("N", nfi) + "/" + Fall[i + 1].ToString("N", nfi));
                Common.CreateTextNode(xeTemp, "Winter", Winter[i].ToString("N", nfi) + "/" + Winter[i + 1].ToString("N", nfi));

                xeChild.AppendChild(xeTemp);
            }

            xePlanet.AppendChild(xeChild);

            if (Life)
            {
                xeChild = objOrbit.OwnerDocument.CreateElement("AnimalEncounters");
                TableGenerator.WriteToXML(xeChild);
                xePlanet.AppendChild(xeChild);
            }

            Normal.SaveToXML(xePlanet);
            Collapse.SaveToXML(xePlanet);

            foreach (var satellite in Satellites)
            {
                satellite.SaveToXML(xePlanet);
            }
        }
コード例 #2
0
        public override void SaveToXML(XmlElement objOrbit)
        {
            var xePlanet = objOrbit.OwnerDocument.CreateElement("Satellite");

            objOrbit.AppendChild(xePlanet);
            Common.CreateTextNode(xePlanet, "OrbitNumber", OrbitNumber.ToString());
            base.SaveToXML(xePlanet);
        }