public static GameCompletionRecord operator +(GameCompletionRecord t, GameCompletionRecord t2) { GameCompletionRecord temp = new GameCompletionRecord(); temp.act1Complete = t.act1Complete || t2.act1Complete; temp.act2Complete = t.act2Complete || t2.act2Complete; temp.act3Complete = t.act3Complete || t2.act3Complete; return(temp); }
// Start is called before the first frame update public void OnEnable() { Debug.Log("EnableActButtons on enable called."); if (File.Exists(Application.persistentDataPath + "/gameCompletion.sav")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gameCompletion.sav", FileMode.Open); actDataLoad = (GameCompletionRecord)bf.Deserialize(file); file.Close(); act2Button.interactable = actDataLoad.act1Complete; act3Button.interactable = actDataLoad.act2Complete; } //if the file doesn't exist, it was deleted, so the buttons should be not interactable else { act2Button.interactable = false; act3Button.interactable = false; } }
public void CompleteAct() { if (File.Exists(Application.persistentDataPath + "/gameCompletion.sav")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gameCompletion.sav", FileMode.Open); actDataLoad = (GameCompletionRecord)bf.Deserialize(file); file.Close(); actDataToSave = actDataLoad + actThisIs; } else { actDataToSave = actThisIs; } //save File BinaryFormatter bf_save = new BinaryFormatter(); FileStream file_save = File.Create(Application.persistentDataPath + "/gameCompletion.sav"); bf_save.Serialize(file_save, actDataToSave); file_save.Close(); }