private void LoadData_Click(object sender, EventArgs e) { int NewAttack; int NewDefense; //Loads the saved information for currentHero, currentItem, and currentArmor if (Singleton.Instance.currentHero != null) { Singleton.Instance.currentHero = AssessmentSerialization <Players> .Deserialize("CurrentPlayer"); //If there is no Player chosen, the program will not break PlayerSelection.SelectedItem = Singleton.Instance.currentHero.Name; //Makes the comboBox currentHero equal the saved currentHero } if (Singleton.Instance.currentItem != null) { Singleton.Instance.currentItem = AssessmentSerialization <Items> .Deserialize("CurrentItem"); //If there is no Item chosen, the program will not break ItemSelection.SelectedItem = Singleton.Instance.currentItem.Name; //Makes the comboBox currentItem equal the saved currentItem NewAttack = Singleton.Instance.currentHero.Attack + Singleton.Instance.currentItem.Attack; //When Loaded, it automatically fixes the combined attack ItemCombo.Text = NewAttack.ToString(); } if (Singleton.Instance.currentArmor != null) { Singleton.Instance.currentArmor = AssessmentSerialization <Armor> .Deserialize("CurrentArmor"); //If there is no Armor chosen, the program will not break ArmorSelection.SelectedItem = Singleton.Instance.currentArmor.Name; //Makes the comboBox currentArmor equal the saved currentArmor NewDefense = Singleton.Instance.currentHero.Defense + Singleton.Instance.currentArmor.Defense; //When Loaded, it automatically fixes the combined defense ArmorCombo.Text = NewDefense.ToString(); } SaveLoad.AppendText(" Loaded"); }
private void SaveData_Click(object sender, EventArgs e) { //Saves the current information for currentHero, currentItem, and currentArmor if (PlayerSelection != null) { AssessmentSerialization <Players> .Serialize("CurrentPlayer", Singleton.Instance.currentHero);//If there is no Player chosen, the program will not break } if (ItemSelection != null) { AssessmentSerialization <Items> .Serialize("CurrentItem", Singleton.Instance.currentItem);//If there is no Item chosen, the program will not break } if (ArmorSelection != null) { AssessmentSerialization <Armor> .Serialize("CurrentArmor", Singleton.Instance.currentArmor);//If there is no Armor chosen, the program will not break } SaveLoad.AppendText(" Saved"); }