using UnityEngine;
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

public static class SaveLoad
{
    static GlobalControl control;
  
    public static void Initialize(GlobalControl gc)
    {
        control = gc;
    }

    public static void SaveGame(string fileName)
    {
        FileStream stream = new FileStream(fileName, FileMode.Create);
        var bf = new BinaryFormatter();

        bf.Serialize(stream, control.progress);

        stream.Close();
    }

    public static void LoadGame(string fileName)
    {
        FileStream stream = new FileStream(fileName, FileMode.Open);
        var bf = new BinaryFormatter();

        control.progress = bf.Deserialize(stream) as ProgressStats;

        stream.Close();
    }

    //public static void Serialize(object data) { bf.Serialize(stream, data); }
    //public object Load() { return bf.Deserialize(stream); }

    //public void Save(Vector2 data) { Serialize(data.ToArray()); }
    //public Vector2 Vector2() { return ((float[])bf.Deserialize(stream)).ToVector2(); }



}