本文整理汇总了C#中Chummer.ImprovementManager.CreateImprovements方法的典型用法代码示例。如果您正苦于以下问题:C# ImprovementManager.CreateImprovements方法的具体用法?C# ImprovementManager.CreateImprovements怎么用?C# ImprovementManager.CreateImprovements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chummer.ImprovementManager
的用法示例。
在下文中一共展示了ImprovementManager.CreateImprovements方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCritter
//.........这里部分代码省略.........
objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0));
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["category"].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 = strCritterName;
objCharacter.MetatypeCategory = objXmlMetatype["category"].InnerText;
objCharacter.Metavariant = "";
objCharacter.MetatypeBP = 0;
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, strCritterName, objXmlMetatype.SelectSingleNode("bonus"), false, 1, strCritterName);
// 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);
// 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 = "";
if (objXmlQualityItem.Attributes["select"] != null)
示例2: mnuSpecialPossessInanimate_Click
//.........这里部分代码省略.........
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);
}
// Now that everything is done, save the merged character and open them.
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*";
string strShowFileName = "";
string[] strFile = _objCharacter.FileName.Split(Path.DirectorySeparatorChar);
strShowFileName = strFile[strFile.Length - 1];
if (strShowFileName == "")
strShowFileName = _objCharacter.Alias;
strShowFileName = strShowFileName.Replace(".chum5", string.Empty);
strShowFileName += " (" + LanguageManager.Instance.GetString("String_Possessed") + ")";
saveFileDialog.FileName = strShowFileName;
if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
{
objMerge.FileName = saveFileDialog.FileName;
objMerge.Save();
// Get the name of the file and destroy the references to the Vessel and the merged character.
string strOpenFile = objMerge.FileName;
objMerge = null;
GlobalOptions.Instance.MainForm.LoadCharacter(strOpenFile);
}
else
{
// The save process was canceled, so drop everything.
objMerge = null;
}
}
示例3: Create
/// Create a Metamagic from an XmlNode and return the TreeNodes for it.
/// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param>
/// <param name="objCharacter">Character the Gear is being added to.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="objSource">Source of the Improvement.</param>
/// <param name="blnCreateImprovements">Whether or not Improvements should be created.</param>
public void Create(XmlNode objXmlMetamagicNode, Character objCharacter, TreeNode objNode, Improvement.ImprovementSource objSource, bool blnCreateImprovements = true)
{
_guidExternalID = Guid.Parse(objXmlMetamagicNode["id"].InnerText);
_strName = objXmlMetamagicNode["name"].InnerText;
_strSource = objXmlMetamagicNode["source"].InnerText;
_strPage = objXmlMetamagicNode["page"].InnerText;
_objImprovementSource = objSource;
if (blnCreateImprovements)
{
_nodBonus = objXmlMetamagicNode["bonus"];
_nodConditional = objXmlMetamagicNode["conditional"];
int intRating = 1;
if (_objCharacter.SubmersionGrade > 0)
intRating = _objCharacter.SubmersionGrade;
else
intRating = _objCharacter.InitiateGrade;
ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodBonus, true, intRating, DisplayNameShort))
{
_guiID = Guid.Empty;
return;
}
if (objImprovementManager.SelectedValue != "")
_strName += " (" + objImprovementManager.SelectedValue + ")";
// Conditional Improvements.
if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodConditional, false, 1, DisplayNameShort, true))
{
_guiID = Guid.Empty;
return;
}
}
if (GlobalOptions.Instance.Language != "en-us")
{
string strXmlFile = "";
string strXPath = "";
if (_objImprovementSource == Improvement.ImprovementSource.Metamagic)
{
strXmlFile = "metamagic.xml";
strXPath = "/chummer/metamagics/metamagic";
}
else
{
strXmlFile = "echoes.xml";
strXPath = "/chummer/echoes/echo";
}
XmlDocument objXmlDocument = XmlManager.Instance.Load(strXmlFile);
XmlNode objMetamagicNode = objXmlDocument.SelectSingleNode(strXPath + "[id = \"" + ExternalId + "\"]");
if (objMetamagicNode != null)
{
if (objMetamagicNode["translate"] != null)
_strAltName = objMetamagicNode["translate"].InnerText;
if (objMetamagicNode["altpage"] != null)
_strAltPage = objMetamagicNode["altpage"].InnerText;
}
}
objNode.Text = DisplayName;
objNode.Tag = _guiID.ToString();
}
示例4: AcceptForm
/// <summary>
/// Accept the values on the Form and create the required XML data.
/// </summary>
private void AcceptForm()
{
// Make sure a value has been selected if necessary.
if (txtSelect.Visible && txtSelect.Text == string.Empty)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectItem"), LanguageManager.Instance.GetString("MessageTitle_SelectItem"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Make sure a value has been provided for the name.
if (txtName.Text == string.Empty)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_ImprovementName"), LanguageManager.Instance.GetString("MessageTitle_ImprovementName"), MessageBoxButtons.OK, MessageBoxIcon.Error);
txtName.Focus();
return;
}
MemoryStream objStream = new MemoryStream();
XmlWriter objWriter = XmlWriter.Create(objStream);
// Build the XML for the Improvement.
XmlNode objFetchNode = _objDocument.SelectSingleNode("/chummer/improvements/improvement[id = \"" + cboImprovemetType.SelectedValue + "\"]");
objWriter.WriteStartDocument();
// <bonus>
objWriter.WriteStartElement("bonus");
// <whatever element>
objWriter.WriteStartElement(objFetchNode["internal"].InnerText);
string strRating = "";
if (chkApplyToRating.Checked)
strRating = "<applytorating>yes</applytorating>";
// Retrieve the XML data from the document and replace the values as necessary.
string strXml = objFetchNode["xml"].InnerText;
strXml = strXml.Replace("{val}", nudVal.Value.ToString());
strXml = strXml.Replace("{min}", nudMin.Value.ToString());
strXml = strXml.Replace("{max}", nudMax.Value.ToString());
strXml = strXml.Replace("{aug}", nudAug.Value.ToString());
strXml = strXml.Replace("{select}", txtSelect.Text);
strXml = strXml.Replace("{applytorating}", strRating);
objWriter.WriteRaw(strXml);
// Write the rest of the document.
// </whatever element>
objWriter.WriteEndElement();
// </bonus>
objWriter.WriteEndElement();
objWriter.WriteEndDocument();
objWriter.Flush();
objStream.Flush();
objStream.Position = 0;
// Read it back in as an XmlDocument.
StreamReader objReader = new StreamReader(objStream);
XmlDocument objBonusXML = new XmlDocument();
string strXML = objReader.ReadToEnd();
objBonusXML.LoadXml(strXML);
objWriter.Close();
objStream.Close();
// Pluck out the bonus information.
XmlNode objNode = objBonusXML.SelectSingleNode("/bonus");
// Pass it to the Improvement Manager so that it can be added to the character.
ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
string strGuid = Guid.NewGuid().ToString();
objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Custom, strGuid, objNode, false, 1, txtName.Text);
// If an Improvement was passed in, remove it from the character.
string strNotes = "";
int intOrder = 0;
if (_objEditImprovement != null)
{
// Copy the notes over to the new item.
strNotes = _objEditImprovement.Notes;
intOrder = _objEditImprovement.SortOrder;
objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Custom, _objEditImprovement.SourceName);
}
// Find the newly-created Improvement and attach its custom name.
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.SourceName == strGuid)
{
objImprovement.CustomName = txtName.Text;
objImprovement.CustomId = cboImprovemetType.SelectedValue.ToString();
objImprovement.Custom = true;
objImprovement.Notes = strNotes;
objImprovement.SortOrder = intOrder;
}
}
this.DialogResult = DialogResult.OK;
}
示例5: Create
/// Create a Metamagic from an XmlNode and return the TreeNodes for it.
/// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param>
/// <param name="objCharacter">Character the Gear is being added to.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="objSource">Source of the Improvement.</param>
public void Create(XmlNode objXmlMetamagicNode, Character objCharacter, TreeNode objNode, Improvement.ImprovementSource objSource)
{
_strName = objXmlMetamagicNode["name"].InnerText;
_strSource = objXmlMetamagicNode["source"].InnerText;
_strPage = objXmlMetamagicNode["page"].InnerText;
_objImprovementSource = objSource;
try
{
_intGrade = Convert.ToInt32(objXmlMetamagicNode["grade"].InnerText);
}
catch { }
if (objXmlMetamagicNode.InnerXml.Contains("<bonus>"))
{
_nodBonus = objXmlMetamagicNode["bonus"];
int intRating = 1;
if (_objCharacter.SubmersionGrade > 0)
intRating = _objCharacter.SubmersionGrade;
else
intRating = _objCharacter.InitiateGrade;
ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodBonus, true, intRating, DisplayNameShort))
{
_guiID = Guid.Empty;
return;
}
if (objImprovementManager.SelectedValue != "")
_strName += " (" + objImprovementManager.SelectedValue + ")";
}
LanguageManager.Instance.Load(GlobalOptions.Instance.Language, null);
if (_objCharacter.SubmersionGrade > 0)
objNode.Text = LanguageManager.Instance.GetString("Label_Echo") + " " + DisplayName;
else
objNode.Text = LanguageManager.Instance.GetString("Label_Metamagic") + " " + DisplayName;
objNode.Tag = _guiID.ToString();
}
示例6: 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)
示例7: cmdOK_Click
private void cmdOK_Click(object sender, EventArgs e)
{
// Make sure that each Priority has only been selected once.
bool blnValid = true;
if (cboPriorityMetatype.SelectedValue == cboPriorityAttributes.SelectedValue)
blnValid = false;
if (cboPriorityMetatype.SelectedValue == cboPrioritySpecial.SelectedValue)
blnValid = false;
if (cboPriorityMetatype.SelectedValue == cboPrioritySkills.SelectedValue)
blnValid = false;
if (cboPriorityMetatype.SelectedValue == cboPriorityNuyen.SelectedValue)
blnValid = false;
if (cboPriorityAttributes.SelectedValue == cboPrioritySpecial.SelectedValue)
blnValid = false;
if (cboPriorityAttributes.SelectedValue == cboPrioritySkills.SelectedValue)
blnValid = false;
if (cboPriorityAttributes.SelectedValue == cboPriorityNuyen.SelectedValue)
blnValid = false;
if (cboPrioritySpecial.SelectedValue == cboPrioritySkills.SelectedValue)
blnValid = false;
if (cboPrioritySpecial.SelectedValue == cboPriorityNuyen.SelectedValue)
blnValid = false;
if (cboPrioritySkills.SelectedValue == cboPriorityNuyen.SelectedValue)
blnValid = false;
if (!blnValid)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_Priorities_UniquePriorities"), LanguageManager.Instance.GetString("MessageTitle_Priorities_UniquePriorities"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
// Determine the number of Special Attribute points that come from the selected Metatype.
XmlNode objXmlMetatypesNode = _objXmlDocument.SelectSingleNode("/chummer/priorities/metatypes/metatype[priority = \"" + cboPriorityMetatype.SelectedValue.ToString() + "\"]");
XmlNode objXmlMetatypeNode = objXmlMetatypesNode.SelectSingleNode("metatypes/metatype[id = \"" + cboMetatype.SelectedValue.ToString() + "\"]");
int intSpecialAttributePoints = Convert.ToInt32(objXmlMetatypeNode["points"].InnerText);
// Determine the number of Attribute Points selected.
XmlNode objXmlAttributeNode = _objXmlDocument.SelectSingleNode("/chummer/priorities/attributes/attribute[priority = \"" + cboPriorityAttributes.SelectedValue.ToString() + "\"]");
int intAttributePoints = Convert.ToInt32(objXmlAttributeNode["points"].InnerText);
// Determine if the character gets anything from their Special Priority.
if (cboSpecial.SelectedValue != null)
{
if (cboSpecial.SelectedValue.ToString() != string.Empty)
{
XmlNode objXmlSpecialNode = _objXmlDocument.SelectSingleNode("/chummer/priorities/specials/special[priority = \"" + cboPrioritySpecial.SelectedValue.ToString() + "\"]/" + cboSpecial.SelectedValue.ToString());
if (objXmlSpecialNode["bonus"] != null)
{
ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Priority, "Priority", objXmlSpecialNode["bonus"]);
}
}
}
// Determine the number of Skill Points selected.
// Determine the amount of Nuyen selected.
XmlNode objXmlNuyenNode = _objXmlDocument.SelectSingleNode("/chummer/priorities/resources/resource[priority = \"" + cboPriorityNuyen.SelectedValue.ToString() + "\"]");
int intNuyen = Convert.ToInt32(objXmlNuyenNode["nuyen"].InnerText);
// Load the Metatype and set the character build information.
_objCharacter.LoadMetatype(Guid.Parse(cboMetatype.SelectedValue.ToString()));
_objCharacter.SpecialAttributePoints = intSpecialAttributePoints;
_objCharacter.AttributePoints = intAttributePoints;
_objCharacter.Nuyen = intNuyen;
this.DialogResult = DialogResult.OK;
}
}
示例8: 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 = "";
示例9: LoadMetatype
/// <summary>
/// Load the character's Metatype information from the XML file.
/// </summary>
/// <param name="guiMetatype">GUID of the Metatype to load.</param>
/// <param name="strXmlFile">Name of the XML file to load from (default: metatypes.xml).</param>
/// <param name="intForce">Force that the Spirit was summoned with (default: 0).</param>
/// <param name="blnBloodSpirit">Whether or not this character is a Blood Spirit (default: false).</param>
/// <param name="blnPossessionBased">Whether or not this Spirit uses a Possession-based tradition (default: false).</param>
/// <param name="strPossessionMethod">Possession method the Spirit uses (default: empty).</param>
public void LoadMetatype(Guid guiMetatype, string strXmlFile = "metatypes.xml", int intForce = 0, bool blnBloodSpirit = false, bool blnPossessionBased = false, string strPossessionMethod = "")
{
ImprovementManager objImprovementManager = new ImprovementManager(this);
XmlDocument objXmlDocument = XmlManager.Instance.Load(strXmlFile);
XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[id = \"" + guiMetatype.ToString() + "\"]");
_guiMetatype = guiMetatype;
// Set Metatype information.
if (strXmlFile != "critters.xml")
{
BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0));
AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0));
REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0));
STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0));
CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0));
INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0));
LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0));
WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0));
MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0));
RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0));
EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0));
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;
BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3));
AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3));
REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3));
STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3));
CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3));
INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3));
LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3));
WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3));
MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3));
RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3));
EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3));
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.
if (strXmlFile == "critters.xml")
{
BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0));
AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0));
REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0));
STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0));
CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0));
INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0));
LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0));
WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0));
MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0));
RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0));
EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0));
ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0));
}
// Sprites can never have Physical Attributes or WIL.
if (objXmlMetatype["category"].InnerText.EndsWith("Sprite"))
{
BOD.AssignLimits("0", "0", "0");
AGI.AssignLimits("0", "0", "0");
REA.AssignLimits("0", "0", "0");
STR.AssignLimits("0", "0", "0");
WIL.AssignLimits("0", "0", "0");
}
Metatype = objXmlMetatype["name"].InnerText;
MetatypeCategory = objXmlMetatype["category"].InnerText;
Metavariant = "";
MetatypeBP = 0;
_intWalk = Convert.ToInt32(objXmlMetatype["walk"].InnerText);
_intRun = Convert.ToInt32(objXmlMetatype["run"].InnerText);
_intSprint = Convert.ToInt32(objXmlMetatype["sprint"].InnerText);
// Load the Qualities file.
XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");
// Determine if the Metatype has any bonuses.
if (objXmlMetatype["bonus"] != null)
objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, Metatype, objXmlMetatype.SelectSingleNode("bonus"), false, 1, Metatype);
// Create the Qualities that come with the Metatype.
foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality"))
{
XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + objXmlQualityItem.InnerText + "\"]");
//.........这里部分代码省略.........
示例10: Create
/// <summary>
/// Create a Quality from an XmlNode and return the TreeNodes for it.
/// </summary>
/// <param name="objXmlQuality">XmlNode to create the object from.</param>
/// <param name="objCharacter">Character object the Quality will be added to.</param>
/// <param name="objQualitySource">Source of the Quality.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="objWeapons">List of Weapons that should be added to the Character.</param>
/// <param name="objWeaponNodes">List of TreeNodes to represent the Weapons added.</param>
/// <param name="strForceValue">Force a value to be selected for the Quality.</param>
public void Create(XmlNode objXmlQuality, Character objCharacter, QualitySource objQualitySource, TreeNode objNode, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, string strForceValue = "")
{
_strName = objXmlQuality["name"].InnerText;
_intBP = Convert.ToInt32(objXmlQuality["karma"].InnerText);
_objQualityType = ConvertToQualityType(objXmlQuality["category"].InnerText);
_objQualitySource = objQualitySource;
if (objXmlQuality["print"] != null)
{
if (objXmlQuality["print"].InnerText == "no")
_blnPrint = false;
}
if (objXmlQuality["contributetolimit"] != null)
{
if (objXmlQuality["contributetolimit"].InnerText == "no")
_blnContributeToLimit = false;
}
_strSource = objXmlQuality["source"].InnerText;
_strPage = objXmlQuality["page"].InnerText;
if (objXmlQuality["mutant"] != null)
_strMutant = "yes";
if (GlobalOptions.Instance.Language != "en-us")
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
XmlNode objQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
if (objQualityNode != null)
{
if (objQualityNode["translate"] != null)
_strAltName = objQualityNode["translate"].InnerText;
if (objQualityNode["altpage"] != null)
_strAltPage = objQualityNode["altpage"].InnerText;
}
}
// Add Weapons if applicable.
if (objXmlQuality.InnerXml.Contains("<addweapon>"))
{
XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");
// More than one Weapon can be added, so loop through all occurrences.
foreach (XmlNode objXmlAddWeapon in objXmlQuality.SelectNodes("addweapon"))
{
XmlNode objXmlWeapon = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlAddWeapon.InnerText + "\" and starts-with(category, \"Quality\")]");
TreeNode objGearWeaponNode = new TreeNode();
Weapon objGearWeapon = new Weapon(objCharacter);
objGearWeapon.Create(objXmlWeapon, objCharacter, objGearWeaponNode, null, null, null);
objGearWeaponNode.ForeColor = SystemColors.GrayText;
objWeaponNodes.Add(objGearWeaponNode);
objWeapons.Add(objGearWeapon);
_guiWeaponID = Guid.Parse(objGearWeapon.InternalId);
}
}
// If the item grants a bonus, pass the information to the Improvement Manager.
if (objXmlQuality.InnerXml.Contains("<bonus>"))
{
ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
objImprovementManager.ForcedValue = strForceValue;
if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Quality, _guiID.ToString(), objXmlQuality["bonus"], false, 1, DisplayNameShort))
{
_guiID = Guid.Empty;
return;
}
if (objImprovementManager.SelectedValue != "")
{
_strExtra = objImprovementManager.SelectedValue;
objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
}
}
// Metatype Qualities appear as grey text to show that they cannot be removed.
if (objQualitySource == QualitySource.Metatype || objQualitySource == QualitySource.MetatypeRemovable)
objNode.ForeColor = SystemColors.GrayText;
objNode.Text = DisplayName;
objNode.Tag = InternalId;
}
示例11: 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 = "";
示例12: Create
/// <summary>
/// Create a LifestyleQuality from an XmlNode and return the TreeNodes for it.
/// </summary>
/// <param name="objXmlLifestyleQuality">XmlNode to create the object from.</param>
/// <param name="objCharacter">Character object the LifestyleQuality will be added to.</param>
/// <param name="objLifestyleQualitySource">Source of the LifestyleQuality.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="objWeapons">List of Weapons that should be added to the Character.</param>
/// <param name="objWeaponNodes">List of TreeNodes to represent the Weapons added.</param>
/// <param name="strForceValue">Force a value to be selected for the LifestyleQuality.</param>
public void Create(XmlNode objXmlLifestyleQuality, Character objCharacter, QualitySource objLifestyleQualitySource, TreeNode objNode)
{
_strName = objXmlLifestyleQuality["name"].InnerText;
_intLP = Convert.ToInt32(objXmlLifestyleQuality["lp"].InnerText);
try
{
_intCost = Convert.ToInt32(objXmlLifestyleQuality["cost"].InnerText);
}
catch
{}
_objLifestyleQualityType = ConvertToLifestyleQualityType(objXmlLifestyleQuality["category"].InnerText);
_objLifestyleQualitySource = objLifestyleQualitySource;
if (objXmlLifestyleQuality["print"] != null)
{
if (objXmlLifestyleQuality["print"].InnerText == "no")
_blnPrint = false;
}
if (objXmlLifestyleQuality["contributetolimit"] != null)
{
if (objXmlLifestyleQuality["contributetolimit"].InnerText == "no")
_blnContributeToLimit = false;
}
_strSource = objXmlLifestyleQuality["source"].InnerText;
_strPage = objXmlLifestyleQuality["page"].InnerText;
if (GlobalOptions.Instance.Language != "en-us")
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");
XmlNode objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/LifestyleQuality[name = \"" + _strName + "\"]");
if (objLifestyleQualityNode != null)
{
if (objLifestyleQualityNode["translate"] != null)
_strAltName = objLifestyleQualityNode["translate"].InnerText;
if (objLifestyleQualityNode["altpage"] != null)
_strAltPage = objLifestyleQualityNode["altpage"].InnerText;
}
}
// If the item grants a bonus, pass the information to the Improvement Manager.
if (objXmlLifestyleQuality.InnerXml.Contains("<bonus>"))
{
ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Quality, _guiID.ToString(), objXmlLifestyleQuality["bonus"], false, 1, DisplayNameShort))
{
_guiID = Guid.Empty;
return;
}
if (objImprovementManager.SelectedValue != "")
{
_strExtra = objImprovementManager.SelectedValue;
objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
}
}
objNode.Text = DisplayName;
objNode.Tag = InternalId;
}
示例13: Create
/// Create a Metamagic from an XmlNode and return the TreeNodes for it.
/// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param>
/// <param name="objCharacter">Character the Gear is being added to.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="objSource">Source of the Improvement.</param>
public void Create(XmlNode objXmlMetamagicNode, Character objCharacter, TreeNode objNode, Improvement.ImprovementSource objSource)
{
_strName = objXmlMetamagicNode["name"].InnerText;
_strSource = objXmlMetamagicNode["source"].InnerText;
_strPage = objXmlMetamagicNode["page"].InnerText;
_objImprovementSource = objSource;
if (objXmlMetamagicNode.InnerXml.Contains("<bonus>"))
{
_nodBonus = objXmlMetamagicNode["bonus"];
int intRating = 1;
if (_objCharacter.SubmersionGrade > 0)
intRating = _objCharacter.SubmersionGrade;
else
intRating = _objCharacter.InitiateGrade;
ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodBonus, true, intRating, DisplayNameShort))
{
_guiID = Guid.Empty;
return;
}
if (objImprovementManager.SelectedValue != "")
_strName += " (" + objImprovementManager.SelectedValue + ")";
}
objNode.Text = DisplayName;
objNode.Tag = _guiID.ToString();
}