本文整理汇总了C#中Chummer.CritterPower.Create方法的典型用法代码示例。如果您正苦于以下问题:C# CritterPower.Create方法的具体用法?C# CritterPower.Create怎么用?C# CritterPower.Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chummer.CritterPower
的用法示例。
在下文中一共展示了CritterPower.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAllCritterPowersTest
public void CreateAllCritterPowersTest()
{
// Create a new Human character.
Character objCharacter = new Character();
objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));
TreeNode objNode = new TreeNode();
XmlDocument objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/powers/power"))
{
CritterPower objPower = new CritterPower(objCharacter);
objPower.Create(objXmlNode, objCharacter, objNode, 0, "", false);
}
}
示例2: cmdAddQuality_Click
private void cmdAddQuality_Click(object sender, EventArgs e)
{
frmSelectQuality frmPickQuality = new frmSelectQuality(_objCharacter);
frmPickQuality.ShowDialog(this);
// Don't do anything else if the form was canceled.
if (frmPickQuality.DialogResult == DialogResult.Cancel)
return;
XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
XmlNode objXmlQuality = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + frmPickQuality.SelectedQuality + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
objQuality.Create(objXmlQuality, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes);
objNode.ContextMenuStrip = cmsQuality;
if (objQuality.InternalId == Guid.Empty.ToString())
return;
if (frmPickQuality.FreeCost)
objQuality.BP = 0;
// If the item being checked would cause the limit of 25 BP spent on Positive Qualities to be exceed, do not let it be checked and display a message.
string strAmount = "";
int intMaxQualityAmount = 0;
strAmount = _objCharacter.GameplayOptionQualityLimit.ToString() + " " + LanguageManager.Instance.GetString("String_Karma");
intMaxQualityAmount = _objCharacter.GameplayOptionQualityLimit;
// Make sure that adding the Quality would not cause the character to exceed their BP limits.
int intBP = 0;
bool blnAddItem = true;
// Add the cost of the Quality that is being added.
if (objQuality.ContributeToLimit)
intBP += objQuality.BP;
if (objQuality.Type == QualityType.Negative)
{
// Calculate the cost of the current Negative Qualities.
foreach (Quality objCharacterQuality in _objCharacter.Qualities)
{
if (objCharacterQuality.Type == QualityType.Negative && objCharacterQuality.ContributeToLimit)
intBP += objCharacterQuality.BP;
}
// Include the BP used by Enemies.
if (lblEnemiesBP.Text.Contains(LanguageManager.Instance.GetString("String_BP")))
intBP += int.Parse(lblEnemiesBP.Text.Replace(LanguageManager.Instance.GetString("String_Karma"), ""));
else
intBP += int.Parse(lblEnemiesBP.Text.Replace(" " + LanguageManager.Instance.GetString("String_Karma"), ""));
// Include the amount from Free Negative Quality BP cost Improvements.
intBP -= (_objImprovementManager.ValueOf(Improvement.ImprovementType.FreeNegativeQualities) * _objOptions.KarmaQuality);
// Check if adding this Quality would put the character over their limit.
if (!_objOptions.ExceedNegativeQualities)
{
if (intBP < (intMaxQualityAmount * -1) && !_objCharacter.IgnoreRules)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NegativeQualityLimit").Replace("{0}", strAmount), LanguageManager.Instance.GetString("MessageTitle_NegativeQualityLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
blnAddItem = false;
}
if (_objCharacter.MetatypeBP < 0)
{
if ((intBP + _objCharacter.MetatypeBP) < (intMaxQualityAmount * -1) && !_objCharacter.IgnoreRules)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NegativeQualityAndMetatypeLimit").Replace("{0}", strAmount), LanguageManager.Instance.GetString("MessageTitle_NegativeQualityLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
blnAddItem = false;
}
}
{
}
}
}
else
{
// Calculate the cost of the current Positive Qualities.
foreach (Quality objCharacterQuality in _objCharacter.Qualities)
{
if (objCharacterQuality.Type == QualityType.Positive && objCharacterQuality.ContributeToLimit)
intBP += objCharacterQuality.BP;
}
if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
intBP *= _objOptions.KarmaQuality;
// Include the amount from Free Negative Quality BP cost Improvements.
intBP -= (_objImprovementManager.ValueOf(Improvement.ImprovementType.FreePositiveQualities) * _objOptions.KarmaQuality);
// Check if adding this Quality would put the character over their limit.
if (!_objOptions.ExceedPositiveQualities)
{
if (intBP > intMaxQualityAmount && !_objCharacter.IgnoreRules)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_PositiveQualityLimit").Replace("{0}", strAmount), LanguageManager.Instance.GetString("MessageTitle_PositiveQualityLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
blnAddItem = false;
}
}
//.........这里部分代码省略.........
示例3: cmdAddCritterPower_Click
private void cmdAddCritterPower_Click(object sender, EventArgs e)
{
// Make sure the Critter is allowed to have Optional Powers.
XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");
XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
if (objXmlCritter == null)
{
objXmlDocument = XmlManager.Instance.Load("metatypes.xml");
objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
}
frmSelectCritterPower frmPickCritterPower = new frmSelectCritterPower(_objCharacter);
frmPickCritterPower.ShowDialog(this);
if (frmPickCritterPower.DialogResult == DialogResult.Cancel)
return;
objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + frmPickCritterPower.SelectedPower + "\"]");
TreeNode objNode = new TreeNode();
CritterPower objPower = new CritterPower(_objCharacter);
objPower.Create(objXmlPower, _objCharacter, objNode, frmPickCritterPower.SelectedRating);
objPower.PowerPoints = frmPickCritterPower.PowerPoints;
objNode.ContextMenuStrip = cmsCritterPowers;
if (objPower.InternalId == Guid.Empty.ToString())
return;
_objCharacter.CritterPowers.Add(objPower);
if (objPower.Category != "Weakness")
{
treCritterPowers.Nodes[0].Nodes.Add(objNode);
treCritterPowers.Nodes[0].Expand();
}
else
{
treCritterPowers.Nodes[1].Nodes.Add(objNode);
treCritterPowers.Nodes[1].Expand();
}
treCritterPowers.SortCustom();
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
if (frmPickCritterPower.AddAgain)
cmdAddCritterPower_Click(sender, e);
}
示例4: mnuSpecialConvertToFreeSprite_Click
private void mnuSpecialConvertToFreeSprite_Click(object sender, EventArgs e)
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Denial\"]");
TreeNode objNode = new TreeNode();
CritterPower objPower = new CritterPower(_objCharacter);
objPower.Create(objXmlPower, _objCharacter, objNode);
objPower.CountTowardsLimit = false;
objNode.ContextMenuStrip = cmsCritterPowers;
if (objPower.InternalId == Guid.Empty.ToString())
return;
_objCharacter.CritterPowers.Add(objPower);
treCritterPowers.Nodes[0].Nodes.Add(objNode);
treCritterPowers.Nodes[0].Expand();
_objCharacter.MetatypeCategory = "Free Sprite";
mnuSpecialConvertToFreeSprite.Visible = false;
treCritterPowers.SortCustom();
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例5: mnuSpecialCyberzombie_Click
private void mnuSpecialCyberzombie_Click(object sender, EventArgs e)
{
bool blnEssence = true;
bool blnCyberware = false;
string strMessage = LanguageManager.Instance.GetString("Message_CyberzombieRequirements");
// Make sure the character has an Essence lower than 0.
if (_objCharacter.Essence >= 0)
{
strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsEssence");
blnEssence = false;
}
// Make sure the character has an Invoked Memory Stimulator.
foreach (Cyberware objCyberware in _objCharacter.Cyberware)
{
if (objCyberware.Name == "Invoked Memory Stimulator")
blnCyberware = true;
}
if (!blnCyberware)
strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsStimulator");
if (!blnEssence || !blnCyberware)
{
MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_CyberzombieRequirements"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberzombieConfirm"), LanguageManager.Instance.GetString("MessageTitle_CyberzombieConfirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
// Get the player to roll Dice to make a WIL Test and record the result.
frmDiceHits frmWILHits = new frmDiceHits();
frmWILHits.Text = LanguageManager.Instance.GetString("String_CyberzombieWILText");
frmWILHits.Description = LanguageManager.Instance.GetString("String_CyberzombieWILDescription");
int intDice = _objCharacter.WIL.TotalValue;
int intThreshold = 3 + (Convert.ToInt32(_objCharacter.EssencePenalty - Convert.ToInt32(_objCharacter.EssenceMaximum)));
frmWILHits.Dice = intDice;
frmWILHits.ShowDialog(this);
if (frmWILHits.DialogResult != DialogResult.OK)
return;
int intWILResult = frmWILHits.Result;
// The character gains 10 + ((Threshold - Hits) * 10)BP worth of Negative Qualities.
int intResult = 10;
if (intWILResult < intThreshold)
{
intResult = (intThreshold - intWILResult) * 10;
}
_objImprovementManager.CreateImprovement("", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Qualities", Improvement.ImprovementType.FreeNegativeQualities, "", intResult * -1);
// Convert the character.
// Characters lose access to Resonance.
_objCharacter.RESEnabled = false;
// Gain MAG that is permanently set to 1.
_objCharacter.MAGEnabled = true;
_objCharacter.MAG.MetatypeMinimum = 1;
_objCharacter.MAG.MetatypeMaximum = 1;
_objCharacter.MAG.Value = 1;
// Add the Cyberzombie Lifestyle if it is not already taken.
bool blnHasLifestyle = false;
foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
{
if (objLifestyle.Name == "Cyberzombie Lifestyle Addition")
blnHasLifestyle = true;
}
if (!blnHasLifestyle)
{
XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");
XmlNode objXmlLifestyle = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"Cyberzombie Lifestyle Addition\"]");
TreeNode objLifestyleNode = new TreeNode();
Lifestyle objLifestyle = new Lifestyle(_objCharacter);
objLifestyle.Create(objXmlLifestyle, objLifestyleNode);
_objCharacter.Lifestyles.Add(objLifestyle);
treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
treLifestyles.Nodes[0].Expand();
}
// Change the MetatypeCategory to Cyberzombie.
_objCharacter.MetatypeCategory = "Cyberzombie";
// Gain access to Critter Powers.
_objCharacter.CritterEnabled = true;
// Gain the Dual Natured Critter Power if it does not yet exist.
bool blnHasPower = false;
foreach (CritterPower objPower in _objCharacter.CritterPowers)
{
if (objPower.Name == "Dual Natured")
blnHasPower = true;
}
if (!blnHasPower)
{
//.........这里部分代码省略.........
示例6: ProcessBonus
private bool ProcessBonus(Improvement.ImprovementSource objImprovementSource, ref string strSourceName,
bool blnConcatSelectedValue,
int intRating, string strFriendlyName, XmlNode bonusNode, string strUnique)
{
Log.Info("Has Child Nodes");
// Add an Attribute.
if (bonusNode.LocalName == ("addattribute"))
{
Log.Info("addattribute");
if (bonusNode["name"].InnerText == "MAG")
{
_objCharacter.MAGEnabled = true;
Log.Info("Calling CreateImprovement for MAG");
CreateImprovement("MAG", objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute,
"enableattribute", 0, 0);
}
else if (bonusNode["name"].InnerText == "RES")
{
_objCharacter.RESEnabled = true;
Log.Info("Calling CreateImprovement for RES");
CreateImprovement("RES", objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute,
"enableattribute", 0, 0);
}
}
// Enable a special tab.
if (bonusNode.LocalName == ("enabletab"))
{
Log.Info("enabletab");
foreach (XmlNode objXmlEnable in bonusNode.ChildNodes)
{
switch (objXmlEnable.InnerText)
{
case "magician":
_objCharacter.MagicianEnabled = true;
Log.Info("magician");
CreateImprovement("Magician", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
"enabletab", 0, 0);
break;
case "adept":
_objCharacter.AdeptEnabled = true;
Log.Info("adept");
CreateImprovement("Adept", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
"enabletab",
0, 0);
break;
case "technomancer":
_objCharacter.TechnomancerEnabled = true;
Log.Info("technomancer");
CreateImprovement("Technomancer", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
"enabletab", 0, 0);
break;
case "critter":
_objCharacter.CritterEnabled = true;
Log.Info("critter");
CreateImprovement("Critter", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
"enabletab", 0, 0);
break;
case "initiation":
_objCharacter.InitiationEnabled = true;
Log.Info("initiation");
CreateImprovement("Initiation", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
"enabletab", 0, 0);
break;
}
}
}
// Select Restricted (select Restricted items for Fake Licenses).
if (bonusNode.LocalName == ("selectrestricted"))
{
Log.Info("selectrestricted");
frmSelectItem frmPickItem = new frmSelectItem();
frmPickItem.Character = _objCharacter;
if (_strForcedValue != string.Empty)
frmPickItem.ForceItem = _strForcedValue;
frmPickItem.AllowAutoSelect = false;
frmPickItem.ShowDialog();
// Make sure the dialogue window was not canceled.
if (frmPickItem.DialogResult == DialogResult.Cancel)
{
Rollback();
_strForcedValue = "";
_strLimitSelection = "";
return false;
}
_strSelectedValue = frmPickItem.SelectedItem;
if (blnConcatSelectedValue)
strSourceName += " (" + _strSelectedValue + ")";
Log.Info("_strSelectedValue = " + _strSelectedValue);
Log.Info("strSourceName = " + strSourceName);
// Create the Improvement.
Log.Info("Calling CreateImprovement");
CreateImprovement(frmPickItem.SelectedItem, objImprovementSource, strSourceName,
Improvement.ImprovementType.Restricted, strUnique);
}
//.........这里部分代码省略.........
示例7: cmdAddQuality_Click
private void cmdAddQuality_Click(object sender, EventArgs e)
{
frmSelectQuality frmPickQuality = new frmSelectQuality(_objCharacter);
frmPickQuality.ShowDialog(this);
// Don't do anything else if the form was canceled.
if (frmPickQuality.DialogResult == DialogResult.Cancel)
return;
XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
XmlNode objXmlQuality = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + frmPickQuality.SelectedQuality + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
objQuality.Create(objXmlQuality, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes);
objNode.ContextMenuStrip = cmsQuality;
if (objQuality.InternalId == Guid.Empty.ToString())
return;
if (frmPickQuality.FreeCost)
objQuality.BP = 0;
bool blnAddItem = true;
int intKarmaCost = objQuality.BP * _objOptions.KarmaQuality;
if (!_objCharacter.Options.DontDoubleQualities)
intKarmaCost *= 2;
// Make sure the character has enough Karma to pay for the Quality.
if (objQuality.Type == QualityType.Positive)
{
if (intKarmaCost > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
blnAddItem = false;
}
if (blnAddItem && !frmPickQuality.FreeCost && objQuality.ContributeToBP)
{
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSpend").Replace("{0}", objQuality.DisplayNameShort).Replace("{1}", intKarmaCost.ToString())))
blnAddItem = false;
}
if (blnAddItem && objQuality.ContributeToBP)
{
// Create the Karma expense.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseAddPositiveQuality") + " " + objQuality.DisplayNameShort, ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.AddQuality, objQuality.InternalId);
objExpense.Undo = objUndo;
}
}
else
{
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_AddNegativeQuality"), LanguageManager.Instance.GetString("MessageTitle_AddNegativeQuality"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
blnAddItem = false;
if (blnAddItem)
{
// Create a Karma Expense for the Negative Quality.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(0, LanguageManager.Instance.GetString("String_ExpenseAddNegativeQuality") + " " + objQuality.DisplayNameShort, ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.AddQuality, objQuality.InternalId);
objExpense.Undo = objUndo;
}
}
if (blnAddItem)
{
// Add the Quality to the appropriate parent node.
if (objQuality.Type == QualityType.Positive)
{
treQualities.Nodes[0].Nodes.Add(objNode);
treQualities.Nodes[0].Expand();
}
else
{
treQualities.Nodes[1].Nodes.Add(objNode);
treQualities.Nodes[1].Expand();
}
_objCharacter.Qualities.Add(objQuality);
// Add any created Weapons to the character.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
// Create the Weapon Node if one exists.
foreach (TreeNode objWeaponNode in objWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
//.........这里部分代码省略.........
示例8: cmdAddCritterPower_Click
private void cmdAddCritterPower_Click(object sender, EventArgs e)
{
// Make sure the Critter is allowed to have Optional Powers.
XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");
XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
if (objXmlCritter == null)
{
objXmlDocument = XmlManager.Instance.Load("metatypes.xml");
objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
}
frmSelectCritterPower frmPickCritterPower = new frmSelectCritterPower(_objCharacter);
frmPickCritterPower.ShowDialog(this);
if (frmPickCritterPower.DialogResult == DialogResult.Cancel)
return;
objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + frmPickCritterPower.SelectedPower + "\"]");
TreeNode objNode = new TreeNode();
CritterPower objPower = new CritterPower(_objCharacter);
objPower.Create(objXmlPower, _objCharacter, objNode, frmPickCritterPower.SelectedRating);
objPower.PowerPoints = frmPickCritterPower.PowerPoints;
objNode.ContextMenuStrip = cmsCritterPowers;
if (objPower.InternalId == Guid.Empty.ToString())
return;
_objCharacter.CritterPowers.Add(objPower);
if (objPower.Category != "Weakness")
{
treCritterPowers.Nodes[0].Nodes.Add(objNode);
treCritterPowers.Nodes[0].Expand();
}
else
{
treCritterPowers.Nodes[1].Nodes.Add(objNode);
treCritterPowers.Nodes[1].Expand();
}
// Determine if the Critter should have access to the Possession menu item.
bool blnAllowPossession = false;
foreach (CritterPower objCritterPower in _objCharacter.CritterPowers)
{
if (objCritterPower.Name == "Inhabitation" || objCritterPower.Name == "Possession")
{
blnAllowPossession = true;
break;
}
}
mnuSpecialPossess.Visible = blnAllowPossession;
_objFunctions.SortTree(treCritterPowers);
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
if (frmPickCritterPower.AddAgain)
cmdAddCritterPower_Click(sender, e);
}
示例9: 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;
//.........这里部分代码省略.........
示例10: mnuSpecialPossessInanimate_Click
//.........这里部分代码省略.........
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)
{
XmlDocument objXmlPowerDoc = XmlManager.Instance.Load("critterpowers.xml");
foreach (XmlNode objXmlPower in objSelected.SelectNodes("powers/power"))
{
XmlNode objXmlCritterPower = objXmlPowerDoc.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]");
CritterPower objPower = new CritterPower(objMerge);
string strSelect = "";
int intRating = 0;
if (objXmlPower.Attributes["select"] != null)
strSelect = objXmlPower.Attributes["select"].InnerText;
if (objXmlPower.Attributes["rating"] != null)
intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText);
TreeNode objDummy = new TreeNode();
objPower.Create(objXmlCritterPower, objMerge, objDummy, intRating, strSelect);
objMerge.CritterPowers.Add(objPower);
}
}
// 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 any Improvements the Vessel grants.
if (objSelected["bonus"] != null)
{
ImprovementManager objMergeManager = new ImprovementManager(objMerge);
objMergeManager.CreateImprovements(Improvement.ImprovementSource.Metatype, frmSelectVessel.SelectedItem, objSelected["bonus"], false, 1, frmSelectVessel.SelectedItem);
示例11: mnuSpecialCyberzombie_Click
private void mnuSpecialCyberzombie_Click(object sender, EventArgs e)
{
bool blnEssence = true;
bool blnCyberware = false;
string strMessage = LanguageManager.Instance.GetString("Message_CyberzombieRequirements");
// Make sure the character has an Essence lower than 0.
if (_objCharacter.Essence >= 0)
{
strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsEssence");
blnEssence = false;
}
// Make sure the character has an Invoked Memory Stimulator.
foreach (Cyberware objCyberware in _objCharacter.Cyberware)
{
if (objCyberware.Name == "Invoked Memory Stimulator")
blnCyberware = true;
}
if (!blnCyberware)
strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsStimulator");
if (!blnEssence || !blnCyberware)
{
MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_CyberzombieRequirements"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberzombieConfirm"), LanguageManager.Instance.GetString("MessageTitle_CyberzombieConfirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
// Convert the character.
// Characters lose access to Resonance.
_objCharacter.RESEnabled = false;
// Gain MAG that is permanently set to 1.
_objCharacter.MAGEnabled = true;
_objCharacter.MAG.MetatypeMinimum = 1;
_objCharacter.MAG.MetatypeMaximum = 1;
_objCharacter.MAG.Value = 1;
// Add the Cyberzombie Lifestyle if it is not already taken.
bool blnHasLifestyle = false;
foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
{
if (objLifestyle.Name == "Cyberzombie Lifestyle Addition")
blnHasLifestyle = true;
}
if (!blnHasLifestyle)
{
XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");
XmlNode objXmlLifestyle = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"Cyberzombie Lifestyle Addition\"]");
TreeNode objLifestyleNode = new TreeNode();
Lifestyle objLifestyle = new Lifestyle(_objCharacter);
objLifestyle.Create(objXmlLifestyle, objLifestyleNode);
_objCharacter.Lifestyles.Add(objLifestyle);
treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
treLifestyles.Nodes[0].Expand();
}
// Change the MetatypeCategory to Cyberzombie.
_objCharacter.MetatypeCategory = "Cyberzombie";
// Gain access to Critter Powers.
_objCharacter.CritterEnabled = true;
// Gain the Dual Natured Critter Power if it does not yet exist.
bool blnHasPower = false;
foreach (CritterPower objPower in _objCharacter.CritterPowers)
{
if (objPower.Name == "Dual Natured")
blnHasPower = true;
}
if (!blnHasPower)
{
XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"Dual Natured\"]");
TreeNode objNode = new TreeNode();
CritterPower objCritterPower = new CritterPower(_objCharacter);
objCritterPower.Create(objXmlPowerNode, _objCharacter, objNode);
_objCharacter.CritterPowers.Add(objCritterPower);
treCritterPowers.Nodes[0].Nodes.Add(objNode);
treCritterPowers.Nodes[0].Expand();
}
// Gain the Immunity (Normal Weapons) Critter Power if it does not yet exist.
blnHasPower = false;
foreach (CritterPower objPower in _objCharacter.CritterPowers)
{
if (objPower.Name == "Immunity" && objPower.Extra == "Normal Weapons")
blnHasPower = true;
}
if (!blnHasPower)
{
XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
//.........这里部分代码省略.........
示例12: 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));
//.........这里部分代码省略.........
示例13: MetatypeSelected
//.........这里部分代码省略.........
_objCharacter.REA.AssignLimits("0", "0", "0");
_objCharacter.STR.AssignLimits("0", "0", "0");
_objCharacter.WIL.AssignLimits("0", "0", "0");
_objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
_objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
}
// If this is a Shapeshifter, a Metavariant must be selected. Default to Human if None is selected.
if (cboCategory.SelectedValue.ToString() == "Shapeshifter" && cboMetavariant.SelectedValue.ToString() == "None")
cboMetavariant.SelectedValue = "Human";
_objCharacter.Metatype = lstMetatypes.SelectedValue.ToString();
_objCharacter.MetatypeCategory = cboCategory.SelectedValue.ToString();
if (cboMetavariant.SelectedValue.ToString() == "None")
{
_objCharacter.Metavariant = "";
_objCharacter.MetatypeBP = Convert.ToInt32(lblBP.Text);
}
else
{
_objCharacter.Metavariant = cboMetavariant.SelectedValue.ToString();
_objCharacter.MetatypeBP = Convert.ToInt32(lblMetavariantBP.Text);
}
if (objXmlMetatype["movement"] != null)
_objCharacter.Movement = objXmlMetatype["movement"].InnerText;
// Load the Qualities file.
XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");
if (cboMetavariant.SelectedValue.ToString() == "None")
{
// Determine if the Metatype has any bonuses.
if (objXmlMetatype.InnerXml.Contains("bonus"))
objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, lstMetatypes.SelectedValue.ToString(), objXmlMetatype.SelectSingleNode("bonus"), false, 1, lstMetatypes.SelectedValue.ToString());
// Create the Qualities that come with the Metatype.
foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality"))
{
XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";
if (objXmlQualityItem.Attributes["select"] != null)
strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
QualitySource objSource = new QualitySource();
objSource = QualitySource.Metatype;
if (objXmlQualityItem.Attributes["removable"] != null)
objSource = QualitySource.MetatypeRemovable;
objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
objQuality.ContributeToLimit = false;
_objCharacter.Qualities.Add(objQuality);
// Add any created Weapons to the character.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
}
foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality"))
{
XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";
示例14: TestMetatype
//.........这里部分代码省略.........
_objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0));
_objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0));
_objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0));
_objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0));
_objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0));
_objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0));
_objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0));
}
// Sprites can never have Physical Attributes or WIL.
if (objXmlMetatype["name"].InnerText.EndsWith("Sprite"))
{
_objCharacter.BOD.AssignLimits("0", "0", "0");
_objCharacter.AGI.AssignLimits("0", "0", "0");
_objCharacter.REA.AssignLimits("0", "0", "0");
_objCharacter.STR.AssignLimits("0", "0", "0");
_objCharacter.WIL.AssignLimits("0", "0", "0");
_objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
_objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
}
_objCharacter.Metatype = objXmlMetatype["name"].InnerText;
_objCharacter.MetatypeCategory = objXmlMetatype["category"].InnerText;
_objCharacter.Metavariant = "";
_objCharacter.MetatypeBP = 400;
if (objXmlMetatype["movement"] != null)
_objCharacter.Movement = objXmlMetatype["movement"].InnerText;
// Load the Qualities file.
XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");
// Determine if the Metatype has any bonuses.
if (objXmlMetatype.InnerXml.Contains("bonus"))
objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, objXmlMetatype["name"].InnerText, objXmlMetatype.SelectSingleNode("bonus"), false, 1, objXmlMetatype["name"].InnerText);
// Create the Qualities that come with the Metatype.
foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality"))
{
XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";
if (objXmlQualityItem.Attributes["select"] != null)
strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
QualitySource objSource = new QualitySource();
objSource = QualitySource.Metatype;
if (objXmlQualityItem.Attributes["removable"] != null)
objSource = QualitySource.MetatypeRemovable;
objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
_objCharacter.Qualities.Add(objQuality);
}
foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality"))
{
XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";
if (objXmlQualityItem.Attributes["select"] != null)
strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
QualitySource objSource = new QualitySource();
objSource = QualitySource.Metatype;
if (objXmlQualityItem.Attributes["removable"] != null)
示例15: MetatypeSelected
//.........这里部分代码省略.........
_objCharacter.AGI.AssignLimits("0", "0", "0");
_objCharacter.REA.AssignLimits("0", "0", "0");
_objCharacter.STR.AssignLimits("0", "0", "0");
_objCharacter.WIL.AssignLimits("0", "0", "0");
_objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
_objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
}
// If this is a Shapeshifter, a Metavariant must be selected. Default to Human if None is selected.
if (cboCategory.SelectedValue.ToString() == "Shapeshifter" && cboMetavariant.SelectedValue.ToString() == "None")
cboMetavariant.SelectedValue = "Human";
_objCharacter.Metatype = lstMetatypes.SelectedValue.ToString();
_objCharacter.MetatypeCategory = cboCategory.SelectedValue.ToString();
if (cboMetavariant.SelectedValue.ToString() == "None")
{
_objCharacter.Metavariant = "";
}
else
{
_objCharacter.Metavariant = cboMetavariant.SelectedValue.ToString();
}
if (objXmlMetatype["movement"] != null) // TODO: Replace with Walk/Run
_objCharacter.Movement = objXmlMetatype["movement"].InnerText;
// Load the Qualities file.
XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");
if (cboMetavariant.SelectedValue.ToString() == "None")
{
// Determine if the Metatype has any bonuses.
if (objXmlMetatype.InnerXml.Contains("bonus"))
objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, lstMetatypes.SelectedValue.ToString(), objXmlMetatype.SelectSingleNode("bonus"), false, 1, lstMetatypes.SelectedValue.ToString());
// Create the Qualities that come with the Metatype.
foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality"))
{
XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";
if (objXmlQualityItem.Attributes["select"] != null)
strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
QualitySource objSource = new QualitySource();
objSource = QualitySource.Metatype;
if (objXmlQualityItem.Attributes["removable"] != null)
objSource = QualitySource.MetatypeRemovable;
objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
objQuality.ContributeToLimit = false;
_objCharacter.Qualities.Add(objQuality);
// Add any created Weapons to the character.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
}
foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality"))
{
XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";