Exemple #1
0
        public void SaveToFile(string filename, HexMap map)
        {
            var record = new MapRecord {
                Name        = Path.GetFileNameWithoutExtension(filename),
                Width       = map.Width,
                Height      = map.Height,
                BaseTexture = map.Texture.Name,
                Hexes       = map.Hexes.Select(h => new HexRecord(h)).ToArray()
            };

            File.WriteAllText(filename, JsonConvert.SerializeObject(record));
        }
Exemple #2
0
        public void SaveToFileProto(string filename, HexMap map)
        {
            var record = new MapRecord {
                Name        = Path.GetFileNameWithoutExtension(filename),
                Width       = map.Width,
                Height      = map.Height,
                BaseTexture = map.Texture.Name,
                Hexes       = map.Hexes.Select(h => new HexRecord(h)).ToArray()
            };

            using (var stream = File.OpenWrite(filename)) {
                Serializer.Serialize(stream, record);
            }
        }