Exemplo n.º 1
0
        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;
                    }
                }
            }
        }
Exemplo n.º 2
0
        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>();
        }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
 public Tile(fbMap map, int x, int y)
 {
     this.map = map;
     Position = new Vector2i(x, y);
 }