public static void LoadMap(ref fbMap map, string path) { using (FileStream stream = File.OpenRead(path)) { StreamReader reader = new StreamReader(stream); string header = reader.ReadLine(); if (header == null) { throw new FormatException(); } string size = header.Split(';')[0]; int w = Int32.Parse(size.Split(',')[0]); int h = Int32.Parse(size.Split(',')[1]); map = new fbMap(w, h); string stations = reader.ReadLine(); if (stations == null) { throw new FormatException(); } foreach (string stationString in stations.Split(';')) { if (stationString == "") { continue; } } } }
public fbWorld(fbGame game, int w, int h) { Game = game; Map = new fbMap(w, h); Players = new Dictionary <int, Player>(); Units = new Dictionary <int, Unit>(); PlayerUnits = new Dictionary <int, List <int> >(); PlayerStations = new Dictionary <int, List <int> >(); PlayerStarts = new List <Vector2i>(); }
public static void SaveMap(fbMap map, string path) { if (File.Exists(path)) { File.Delete(path); } using (FileStream stream = File.OpenWrite(path)) { string output = ""; output += string.Format( "{0},{1};", map.Width, map.Height ); output += "\n"; foreach (Station s in map.Stations.Values) { output += string.Format( "{0},{1},{2},{3};", s.ID, s.Owner, s.Position.X, s.Position.Y ); } output += "\n"; foreach (Planet p in map.Planets) { output += string.Format( "{0},{1};", p.Position.X, p.Position.Y ); } output += "\n"; StreamWriter sw = new StreamWriter(stream); sw.Write(output); sw.Flush(); } }
public Tile(fbMap map, int x, int y) { this.map = map; Position = new Vector2i(x, y); }