Ejemplo n.º 1
0
        public void FromFile(string Filename, Tiles tiles, PaletteModel palette, SelectedColourModel selectedcolours, LevelScreens screens)
        {
            var stuff = System.IO.File.ReadAllText(Filename);

            string[] separatingChars = { Constants.SEPARATOR };
            string[] SplitData       = stuff.Split(separatingChars, System.StringSplitOptions.None);

            var deserialized = new JavaScriptSerializer();

            tiles.TileList         = deserialized.Deserialize <List <Tile> >(SplitData[0]);
            palette.CurrentPalette = deserialized.Deserialize <Constants.Colour[]>(SplitData[1]);
            selectedcolours.pal    = deserialized.Deserialize <int[]>(SplitData[3]);
            screens.list           = deserialized.Deserialize <List <LevelScreen> >(SplitData[4]);

            //  var deserialized = new JavaScriptSerializer();
            //  tiles.TileList = deserialized.Deserialize<List<Tile>>(stuff);
            //palette.pal = deserialized.Deserialize<>
        }
Ejemplo n.º 2
0
        public void ToFile(string Filename, Tiles tiles, PaletteModel palette, SelectedColourModel selectedcolours, LevelScreens screens)
        {
            var serializer       = new JavaScriptSerializer();
            var serializedResult =
                serializer.Serialize(tiles.TileList.Select(x => new { x.tileNumber, x.Pixels, x.prevPixels }));
            var serPalette       = new JavaScriptSerializer();
            var serPaletteResult = serPalette.Serialize(palette.CurrentPalette);
            var serPalRes        = serPalette.Serialize(palette.pal);
            var serSelColRes     = serPalette.Serialize(selectedcolours.pal);
            var serLevelScreens  = serializer.Serialize(screens.list);
            var AllResults       =
                serializedResult + Constants.SEPARATOR +
                serPaletteResult + Constants.SEPARATOR +
                serPalRes + Constants.SEPARATOR +
                serSelColRes + Constants.SEPARATOR +
                serLevelScreens;



            System.IO.File.WriteAllText(Filename, AllResults);
        }