private void InitMeta() { saveSlotMetas = new Dictionary <int, SaveSlotMeta>(); for (int i = 0; i < (int)SaveSlot.SlotNum; ++i) { SaveSlotMeta meta = new SaveSlotMeta(); meta.SceneCode = (int)gm.currentSceneCode; meta.elapsedSeconds = 0f; saveSlotMetas.Add(i, meta); } }
/// <summary> /// Use this to save meta infomation /// </summary> private void SaveMeta() { SaveSlotMeta meta = new SaveSlotMeta(); meta.SceneCode = (int)gm.currentSceneCode; meta.elapsedSeconds = gm.elapsedSeconds; UpdateMeta(currentSaveSlot, meta); try{ using (FileStream fs = new FileStream(saveDirectory + "/meta.tgb", FileMode.OpenOrCreate)){ var bf = new BinaryFormatter(); bf.Serialize(fs, saveSlotMetas); fs.Close(); } } catch (FileNotFoundException ex) { Debug.Log("On GameSaver::SaveMeta, " + ex.StackTrace); } }
public void UpdateMeta(SaveSlot saveSlot, SaveSlotMeta meta) { SaveSlotMetas[(int)saveSlot] = meta; }