本文整理汇总了C#中Gear.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Gear.Create方法的具体用法?C# Gear.Create怎么用?C# Gear.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gear
的用法示例。
在下文中一共展示了Gear.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: tsWeaponAccessoryGearMenuAddAsPlugin_Click
private void tsWeaponAccessoryGearMenuAddAsPlugin_Click(object sender, EventArgs e)
{
// Locate the Vehicle Sensor Gear.
bool blnFound = false;
WeaponAccessory objFoundAccessory = new WeaponAccessory(_objCharacter);
Gear objSensor = (Gear)_objFunctions.FindEquipment(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, typeof(Gear));
if (objSensor != null)
blnFound = true;
if (objSensor.Parent != null)
objFoundAccessory = (WeaponAccessory)objSensor.Parent;
// Make sure the Gear was found.
if (!blnFound)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_ModifyVehicleGear"), LanguageManager.Instance.GetString("MessageTitle_SelectGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[id = \"" + objSensor.ExternalId + "\"]");
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter);
//frmPickGear.ShowNegativeCapacityOnly = true;
if (objXmlGear["addoncategory"] != null)
{
string strCategories = "";
foreach (XmlNode objXmlCategory in objXmlGear.SelectNodes("addoncategory"))
strCategories += objXmlCategory.InnerText + ",";
// Remove the trailing comma.
strCategories = strCategories.Substring(0, strCategories.Length - 1);
frmPickGear.AddCategory(strCategories);
}
if (frmPickGear.AllowedCategories != "")
frmPickGear.AllowedCategories += objSensor.Category + ",";
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
// Open the Gear XML file and locate the selected piece.
objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[id = \"" + frmPickGear.SelectedGear + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
TreeNode objNode = new TreeNode();
Gear objGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlink":
case "Commlink Upgrade":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
objCommlink.Quantity = frmPickGear.SelectedQty;
objNode.Text = objCommlink.DisplayName;
objGear = objCommlink;
break;
case "Commlink Operating System":
case "Commlink Operating System Upgrade":
OperatingSystem objOperatingSystem = new OperatingSystem(_objCharacter);
objOperatingSystem.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
objOperatingSystem.Quantity = frmPickGear.SelectedQty;
objNode.Text = objOperatingSystem.DisplayName;
objGear = objOperatingSystem;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, true, true, frmPickGear.Aerodynamic);
objNewGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objNewGear.DisplayName;
objGear = objNewGear;
break;
}
if (objGear.InternalId == Guid.Empty.ToString())
return;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objGear.Cost = (Convert.ToDouble(objGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Reduce the cost to 10% for Hacked programs.
if (frmPickGear.Hacked)
{
if (objGear.Cost != "")
objGear.Cost = "(" + objGear.Cost + ") * 0.1";
if (objGear.Cost3 != "")
objGear.Cost3 = "(" + objGear.Cost3 + ") * 0.1";
if (objGear.Cost6 != "")
objGear.Cost6 = "(" + objGear.Cost6 + ") * 0.1";
if (objGear.Cost10 != "")
objGear.Cost10 = "(" + objGear.Cost10 + ") * 0.1";
//.........这里部分代码省略.........
示例2: tsWeaponAccessoryGearMenuAddAsPlugin_Click
private void tsWeaponAccessoryGearMenuAddAsPlugin_Click(object sender, EventArgs e)
{
// Locate the Vehicle Sensor Gear.
bool blnFound = false;
WeaponAccessory objFoundAccessory = new WeaponAccessory(_objCharacter);
Gear objSensor = _objFunctions.FindWeaponGear(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, out objFoundAccessory);
if (objSensor != null)
blnFound = true;
// Make sure the Gear was found.
if (!blnFound)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_ModifyVehicleGear"), LanguageManager.Instance.GetString("MessageTitle_SelectGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSensor.Name + "\" and category = \"" + objSensor.Category + "\"]");
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true);
//frmPickGear.ShowNegativeCapacityOnly = true;
if (objXmlGear.InnerXml.Contains("<addoncategory>"))
{
string strCategories = "";
foreach (XmlNode objXmlCategory in objXmlGear.SelectNodes("addoncategory"))
strCategories += objXmlCategory.InnerText + ",";
// Remove the trailing comma.
strCategories = strCategories.Substring(0, strCategories.Length - 1);
frmPickGear.AddCategory(strCategories);
}
if (frmPickGear.AllowedCategories != "")
frmPickGear.AllowedCategories += objSensor.Category + ",";
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
// Open the Gear XML file and locate the selected piece.
objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
TreeNode objNode = new TreeNode();
Gear objGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
objCommlink.Quantity = frmPickGear.SelectedQty;
objNode.Text = objCommlink.DisplayName;
objGear = objCommlink;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, true, true, frmPickGear.Aerodynamic);
objNewGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objNewGear.DisplayName;
objGear = objNewGear;
break;
}
if (objGear.InternalId == Guid.Empty.ToString())
return;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objGear.Cost = (Convert.ToDouble(objGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Reduce the cost to 10% for Hacked programs.
if (frmPickGear.Hacked)
{
if (objGear.Cost != "")
objGear.Cost = "(" + objGear.Cost + ") * 0.1";
if (objGear.Cost3 != "")
objGear.Cost3 = "(" + objGear.Cost3 + ") * 0.1";
if (objGear.Cost6 != "")
objGear.Cost6 = "(" + objGear.Cost6 + ") * 0.1";
if (objGear.Cost10 != "")
objGear.Cost10 = "(" + objGear.Cost10 + ") * 0.1";
if (objGear.Extra == "")
objGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
else
objGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
}
// If the item was marked as free, change its cost.
if (frmPickGear.FreeCost)
{
objGear.Cost = "0";
objGear.Cost3 = "0";
objGear.Cost6 = "0";
//.........这里部分代码省略.........
示例3: tsCyberwareAddGear_Click
private void tsCyberwareAddGear_Click(object sender, EventArgs e)
{
// Make sure a parent items is selected, then open the Select Gear window.
try
{
if (treCyberware.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectCyberware"), LanguageManager.Instance.GetString("MessageTitle_SelectCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectCyberware"), LanguageManager.Instance.GetString("MessageTitle_SelectCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Cyberware objCyberware = new Cyberware(_objCharacter);
foreach (Cyberware objCharacterCyberware in _objCharacter.Cyberware)
{
if (objCharacterCyberware.InternalId == treCyberware.SelectedNode.Tag.ToString())
{
objCyberware = objCharacterCyberware;
break;
}
foreach (Cyberware objChild in objCharacterCyberware.Cyberwares)
{
if (objChild.InternalId == treCyberware.SelectedNode.Tag.ToString())
{
objCyberware = objChild;
break;
}
}
}
// Make sure the Cyberware is allowed to accept Gear.
if (objCyberware.AllowGear == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberwareGear"), LanguageManager.Instance.GetString("MessageTitle_CyberwareGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, false);
string strCategories = "";
foreach (XmlNode objXmlCategory in objCyberware.AllowGear)
strCategories += objXmlCategory.InnerText + ",";
frmPickGear.AllowedCategories = strCategories;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
TreeNode objNode = new TreeNode();
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[id = \"" + frmPickGear.SelectedGear + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Gear objNewGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlink":
case "Commlink Upgrade":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
objCommlink.Quantity = frmPickGear.SelectedQty;
try
{
_blnSkipRefresh = true;
nudGearQty.Increment = objCommlink.CostFor;
//nudGearQty.Minimum = nudGearQty.Increment;
_blnSkipRefresh = false;
}
catch
{
}
objNode.Text = objCommlink.DisplayName;
objNewGear = objCommlink;
break;
case "Commlink Operating System":
case "Commlink Operating System Upgrade":
OperatingSystem objOperatingSystem = new OperatingSystem(_objCharacter);
objOperatingSystem.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
objOperatingSystem.Quantity = frmPickGear.SelectedQty;
try
{
_blnSkipRefresh = true;
nudGearQty.Increment = objOperatingSystem.CostFor;
//nudGearQty.Minimum = nudGearQty.Increment;
_blnSkipRefresh = false;
}
catch
{
}
objNode.Text = objOperatingSystem.DisplayName;
//.........这里部分代码省略.........
示例4: tsVehicleAddGear_Click
private void tsVehicleAddGear_Click(object sender, EventArgs e)
{
// Make sure a parent items is selected, then open the Select Gear window.
try
{
if (treVehicles.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (treVehicles.SelectedNode.Level > 1)
treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;
// Locate the selected Vehicle.
Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter);
//frmPickGear.ShowPositiveCapacityOnly = true;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
TreeNode objNode = new TreeNode();
Gear objGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objCommlink.Quantity = frmPickGear.SelectedQty;
objGear = objCommlink;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, false, true, frmPickGear.Aerodynamic);
objNewGear.Quantity = frmPickGear.SelectedQty;
objGear = objNewGear;
break;
}
if (objGear.InternalId == Guid.Empty.ToString())
return;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objGear.Cost = (Convert.ToDouble(objGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Reduce the cost to 10% for Hacked programs.
if (frmPickGear.Hacked)
{
if (objGear.Cost != "")
objGear.Cost = "(" + objGear.Cost + ") * 0.1";
if (objGear.Cost3 != "")
objGear.Cost3 = "(" + objGear.Cost3 + ") * 0.1";
if (objGear.Cost6 != "")
objGear.Cost6 = "(" + objGear.Cost6 + ") * 0.1";
if (objGear.Cost10 != "")
objGear.Cost10 = "(" + objGear.Cost10 + ") * 0.1";
if (objGear.Extra == "")
objGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
else
objGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
}
// If the item was marked as free, change its cost.
if (frmPickGear.FreeCost)
{
objGear.Cost = "0";
objGear.Cost3 = "0";
objGear.Cost6 = "0";
objGear.Cost10 = "0";
}
objGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objGear.DisplayName;
try
{
nudVehicleRating.Increment = objGear.CostFor;
nudVehicleRating.Minimum = nudGearQty.Increment;
}
catch
{
//.........这里部分代码省略.........
示例5: 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 + "\"]");
//.........这里部分代码省略.........
示例6: PickArmorGear
//.........这里部分代码省略.........
strCategories += objXmlCategory.InnerText + ",";
// Remove the trailing comma.
strCategories = strCategories.Substring(0, strCategories.Length - 1);
frmPickGear.AddCategory(strCategories);
}
}
}
catch
{
}
frmPickGear.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickGear.DialogResult == DialogResult.Cancel)
return false;
TreeNode objNode = new TreeNode();
// Open the Cyberware XML file and locate the selected piece.
objXmlDocument = XmlManager.Instance.Load("gear.xml");
objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Gear objNewGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
objCommlink.Quantity = frmPickGear.SelectedQty;
try
{
nudGearQty.Increment = objCommlink.CostFor;
//nudGearQty.Minimum = nudGearQty.Increment;
}
catch
{
}
objNewGear = objCommlink;
break;
default:
Gear objGear = new Gear(_objCharacter);
objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", false, false, true, true, frmPickGear.Aerodynamic);
objGear.Quantity = frmPickGear.SelectedQty;
try
{
nudGearQty.Increment = objGear.CostFor;
//nudGearQty.Minimum = nudGearQty.Increment;
}
catch
{
}
objNewGear = objGear;
break;
}
if (objNewGear.InternalId == Guid.Empty.ToString())
return false;
示例7: ChangeVehicleSensor
/// <summary>
/// Change the size of a Vehicle's Sensor
/// </summary>
/// <param name="objVehicle">Vehicle to modify.</param>
/// <param name="blnIncrease">True if the Sensor should increase in size, False if it should decrease.</param>
private void ChangeVehicleSensor(Vehicle objVehicle, bool blnIncrease)
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objNewNode;
bool blnFound = false;
Gear objSensor = new Gear(_objCharacter);
Gear objNewSensor = new Gear(_objCharacter);
TreeNode objTreeNode = new TreeNode();
List<Weapon> lstWeapons = new List<Weapon>();
List<TreeNode> lstWeaponNodes = new List<TreeNode>();
foreach (Gear objCurrentGear in objVehicle.Gear)
{
if (objCurrentGear.Name == "Microdrone Sensor")
{
if (blnIncrease)
{
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Minidrone Sensor\" and category = \"Sensors\"]");
objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
objSensor = objCurrentGear;
blnFound = true;
}
break;
}
else if (objCurrentGear.Name == "Minidrone Sensor")
{
if (blnIncrease)
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Small Drone Sensor\" and category = \"Sensors\"]");
else
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Microdrone Sensor\" and category = \"Sensors\"]");
objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
objSensor = objCurrentGear;
blnFound = true;
break;
}
else if (objCurrentGear.Name == "Small Drone Sensor")
{
if (blnIncrease)
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Medium Drone Sensor\" and category = \"Sensors\"]");
else
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Minidrone Sensor\" and category = \"Sensors\"]");
objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
objSensor = objCurrentGear;
blnFound = true;
break;
}
else if (objCurrentGear.Name == "Medium Drone Sensor")
{
if (blnIncrease)
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Large Drone Sensor\" and category = \"Sensors\"]");
else
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Small Drone Sensor\" and category = \"Sensors\"]");
objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
objSensor = objCurrentGear;
blnFound = true;
break;
}
else if (objCurrentGear.Name == "Large Drone Sensor")
{
if (blnIncrease)
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Vehicle Sensor\" and category = \"Sensors\"]");
else
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Medium Drone Sensor\" and category = \"Sensors\"]");
objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
objSensor = objCurrentGear;
blnFound = true;
break;
}
else if (objCurrentGear.Name == "Vehicle Sensor")
{
if (blnIncrease)
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Extra-Large Vehicle Sensor\" and category = \"Sensors\"]");
else
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Large Drone Sensor\" and category = \"Sensors\"]");
objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
objSensor = objCurrentGear;
blnFound = true;
break;
}
else if (objCurrentGear.Name == "Extra-Large Vehicle Sensor")
{
if (!blnIncrease)
{
objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Vehicle Sensor\" and category = \"Sensors\"]");
objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
objSensor = objCurrentGear;
blnFound = true;
}
break;
}
}
// If the item was found, update the Vehicle Sensor information.
if (blnFound)
//.........这里部分代码省略.........
示例8: 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 = "";
示例9: tsVehicleAddGear_Click
private void tsVehicleAddGear_Click(object sender, EventArgs e)
{
// Make sure a parent items is selected, then open the Select Gear window.
try
{
if (treVehicles.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (treVehicles.SelectedNode.Level > 1)
treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;
// Locate the selected Vehicle.
Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true);
frmPickGear.ShowPositiveCapacityOnly = true;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
TreeNode objNode = new TreeNode();
Gear objGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlink":
case "Commlink Upgrade":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objCommlink.Quantity = frmPickGear.SelectedQty;
objGear = objCommlink;
break;
case "Commlink Operating System":
case "Commlink Operating System Upgrade":
OperatingSystem objOperatingSystem = new OperatingSystem(_objCharacter);
objOperatingSystem.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objOperatingSystem.Quantity = frmPickGear.SelectedQty;
objGear = objOperatingSystem;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, false, true, frmPickGear.Aerodynamic);
objNewGear.Quantity = frmPickGear.SelectedQty;
objGear = objNewGear;
break;
}
if (objGear.InternalId == Guid.Empty.ToString())
return;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objGear.Cost = (Convert.ToDouble(objGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Reduce the cost to 10% for Hacked programs.
if (frmPickGear.Hacked)
{
if (objGear.Cost != "")
objGear.Cost = "(" + objGear.Cost + ") * 0.1";
if (objGear.Cost3 != "")
objGear.Cost3 = "(" + objGear.Cost3 + ") * 0.1";
if (objGear.Cost6 != "")
objGear.Cost6 = "(" + objGear.Cost6 + ") * 0.1";
if (objGear.Cost10 != "")
objGear.Cost10 = "(" + objGear.Cost10 + ") * 0.1";
if (objGear.Extra == "")
objGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
else
objGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
}
// If the item was marked as free, change its cost.
if (frmPickGear.FreeCost)
{
objGear.Cost = "0";
objGear.Cost3 = "0";
objGear.Cost6 = "0";
objGear.Cost10 = "0";
}
objGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objGear.DisplayName;
//.........这里部分代码省略.........
示例10: TestGear
private void TestGear()
{
Character objCharacter = new Character();
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
pgbProgress.Minimum = 0;
pgbProgress.Value = 0;
pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/gears/gear").Count;
// Gear.
foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/gears/gear"))
{
pgbProgress.Value++;
Application.DoEvents();
try
{
TreeNode objTempNode = new TreeNode();
Gear objTemp = new Gear(objCharacter);
List<Weapon> lstWeapons = new List<Weapon>();
List<TreeNode> lstNodes = new List<TreeNode>();
objTemp.Create(objXmlGear, objCharacter, objTempNode, 1, lstWeapons, lstNodes, "Blades");
try
{
int objValue = objTemp.TotalCost;
}
catch
{
if (objXmlGear["category"].InnerText != "Mook")
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
}
try
{
string objValue = objTemp.TotalAvail();
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n";
}
try
{
string objValue = objTemp.CalculatedArmorCapacity;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedArmorCapacity\n";
}
try
{
string objValue = objTemp.CalculatedCapacity;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCapacity\n";
}
try
{
int objValue = objTemp.CalculatedCost;
}
catch
{
if (objXmlGear["category"].InnerText != "Mook")
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCost\n";
}
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
}
}
}
示例11: 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)
示例12: 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 = "";
示例13: tsVehicleWeaponAccessoryAddGear_Click
private void tsVehicleWeaponAccessoryAddGear_Click(object sender, EventArgs e)
{
WeaponAccessory objAccessory = (WeaponAccessory)_objFunctions.FindEquipment(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, typeof(WeaponAccessory));
// Make sure the Weapon Accessory is allowed to accept Gear.
if (objAccessory.AllowGear == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_WeaponGear"), LanguageManager.Instance.GetString("MessageTitle_CyberwareGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true);
string strCategories = "";
foreach (XmlNode objXmlCategory in objAccessory.AllowGear)
strCategories += objXmlCategory.InnerText + ",";
frmPickGear.AllowedCategories = strCategories;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
TreeNode objNode = new TreeNode();
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[id = \"" + frmPickGear.SelectedGear + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Gear objNewGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlink":
case "Commlink Upgrade":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objCommlink.Quantity = frmPickGear.SelectedQty;
objNode.Text = objCommlink.DisplayName;
objNewGear = objCommlink;
break;
case "Commlink Operating System":
case "Commlink Operating System Upgrade":
OperatingSystem objOperatingSystem = new OperatingSystem(_objCharacter);
objOperatingSystem.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objOperatingSystem.Quantity = frmPickGear.SelectedQty;
objNode.Text = objOperatingSystem.DisplayName;
objNewGear = objOperatingSystem;
break;
default:
Gear objGear = new Gear(_objCharacter);
objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, false, true, frmPickGear.Aerodynamic);
objGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objGear.DisplayName;
objNewGear = objGear;
break;
}
if (objNewGear.InternalId == Guid.Empty.ToString())
return;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objNewGear.Cost = (Convert.ToDouble(objNewGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Reduce the cost to 10% for Hacked programs.
if (frmPickGear.Hacked)
{
if (objNewGear.Cost != "")
objNewGear.Cost = "(" + objNewGear.Cost + ") * 0.1";
if (objNewGear.Cost3 != "")
objNewGear.Cost3 = "(" + objNewGear.Cost3 + ") * 0.1";
if (objNewGear.Cost6 != "")
objNewGear.Cost6 = "(" + objNewGear.Cost6 + ") * 0.1";
if (objNewGear.Cost10 != "")
objNewGear.Cost10 = "(" + objNewGear.Cost10 + ") * 0.1";
if (objNewGear.Extra == "")
objNewGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
else
objNewGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
}
// If the item was marked as free, change its cost.
if (frmPickGear.FreeCost)
{
objNewGear.Cost = "0";
objNewGear.Cost3 = "0";
objNewGear.Cost6 = "0";
objNewGear.Cost10 = "0";
}
int intCost = objNewGear.TotalCost;
// Check the item's Cost and make sure the character can afford it.
if (!frmPickGear.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
_objFunctions.DeleteGear(objNewGear, treWeapons, _objImprovementManager);
//.........这里部分代码省略.........
示例14: UpdateGearInfo
/// <summary>
/// Update the Gear's information based on the Gear selected and current Rating.
/// </summary>
private void UpdateGearInfo()
{
if (lstGear.Text != "")
{
// Retireve the information for the selected piece of Cyberware.
XmlNode objXmlGear;
int intItemCost = 0;
string strCategory = "";
objXmlGear = _objXmlDocument.SelectSingleNode("/chummer/gears/gear[id = \"" + lstGear.SelectedValue + "\"]");
strCategory = cboCategory.SelectedValue.ToString();
TreeNode objTreeNode = new TreeNode();
List<Weapon> lstWeapons = new List<Weapon>();
List<TreeNode> lstTreeNodes = new List<TreeNode>();
Gear objGear = new Gear(_objCharacter);
Commlink objCommlink = new Commlink(_objCharacter);
OperatingSystem objOperatingSystem = new OperatingSystem(_objCharacter);
if (objXmlGear["category"].InnerText == "Commlink" || objXmlGear["category"].InnerText == "Commlink Upgrade")
{
objCommlink.Create(objXmlGear, _objCharacter, objTreeNode, Convert.ToInt32(nudRating.Value), false, true);
objGear = (Gear)objCommlink;
}
else if (objXmlGear["category"].InnerText == "Operating System" || objXmlGear["category"].InnerText == "Operating System Upgrade")
{
objOperatingSystem.Create(objXmlGear, _objCharacter, objTreeNode, Convert.ToInt32(nudRating.Value), false, true);
objGear = (Gear)objCommlink;
}
else
objGear.Create(objXmlGear, _objCharacter, objTreeNode, Convert.ToInt32(nudRating.Value), lstWeapons, lstTreeNodes, "", chkHacked.Checked, false, false, true, chkAerodynamic.Checked);
if (_objCharacter.Metatype == "A.I." || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
{
if ((strCategory == "Matrix Programs" || strCategory == "Skillsofts" || strCategory == "Autosofts" || strCategory == "Autosofts, Agent" || strCategory == "Autosofts, Drone") && _objCharacter.Options.BookEnabled("UN") && !lstGear.SelectedValue.ToString().StartsWith("Suite:"))
chkInherentProgram.Visible = true;
else
chkInherentProgram.Visible = false;
chkInherentProgram.Enabled = !chkHacked.Checked;
if (!chkInherentProgram.Enabled)
chkInherentProgram.Checked = false;
}
else
chkInherentProgram.Visible = false;
if (objGear.GetType() == typeof(Commlink))
{
lblGearResponse.Text = objCommlink.TotalResponse.ToString();
lblGearSignal.Text = objCommlink.TotalSignal.ToString();
lblGearSystem.Text = "";
lblGearFirewall.Text = "";
}
else if (objGear.GetType() == typeof(OperatingSystem))
{
lblGearResponse.Text = "";
lblGearSignal.Text = "";
lblGearSystem.Text = objOperatingSystem.System.ToString();
lblGearFirewall.Text = objOperatingSystem.Firewall.ToString();
}
else
{
lblGearResponse.Text = "";
lblGearSignal.Text = "";
lblGearSystem.Text = "";
lblGearFirewall.Text = "";
}
if (objXmlGear["category"].InnerText.EndsWith("Software") || objXmlGear["category"].InnerText.EndsWith("Programs") || objXmlGear["category"].InnerText == "Program Options" || objXmlGear["category"].InnerText.StartsWith("Autosofts") || objXmlGear["category"].InnerText.StartsWith("Skillsoft") || objXmlGear["category"].InnerText == "Program Packages" || objXmlGear["category"].InnerText == "Software Suites")
chkHacked.Visible = true;
else
chkHacked.Visible = false;
string strBook = _objCharacter.Options.LanguageBookShort(objGear.Source);
string strPage = objGear.Page;
lblSource.Text = strBook + " " + strPage;
// Avail.
lblAvail.Text = objGear.TotalAvail();
double dblMultiplier = Convert.ToDouble(nudGearQty.Value / nudGearQty.Increment, GlobalOptions.Instance.CultureInfo);
if (chkDoItYourself.Checked)
dblMultiplier *= 0.5;
// Cost.
if (objGear.Cost.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objGear.Cost.Replace("Variable(", string.Empty).Replace(")", string.Empty);
if (strCost.Contains("-"))
{
string[] strValues = strCost.Split('-');
intMin = Convert.ToInt32(strValues[0]);
intMax = Convert.ToInt32(strValues[1]);
}
else
intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));
//.........这里部分代码省略.........
示例15: tsVehicleWeaponAccessoryAddGear_Click
private void tsVehicleWeaponAccessoryAddGear_Click(object sender, EventArgs e)
{
WeaponAccessory objAccessory = _objFunctions.FindVehicleWeaponAccessory(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
// Make sure the Weapon Accessory is allowed to accept Gear.
if (objAccessory.AllowGear == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_WeaponGear"), LanguageManager.Instance.GetString("MessageTitle_CyberwareGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, false);
string strCategories = "";
foreach (XmlNode objXmlCategory in objAccessory.AllowGear)
strCategories += objXmlCategory.InnerText + ",";
frmPickGear.AllowedCategories = strCategories;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
TreeNode objNode = new TreeNode();
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");
// Create the new piece of Gear.
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Gear objNewGear = new Gear(_objCharacter);
switch (frmPickGear.SelectedCategory)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objCommlink.Quantity = frmPickGear.SelectedQty;
try
{
_blnSkipRefresh = true;
nudGearQty.Increment = objCommlink.CostFor;
//nudGearQty.Minimum = nudGearQty.Increment;
_blnSkipRefresh = false;
}
catch
{
}
objNode.Text = objCommlink.DisplayName;
objNewGear = objCommlink;
break;
default:
Gear objGear = new Gear(_objCharacter);
objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, false, true, frmPickGear.Aerodynamic);
objGear.Quantity = frmPickGear.SelectedQty;
try
{
_blnSkipRefresh = true;
nudGearQty.Increment = objGear.CostFor;
//nudGearQty.Minimum = nudGearQty.Increment;
_blnSkipRefresh = false;
}
catch
{
}
objNode.Text = objGear.DisplayName;
objNewGear = objGear;
break;
}
if (objNewGear.InternalId == Guid.Empty.ToString())
return;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objNewGear.Cost = (Convert.ToDouble(objNewGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Reduce the cost to 10% for Hacked programs.
if (frmPickGear.Hacked)
{
if (objNewGear.Cost != "")
objNewGear.Cost = "(" + objNewGear.Cost + ") * 0.1";
if (objNewGear.Cost3 != "")
objNewGear.Cost3 = "(" + objNewGear.Cost3 + ") * 0.1";
if (objNewGear.Cost6 != "")
objNewGear.Cost6 = "(" + objNewGear.Cost6 + ") * 0.1";
if (objNewGear.Cost10 != "")
objNewGear.Cost10 = "(" + objNewGear.Cost10 + ") * 0.1";
if (objNewGear.Extra == "")
objNewGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
else
objNewGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
}
// If the item was marked as free, change its cost.
if (frmPickGear.FreeCost)
{
objNewGear.Cost = "0";
objNewGear.Cost3 = "0";
//.........这里部分代码省略.........