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

public static class SaveLoad  {
    public static List<Game> myGames = new List<Game>();
	public static void Save(bool createNewGame)
    {
        

		if (createNewGame) {
			Load();
			myGames.Add(Game.currentGame);
		}

        BinaryFormatter bf = new BinaryFormatter();
        FileStream myFile = File.Create(Application.persistentDataPath + "/GameData.gd");
        bf.Serialize(myFile, myGames);
        myFile.Close();

    }
    public static void Load()
    {
        if (File.Exists(Application.persistentDataPath+ "/GameData.gd"))
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream myFile = File.Open(Application.persistentDataPath +
 "/GameData.gd", FileMode.Open);
            myGames = (List<Game>)bf.Deserialize(myFile);
            myFile.Close();

        }
    }
}
