本文整理汇总了C#中Chummer.Character.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Character.Save方法的具体用法?C# Character.Save怎么用?C# Character.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chummer.Character
的用法示例。
在下文中一共展示了Character.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mnuSpecialPossessInanimate_Click
private void mnuSpecialPossessInanimate_Click(object sender, EventArgs e)
{
// Make sure the Spirit has been saved first.
if (_blnIsDirty)
{
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_PossessionSave"), LanguageManager.Instance.GetString("MessageTitle_Possession"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
return;
}
// Prompt the user to select an inanimate Vessel.
XmlDocument objVesselDoc = XmlManager.Instance.Load("vessels.xml");
XmlNodeList objXmlMetatypeList = objVesselDoc.SelectNodes("/chummer/metatypes/metatype");
List<ListItem> lstMetatype = new List<ListItem>();
foreach (XmlNode objXmlMetatype in objXmlMetatypeList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlMetatype["name"].InnerText;
if (objXmlMetatype["translate"] != null)
objItem.Name = objXmlMetatype["translate"].InnerText;
else
objItem.Name = objXmlMetatype["name"].InnerText;
lstMetatype.Add(objItem);
}
frmSelectItem frmSelectVessel = new frmSelectItem();
frmSelectVessel.GeneralItems = lstMetatype;
frmSelectVessel.ShowDialog(this);
if (frmSelectVessel.DialogResult == DialogResult.Cancel)
return;
// Load the Spirit's save file into a new Merge character.
Character objMerge = new Character();
objMerge.FileName = _objCharacter.FileName;
objMerge.Load();
objMerge.Possessed = true;
objMerge.Alias = frmSelectVessel.SelectedItem + " (" + LanguageManager.Instance.GetString("String_Possessed") + ")";
// Get the Node for the selected Vessel.
XmlNode objSelected = objVesselDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + frmSelectVessel.SelectedItem + "\"]");
// Get the Attribute Modifiers for the Vessel.
int intBOD = Convert.ToInt32(objSelected["bodmin"].InnerText);
int intAGI = Convert.ToInt32(objSelected["agimin"].InnerText);
int intREA = Convert.ToInt32(objSelected["reamin"].InnerText);
int intSTR = Convert.ToInt32(objSelected["strmin"].InnerText);
// Add the Attribute modifiers, making sure that none of them go below 1.
int intSetBOD = objMerge.MAG.TotalValue + intBOD;
int intSetAGI = objMerge.MAG.TotalValue + intAGI;
int intSetREA = objMerge.MAG.TotalValue + intREA;
int intSetSTR = objMerge.MAG.TotalValue + intSTR;
objMerge.BOD.MetatypeMinimum += intBOD;
if (objMerge.BOD.MetatypeMinimum < 1)
objMerge.BOD.MetatypeMinimum = 1;
objMerge.BOD.MetatypeMaximum += intBOD;
if (objMerge.BOD.MetatypeMaximum < 1)
objMerge.BOD.MetatypeMaximum = 1;
objMerge.BOD.Value = intSetBOD;
if (objMerge.BOD.Value < 1)
objMerge.BOD.Value = 1;
objMerge.AGI.MetatypeMinimum += intAGI;
if (objMerge.AGI.MetatypeMinimum < 1)
objMerge.AGI.MetatypeMinimum = 1;
objMerge.AGI.MetatypeMaximum += intAGI;
if (objMerge.AGI.MetatypeMaximum < 1)
objMerge.AGI.MetatypeMaximum = 1;
objMerge.AGI.Value = intSetAGI;
if (objMerge.AGI.Value < 1)
objMerge.AGI.Value = 1;
objMerge.REA.MetatypeMinimum += intREA;
if (objMerge.REA.MetatypeMinimum < 1)
objMerge.REA.MetatypeMinimum = 1;
objMerge.REA.MetatypeMaximum += intREA;
if (objMerge.REA.MetatypeMaximum < 1)
objMerge.REA.MetatypeMaximum = 1;
objMerge.REA.Value = intSetREA;
if (objMerge.REA.Value < 1)
objMerge.REA.Value = 1;
objMerge.STR.MetatypeMinimum += intSTR;
if (objMerge.STR.MetatypeMinimum < 1)
objMerge.STR.MetatypeMinimum = 1;
objMerge.STR.MetatypeMaximum += intSTR;
if (objMerge.STR.MetatypeMaximum < 1)
objMerge.STR.MetatypeMaximum = 1;
objMerge.STR.Value = intSetSTR;
if (objMerge.STR.Value < 1)
objMerge.STR.Value = 1;
// Update the Movement if the Vessel has one.
if (objSelected["movement"] != null)
objMerge.Movement = objSelected["movement"].InnerText;
// Add any additional Critter Powers the Vessel grants.
if (objSelected["powers"] != null)
{
//.........这里部分代码省略.........
示例2: mnuSpecialPossess_Click
private void mnuSpecialPossess_Click(object sender, EventArgs e)
{
// Make sure the Spirit has been saved first.
if (_blnIsDirty)
{
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_PossessionSave"), LanguageManager.Instance.GetString("MessageTitle_Possession"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
return;
}
// Prompt the user to select a save file to possess.
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
Character objVessel = new Character();
objVessel.FileName = openFileDialog.FileName;
objVessel.Load();
// Make sure the Vessel is in Career Mode.
if (!objVessel.Created)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_VesselInCareerMode"), LanguageManager.Instance.GetString("MessageTitle_Possession"), MessageBoxButtons.OK, MessageBoxIcon.Error);
objVessel = null;
return;
}
// Load the Spirit's save file into a new Merge character.
Character objMerge = new Character();
objMerge.FileName = _objCharacter.FileName;
objMerge.Load();
objMerge.Possessed = true;
objMerge.Alias = objVessel.Alias + " (" + LanguageManager.Instance.GetString("String_Possessed") + ")";
// Give the Critter the Immunity to Normal Weapons Power if they don't already have it.
bool blnHasImmunity = false;
foreach (CritterPower objCritterPower in objMerge.CritterPowers)
{
if (objCritterPower.Name == "Immunity" && objCritterPower.Extra == "Normal Weapons")
{
blnHasImmunity = true;
break;
}
}
if (!blnHasImmunity)
{
XmlDocument objPowerDoc = new XmlDocument();
objPowerDoc = XmlManager.Instance.Load("critterpowers.xml");
XmlNode objPower = objPowerDoc.SelectSingleNode("/chummer/powers/power[name = \"Immunity\"]");
CritterPower objCritterPower = new CritterPower(objMerge);
TreeNode objDummy = new TreeNode();
objCritterPower.Create(objPower, objMerge, objDummy, 0, "Normal Weapons");
objMerge.CritterPowers.Add(objCritterPower);
}
// Add the Vessel's Physical Attributes to the Spirit's Force.
objMerge.BOD.MetatypeMaximum = objVessel.BOD.Value + objMerge.MAG.TotalValue;
objMerge.BOD.Value = objVessel.BOD.Value + objMerge.MAG.TotalValue;
objMerge.AGI.MetatypeMaximum = objVessel.AGI.Value + objMerge.MAG.TotalValue;
objMerge.AGI.Value = objVessel.AGI.Value + objMerge.MAG.TotalValue;
objMerge.REA.MetatypeMaximum = objVessel.REA.Value + objMerge.MAG.TotalValue;
objMerge.REA.Value = objVessel.REA.Value + objMerge.MAG.TotalValue;
objMerge.STR.MetatypeMaximum = objVessel.STR.Value + objMerge.MAG.TotalValue;
objMerge.STR.Value = objVessel.STR.Value + objMerge.MAG.TotalValue;
// Copy any Lifestyles the Vessel has.
foreach (Lifestyle objLifestyle in objVessel.Lifestyles)
objMerge.Lifestyles.Add(objLifestyle);
// Copy any Armor the Vessel has.
foreach (Armor objArmor in objVessel.Armor)
{
objMerge.Armor.Add(objArmor);
CopyArmorImprovements(objVessel, objMerge, objArmor);
}
// Copy any Gear the Vessel has.
foreach (Gear objGear in objVessel.Gear)
{
objMerge.Gear.Add(objGear);
CopyGearImprovements(objVessel, objMerge, objGear);
}
// Copy any Cyberware/Bioware the Vessel has.
foreach (Cyberware objCyberware in objVessel.Cyberware)
{
objMerge.Cyberware.Add(objCyberware);
CopyCyberwareImprovements(objVessel, objMerge, objCyberware);
}
// Copy any Weapons the Vessel has.
foreach (Weapon objWeapon in objVessel.Weapons)
objMerge.Weapons.Add(objWeapon);
// Copy and Vehicles the Vessel has.
foreach (Vehicle objVehicle in objVessel.Vehicles)
objMerge.Vehicles.Add(objVehicle);
// Copy the character info.
objMerge.Sex = objVessel.Sex;
//.........这里部分代码省略.........
示例3: CreateCritter
/// <summary>
/// Create a Critter, put them into Career Mode, link them, and open the newly-created Critter.
/// </summary>
/// <param name="strCritterName">Name of the Critter's Metatype.</param>
/// <param name="intForce">Critter's Force.</param>
private void CreateCritter(string strCritterName, int intForce)
{
// The Critter should use the same settings file as the character.
Character objCharacter = new Character();
objCharacter.SettingsFile = _objSpirit.CharacterObject.SettingsFile;
// Override the defaults for the setting.
objCharacter.IgnoreRules = true;
objCharacter.IsCritter = true;
objCharacter.BuildMethod = CharacterBuildMethod.Karma;
objCharacter.BuildPoints = 0;
if (txtCritterName.Text != string.Empty)
objCharacter.Name = txtCritterName.Text;
// Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book.
bool blnRunningWild = false;
blnRunningWild = (objCharacter.Options.Books.Contains("RW"));
if (!blnRunningWild)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Ask the user to select a filename for the new character.
string strForce = LanguageManager.Instance.GetString("String_Force");
if (_objSpirit.EntityType == SpiritType.Sprite)
strForce = LanguageManager.Instance.GetString("String_Rating");
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*";
saveFileDialog.FileName = strCritterName + " (" + strForce + " " + _objSpirit.Force.ToString() + ").chum5";
if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
{
string strFileName = saveFileDialog.FileName;
objCharacter.FileName = strFileName;
}
else
return;
// Code from frmMetatype.
ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");
XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + strCritterName + "\"]");
// If the Critter could not be found, show an error and get out of here.
if (objXmlMetatype == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_UnknownCritterType").Replace("{0}", strCritterName), LanguageManager.Instance.GetString("MessageTitle_SelectCritterType"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Set Metatype information.
if (strCritterName == "Ally Spirit")
{
objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0));
objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0));
objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0));
objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0));
objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0));
objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0));
objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0));
objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0));
objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0));
objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0));
objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0));
objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
}
else
{
int intMinModifier = -3;
if (objXmlMetatype["category"].InnerText == "Mutant Critters")
intMinModifier = 0;
objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3));
objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3));
objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3));
objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3));
objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3));
objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3));
objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3));
objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3));
objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3));
objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3));
objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3));
objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
}
// If we're working with a Critter, set the Attributes to their default values.
objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0));
objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0));
objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0));
objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0));
//.........这里部分代码省略.........