public virtual void SaveToXML(XmlElement objSystem) { var xeStar = objSystem.OwnerDocument.CreateElement("Star"); objSystem.AppendChild(xeStar); Common.CreateTextNode(xeStar, "Type", StarType.ToString()); Common.CreateTextNode(xeStar, "LumClass", LumClass.ToString()); Common.CreateTextNode(xeStar, "DecClass", DecClass.ToString()); Common.CreateTextNode(xeStar, "StellarMass", StellarMass.ToString()); Common.CreateTextNode(xeStar, "Luminosity", Luminosity.ToString()); Common.CreateTextNode(xeStar, "NumOrbits", NumOrbits.ToString()); Common.CreateTextNode(xeStar, "HZone", HZone.ToString()); Common.CreateTextNode(xeStar, "TypeRoll", TypeRoll.ToString()); Common.CreateTextNode(xeStar, "ClassRoll", ClassRoll.ToString()); Common.CreateTextNode(xeStar, "NumCompanions", NumCompanions.ToString()); Common.CreateTextNode(xeStar, "Name", Name.ToString()); foreach (var orbit in Orbits) { orbit.SaveToXML(xeStar); } var xeStars = objSystem.OwnerDocument.CreateElement("Companions"); xeStar.AppendChild(xeStars); foreach (var companion in Companions) { companion.SaveToXML(xeStars); } }
// // Use this for initialization // void Awake () { // // } // // // Update is called once per frame // void Update () { // // } public string dumpSystem() { string s = "Star name: " + name + " Star Class: " + starClass.ToString() + " Planets: " + planets.Count + "\n"; for (int i = 0; i < planets.Count; i++) { if (planets [i].isFarmable) { s = string.Concat(s, "Planet " + (i + 1) + " is Farmable\n"); } else if (planets [i].isInhabited) { s = string.Concat(s, "Planet " + (i + 1) + " is Inhabited\n"); } else if (planets [i].isTerraformable) { s = string.Concat(s, "Planet " + (i + 1) + " is Terraformable\n"); } else { s = string.Concat(s, "Planet " + (i + 1) + " is a dud\n"); } if (planets[i].ownedByPlayer) { s = string.Concat(s, "This planet is owned by the player\n"); } } return(s); }
public override void SaveToXML(XmlElement objStar) { var xeStar = objStar.OwnerDocument.CreateElement("Star"); objStar.AppendChild(xeStar); // Companion specific attributes Common.CreateTextNode(xeStar, "OrbitNum", OrbitNum.ToString()); Common.CreateTextNode(xeStar, "Range", Range.ToString()); Common.CreateTextNode(xeStar, "SysNat", SysNat.ToString()); // Common attributes Common.CreateTextNode(xeStar, "Type", StarType.ToString()); Common.CreateTextNode(xeStar, "LumClass", LumClass.ToString()); Common.CreateTextNode(xeStar, "DecClass", DecClass.ToString()); Common.CreateTextNode(xeStar, "StellarMass", StellarMass.ToString()); Common.CreateTextNode(xeStar, "Luminosity", Luminosity.ToString()); Common.CreateTextNode(xeStar, "NumOrbits", NumOrbits.ToString()); Common.CreateTextNode(xeStar, "HZone", HZone.ToString()); Common.CreateTextNode(xeStar, "TypeRoll", TypeRoll.ToString()); Common.CreateTextNode(xeStar, "ClassRoll", ClassRoll.ToString()); Common.CreateTextNode(xeStar, "NumCompanions", NumCompanions.ToString()); Common.CreateTextNode(xeStar, "Name", Name.ToString()); foreach (var orbit in Orbits) { orbit.SaveToXML(xeStar); } var xeStars = objStar.OwnerDocument.CreateElement("Companions"); xeStar.AppendChild(xeStars); foreach (var companion in Companions) { companion.SaveToXML(xeStars); } }
/// <summary> /// 经过类型装饰 /// </summary> /// <param name="type"></param> /// <returns></returns> public NPCStar GetNPCStarFromType(StarType type) { NPCStar e = NPCStarPool.GetObject(); e.SpriteRenderer.sprite = GetSpriteMapping(GameConfig.Instance.GetComnmonStarMapping(type.ToString())); e.Type = type; e.Used(); return(e); }
public Star Star_Create(Int32 Galaxy_Id, String name, Decimal radius, Decimal galactic_radius, Decimal speed, StarType type, Decimal diameter, Int32 size, Decimal mass) { Star s = new Star(); using (var cmd = GetCommand()) { cmd.CommandText = "[dbo].[Star_Create]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Galaxy_Id", Galaxy_Id); cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@radius", radius); cmd.Parameters.AddWithValue("@galactic_radius", galactic_radius); cmd.Parameters.AddWithValue("@speed", speed); cmd.Parameters.AddWithValue("@type", type.ToString()); cmd.Parameters.AddWithValue("@diameter", diameter); cmd.Parameters.AddWithValue("@size", size); cmd.Parameters.AddWithValue("@mass", mass); Int32 id = 0; SqlParameter param = new SqlParameter("@id", id); param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); cmd.ExecuteNonQuery(); id = Convert.ToInt32(param.Value); return Star_SelectById(id); } return s; }