예제 #1
0
    public static void SaveData()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/gd.fun";
        FileStream      fStream   = new FileStream(path, FileMode.Create);

        GameDataSL gdsl = new GameDataSL(true);

        formatter.Serialize(fStream, gdsl);
        fStream.Close();
    }
예제 #2
0
    public static GameDataSL LoadData()
    {
        string path = Application.persistentDataPath + "/gd.fun";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      fStream   = new FileStream(path, FileMode.Open);
            GameDataSL      gdsl      = formatter.Deserialize(fStream) as GameDataSL;
            fStream.Close();
            return(gdsl);
        }
        else
        {
            return(null);
        }
    }
예제 #3
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         GameDataSL gdsl = SaveLoadSystem.LoadData();
         maxTime           = gdsl.maxTime;
         increaseTime      = gdsl.increaseTime;
         coins             = gdsl.coins;
         priceMaxTime      = gdsl.priceMaxTime;
         priceIncreaseTime = gdsl.priceIncreaseTime;
         bestScore         = gdsl.bestScore;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }