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 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 GameState() { turn = 0; alignment = 0; att = 0; saved = false; mainArmy = new Army(); mainChar = null; mainCharPos = new Point(-1, -1); gen = null; citymap = new Dictionary<String, CityMap>(); citymap.Add("gen", Content.Instance.gen.CityMap.clone()); foreach (String s in Tilemap.reflist("map\\gen.map")) citymap.Add(s, new Tilemap(s).CityMap.clone()); }
public void load(String path) { XmlDocument doc = new XmlDocument(); doc.Load(path); alignment = int.Parse(doc.DocumentElement.GetAttribute("ali")); turn = int.Parse(doc.DocumentElement.GetAttribute("turn")); att = int.Parse(doc.DocumentElement.GetAttribute("att")); /*foreach (XmlElement e in doc.DocumentElement.ChildNodes) if (e.Name=="Character" && e.GetAttribute("org") == "main") mainChar = XmlTransaltor.xmlToChar(e);*/ foreach (XmlElement e in doc.DocumentElement.ChildNodes) if (e.Name=="Army" && e.GetAttribute("org") == "main") mainArmy = XmlTransaltor.army(e); //mainChar = mainArmy.MainCharUnit.Leader; mainCharPos = XmlTransaltor.pos(doc.DocumentElement["MainCharPos"]); gen = XmlTransaltor.fog(doc.DocumentElement["Fog"]); citymap.Clear(); foreach (XmlElement e in doc.DocumentElement["CityMapList"].ChildNodes) citymap.Add(e.GetAttribute("region"), XmlTransaltor.citymap(e)); foreach (XmlElement e in doc.DocumentElement["RecruitmentList"].ChildNodes) Content.Instance.recruitedLs.Add(e.GetAttribute("name")); Content.Instance.cleanRecruitLs(); saved = true; }
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 Fog fog(XmlElement e) { int numx = int.Parse(e.GetAttribute("numx")); int numy = int.Parse(e.GetAttribute("numy")); Fog f = new Fog(numx, numy); bool[] ba = Gen.BitPacker.unpack(Gen.hexstr(e.GetAttribute("data"))); for (int j = 0; j < numy; j++) for (int i = 0; i < numx; i++) f.set(i, j, ba[j * numx + i]); return f; }
public static XmlElement fog(XmlDocument doc, Fog f) { XmlElement e = doc.CreateElement("Fog"); e.SetAttribute("numx", f.NumX.ToString()); e.SetAttribute("numy", f.NumY.ToString()); e.SetAttribute("data", Gen.strhex(f.toByteArray())); return e; }