public static XmlElement city(XmlDocument doc, City c) { XmlElement e = doc.CreateElement("City"); e.SetAttribute("name", c.Name); e.SetAttribute("owner", c.Owner); e.SetAttribute("side", c.Side.ToString()); e.SetAttribute("factor", c.EnnemyFactor.ToString()); return e; }
public void set(int x, int y, City c) { cmap[x, y] = c; }
public void load(String path) { if (!VersionSys.match(path, vi)) throw new Exception("File is not a Forgotten Schism Citymap file v1.0"); FileStream fin = new FileStream(path, FileMode.Open); fin.Seek(12, SeekOrigin.Begin); String[] ownls = Gen.rstra(fin); int w=fin.ReadByte(); int h=fin.ReadByte(); cmap=new City[w, h]; int x; int y; String n; int on; int s; int f; while(fin.Position<fin.Length-1) { x = fin.ReadByte(); y = fin.ReadByte(); n = Gen.rstr(fin); on = fin.ReadByte(); s = fin.ReadByte(); f = fin.ReadByte(); if(on==0) cmap[x, y] = new City(n, (City.CitySide)s, "", f); else cmap[x, y] = new City(n, (City.CitySide)s, ownls[on - 1], f); } fin.Close(); }
private bool contains(List<City> cls, City fc) { foreach (City c in cls) if (c != null && c.Name == fc.Name) return true; return false; }
public static City city(XmlElement e) { City c = new City(e.GetAttribute("name")); c.Owner = e.GetAttribute("owner"); c.Side = (City.CitySide)Enum.Parse(typeof(City.CitySide), e.GetAttribute("side")); c.EnnemyFactor = int.Parse(e.GetAttribute("factor")); return c; }