public void CombatStyleSave() { if(saveStream==null) CombatStyleDialogSaveAs(); else { CombatAttributes Attri = new CombatAttributes(CombatStyleComAttrFireIn_Num.Value, CombatStyleComAttrIceIn_Num.Value, CombatStyleComAttrAirIn_Num.Value, CombatStyleComAttrEarthIn_Num.Value, CombatStyleComAttrSlashIn_Num.Value, CombatStyleComAttrBashIn_Num.Value, CombatStyleComAttrPierceIn_Num.Value); String Name = CombatStyleNameIn_Text.Text; String pFileLocation = CombatStylePClassIn_Text.Text; String animeFileLocation = CombatStyleAnimIn_Text.Text; CombatStyle style = new CombatStyle(Attri, Name ,pFileLocation, animeFileLocation); if (!CombatStyles.Contains(style)) { CombatStyles.Add(style); } DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<CombatStyle>)); serializer.WriteObject(saveStream, CombatStyles); } }
public CombatStyle(CombatStyle comb) { this.Attributes = comb.Attributes; this.Name = comb.Name; this.PartialClassLocation = comb.PartialClassLocation; this.Animation = comb.Animation; }
private void LoadCombatStyle_Click(object sender, EventArgs e) { if (CombatStyles_List.SelectedItem != null) { CombatStyle inCom = new CombatStyle((CombatStyle)CombatStyles_List.SelectedItem); CombatStyleNameIn_Text.Text = inCom.Name; CombatStyleComAttrFireIn_Num.Value = inCom.Attributes.elements.Fire; CombatStyleComAttrAirIn_Num.Value = inCom.Attributes.elements.Air; CombatStyleComAttrEarthIn_Num.Value = inCom.Attributes.elements.Earth; CombatStyleComAttrIceIn_Num.Value = inCom.Attributes.elements.Ice; CombatStyleComAttrSlashIn_Num.Value = inCom.Attributes.normal.Slashing; CombatStyleComAttrBashIn_Num.Value = inCom.Attributes.normal.Bashing; CombatStyleComAttrPierceIn_Num.Value = inCom.Attributes.normal.Piercing; CombatStylePClassIn_Text.Text = inCom.PartialClassLocation; CombatStyleAnimIn_Text.Text = inCom.Animation; } }
private void CombatStyleSave_Button_Click(object sender, EventArgs e) { if (CombatStyleNameIn_Text.Text != "") { CombatAttributes Attri = new CombatAttributes(CombatStyleComAttrFireIn_Num.Value, CombatStyleComAttrIceIn_Num.Value, CombatStyleComAttrAirIn_Num.Value, CombatStyleComAttrEarthIn_Num.Value, CombatStyleComAttrSlashIn_Num.Value, CombatStyleComAttrBashIn_Num.Value, CombatStyleComAttrPierceIn_Num.Value); String Name = CombatStyleNameIn_Text.Text; String pFileLocation = CombatStylePClassIn_Text.Text; String animeFileLocation = CombatStyleAnimIn_Text.Text; CombatStyle style = new CombatStyle(Attri, Name, pFileLocation, animeFileLocation); bool OK = true; List<CombatStyle> mock = new List<CombatStyle>(CombatStyles); foreach (CombatStyle styleCompare in mock) { if (styleCompare.Equals(style)) { if (MessageBox.Show("Would you like to replace the combat style on the list?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { CombatStyles.Remove(styleCompare); } else OK = false; } } if (OK) { CombatStyles.Add(style); CombatStyles_List.DataSource = new List<CombatStyle>(CombatStyles); } } }