public Tilemap(int w, int h, Tilemap ft) { cmap = new CityMap(w, h); map = new Tile[w, h]; fog = new Fog(w, h); name = ft.name; startpos = new Point(ft.startpos.X, ft.startpos.Y); for (int i = 0; i < w; i++) for (int e = 0; e < h; e++) { if (i < ft.NumX && e < ft.NumY) { map[i, e] = ft.get(i, e); fog.set(i, e, ft.Fog.get(i, e)); cmap.set(i, e, ft.CityMap.get(i, e)); } else if (i < w && e < h) { map[i, e] = new Tile(); fog.set(i, e, false); } } }
public CityMap clone() { CityMap ret = new CityMap(NumX, NumY); for (int i = 0; i < cmap.GetLength(0); i++) for (int e = 0; e < cmap.GetLength(1); e++) if(cmap[i, e]!=null) ret.set(i, e, cmap[i, e].clone()); return ret; }
public Tilemap(int w, int h) { cmap = new CityMap(w, h); startpos = new Point(); map=new Tile[w,h]; fog = new Fog(w, h); for(int i=0; i<w; i++) for (int e = 0; e < h; e++) { map[i, e] = new Tile(Tile.TileType.PLAIN); } }
public void load(String path) { name = Path.GetFileNameWithoutExtension(path); if (!VersionSys.match(path, vi)) throw new Exception("File is not a Forgotten Schism Map file v1.0"); FileStream fin = new FileStream(path, FileMode.Open); fin.Seek(12, SeekOrigin.Begin); startpos.X = fin.ReadByte(); startpos.Y = fin.ReadByte(); //map width and height int w = fin.ReadByte(); int h = fin.ReadByte(); map=new Tile[w,h]; fog = new Fog(w, h); if(cmap==null) cmap = new CityMap(w, h); cmap.load(Path.ChangeExtension(path, ".citymap")); //map data int tt; for (int e = 0; e < h ; e++) for (int i = 0; i < w; i++) { tt = fin.ReadByte(); fog.set(i, e, Gen.conv((byte)fin.ReadByte())); map[i, e] = new Tile((Tile.TileType)tt); } fin.Close(); }
public static String[] reflist(String path) { CityMap cmap = new CityMap(1, 1); cmap.load(Path.ChangeExtension(path, ".citymap")); List<String> refls = new List<string>(); foreach (City c in cmap.toArray()) if (c.Name != "" && !refls.Contains(c.Name)) refls.Add(c.Name); return refls.ToArray(); }
public static XmlElement citymap(XmlDocument doc, CityMap cmap, String region) { XmlElement e = doc.CreateElement("CityMap"); e.SetAttribute("region", region); e.SetAttribute("numx", cmap.NumX.ToString()); e.SetAttribute("numy", cmap.NumY.ToString()); XmlElement p; for (int i = 0; i < cmap.NumX; i++) for (int j = 0; j < cmap.NumY; j++) if (cmap.isCity(i, j)) { p = pos(doc, "Pos", new Point(i, j)); p.AppendChild(city(doc, cmap.get(i, j))); e.AppendChild(p); } return e; }
public static CityMap citymap(XmlElement e) { CityMap cmap = new CityMap(int.Parse(e.GetAttribute("numx")), int.Parse(e.GetAttribute("numy"))); Point p; foreach (XmlElement ce in e.ChildNodes) if (ce.Name == "Pos") { p = pos(ce); cmap.set(p.X, p.Y, city(ce["City"])); } return cmap; }