Ejemplo n.º 1
0
        private void MenuWindow_Load(object sender, EventArgs e)
        {
            allLevels = new List <LevelInformation>();
            string[]   names     = Directory.GetFiles(@"C:\Users\Vartotojas\Source\BreakoutRepos\SuperBreakout\Super Breakout\Super Breakout\bin\Debug", "*.bin");
            IFormatter formatter = new BinaryFormatter();

            foreach (var n in names)
            {
                Stream           stream = new FileStream(n, FileMode.Open, FileAccess.Read, FileShare.Read);
                LevelInformation obj    = (LevelInformation)formatter.Deserialize(stream);
                allLevels.Add(obj);
                stream.Close();
            }

            foreach (var a in allLevels)
            {
                chooseLevel.Items.Add(a.LevelName);
            }

            chooseLevel.SelectedItem = "";
        }
Ejemplo n.º 2
0
        private void _saveMapButton_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 15; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (Buttons[i, j].BackgroundImage != null)
                    {
                        _locations[i, j] = 1;
                    }
                }
            }
            _levelInf = new LevelInformation()
            {
                LevelName = _mapName.Text,
                BlockInfo = _locations
            };

            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream(_levelInf.LevelName + ".bin", FileMode.Create, FileAccess.Write, FileShare.None);

            formatter.Serialize(stream, _levelInf);
            stream.Close();
        }