Beispiel #1
0
    // Use this for initialization
    void OnEnable()
    {
        save = GetComponent <SaveBuffer>();

        if (name != null)
        {
            float[] data = save.Load(name);
            if (data.Length == 1)
            {
                SetUp();
            }
            else
            {
                values = data;

                loaded = 1;
            }
        }



        _buffer = new ComputeBuffer(dimensions * dimensions * dimensions, sizeof(float) * 8);

        _buffer.SetData(values);
    }
Beispiel #2
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            var sb = new SaveBuffer(_table);

            try
            {
                FileStream fs;
                try
                {
                    fs = new FileStream("save.dat", FileMode.Truncate, FileAccess.Write);
                }
                catch (Exception)
                {
                    fs = new FileStream("save.dat", FileMode.Create, FileAccess.Write);
                }

                var bf = new BinaryFormatter();

                bf.Serialize(fs, sb);
                fs.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Сохранение результата не удалось");
            }
        }
Beispiel #3
0
        public MainForm()
        {
            InitializeComponent();

            try
            {
                FileStream      fs = new FileStream("save.dat", FileMode.Open, FileAccess.Read);
                BinaryFormatter bf = new BinaryFormatter();
                SaveBuffer      sb = (SaveBuffer)bf.Deserialize(fs);
                _table = new GameBoard(sb);
            }
            catch (Exception)
            {
                _table = new GameBoard();
                _table.Restart();
            }

            foreach (Cell cell in _table)
            {
                cell.Win += Win;
            }

            _table.Lose += Lose;

            ShowTable();
        }
Beispiel #4
0
 public void Serialize()
 {
     SaveBuffer.Flush();
     Serialize(SaveBuffer);
 }
Beispiel #5
0
 public void Serialize()
 {
     SaveBuffer ??= new BufferWriter(true);
     SaveBuffer.Reset();
     Serialize(SaveBuffer);
 }