bool LoadDB_Local() { FileInfo fi = new FileInfo(savePath + "/LocalDB.dat"); if (fi.Exists == true) { try { BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream(savePath + "/LocalDB.dat", FileMode.Open, FileAccess.Read); DataBase.LocalDB localDB = (DataBase.LocalDB)bf.Deserialize(fs); LandManager.instance.landList = localDB.landList; PuzzleManager.instance.puzzles = localDB.puzzles; fs.Close(); return(true); } catch { Debug.Log("Can't Accesse the Local Database"); return(false); } } else { return(false); } }
void SaveDB_Local() { DataBase.LocalDB localDB = new DataBase.LocalDB(); localDB.landList = LandManager.instance.landList; localDB.puzzles = PuzzleManager.instance.puzzles; DirectoryInfo di = new DirectoryInfo(savePath); if (di.Exists == false) { di.Create(); Debug.Log("newFolder"); }//폴더 없으면 만듦. BinaryFormatter bf = new BinaryFormatter(); if (System.IO.File.Exists(savePath + "/LocalDB.dat")) { Debug.Log("double"); } //덮어쓸거야?} FileStream fs = new FileStream(savePath + "/LocalDB.dat", FileMode.Create); bf.Serialize(fs, localDB); fs.Close(); }