本文整理汇总了C#中WeaponAccessory.Create方法的典型用法代码示例。如果您正苦于以下问题:C# WeaponAccessory.Create方法的具体用法?C# WeaponAccessory.Create怎么用?C# WeaponAccessory.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeaponAccessory
的用法示例。
在下文中一共展示了WeaponAccessory.Create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: tsWeaponAddAccessory_Click
private void tsWeaponAddAccessory_Click(object sender, EventArgs e)
{
// Make sure a parent item is selected, then open the Select Accessory window.
try
{
if (treWeapons.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Locate the Weapon that is selected in the Tree.
Weapon objWeapon = _objFunctions.FindWeapon(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
// Accessories cannot be added to Cyberweapons.
if (objWeapon.Cyberware)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberweaponNoAccessory"), LanguageManager.Instance.GetString("MessageTitle_CyberweaponNoAccessory"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Open the Weapons XML file and locate the selected Weapon.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objWeapon.Name + "\"]");
frmSelectWeaponAccessory frmPickWeaponAccessory = new frmSelectWeaponAccessory(_objCharacter);
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotFindWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the Weapon allows Accessories to be added to it.
bool blnAllowAccessories = false;
if (objXmlWeapon["allowaccessory"] != null)
{
blnAllowAccessories = Convert.ToBoolean(objXmlWeapon["allowaccessory"].InnerText);
}
if (!blnAllowAccessories)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
XmlNodeList objXmlMountList = objXmlWeapon.SelectNodes("accessorymounts/mount");
string strMounts = "";
foreach (XmlNode objXmlMount in objXmlMountList)
{
bool blnFound = false;
foreach (WeaponAccessory objMod in objWeapon.WeaponAccessories)
{
if (objMod.Mount == objXmlMount.InnerText)
{
blnFound = true;
}
}
if (!blnFound)
{
strMounts += objXmlMount.InnerText + "/";
}
}
// Remove the trailing /
if (strMounts != "" && strMounts.Contains('/'))
strMounts = strMounts.Substring(0, strMounts.Length - 1);
frmPickWeaponAccessory.AllowedMounts = strMounts;
}
frmPickWeaponAccessory.WeaponCost = objWeapon.Cost;
frmPickWeaponAccessory.AccessoryMultiplier = objWeapon.AccessoryMultiplier;
frmPickWeaponAccessory.ShowDialog();
if (frmPickWeaponAccessory.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + frmPickWeaponAccessory.SelectedAccessory + "\"]");
TreeNode objNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlWeapon, objNode, frmPickWeaponAccessory.SelectedMount,Convert.ToInt32(frmPickWeaponAccessory.SelectedRating));
objAccessory.Parent = objWeapon;
if (objAccessory.Cost.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objAccessory.Cost.Replace("Variable(", string.Empty).Replace(")", string.Empty);
if (strCost.Contains("-"))
{
//.........这里部分代码省略.........
示例2: tsVehicleAddWeaponAccessory_Click
private void tsVehicleAddWeaponAccessory_Click(object sender, EventArgs e)
{
// Attempt to locate the selected VehicleWeapon.
bool blnWeaponFound = false;
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
Weapon objWeapon = _objFunctions.FindVehicleWeapon(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (objWeapon != null)
blnWeaponFound = true;
if (!blnWeaponFound)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleWeaponAccessories"), LanguageManager.Instance.GetString("MessageTitle_VehicleWeaponAccessories"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Open the Weapons XML file and locate the selected Weapon.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + treVehicles.SelectedNode.Text + "\"]");
frmSelectWeaponAccessory frmPickWeaponAccessory = new frmSelectWeaponAccessory(_objCharacter);
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the Weapon allows Accessories to be added to it.
if (!Convert.ToBoolean(objXmlWeapon["allowaccessory"].InnerText))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
XmlNodeList objXmlMountList = objXmlWeapon.SelectNodes("accessorymounts/mount");
string strMounts = "";
foreach (XmlNode objXmlMount in objXmlMountList)
{
// Run through the Weapon's currenct Accessories and filter out any used up Mount points.
bool blnFound = false;
foreach (WeaponAccessory objCurrentAccessory in objWeapon.WeaponAccessories)
{
if (objCurrentAccessory.Mount == objXmlMount.InnerText)
blnFound = true;
}
if (!blnFound)
strMounts += objXmlMount.InnerText + "/";
}
frmPickWeaponAccessory.AllowedMounts = strMounts;
}
frmPickWeaponAccessory.WeaponCost = objWeapon.Cost;
frmPickWeaponAccessory.AccessoryMultiplier = objWeapon.AccessoryMultiplier;
frmPickWeaponAccessory.ShowDialog();
if (frmPickWeaponAccessory.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + frmPickWeaponAccessory.SelectedAccessory + "\"]");
TreeNode objNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlWeapon, objNode, frmPickWeaponAccessory.SelectedMount, Convert.ToInt32(frmPickWeaponAccessory.SelectedRating));
objAccessory.Parent = objWeapon;
objWeapon.WeaponAccessories.Add(objAccessory);
objNode.ContextMenuStrip = cmsVehicleWeaponAccessory;
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
if (frmPickWeaponAccessory.AddAgain)
tsVehicleAddWeaponAccessory_Click(sender, e);
UpdateCharacterInfo();
}
示例3: tsWeaponAddAccessory_Click
private void tsWeaponAddAccessory_Click(object sender, EventArgs e)
{
// Make sure a parent item is selected, then open the Select Accessory window.
try
{
if (treWeapons.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Locate the Weapon that is selected in the Tree.
Weapon objWeapon = (Weapon)_objFunctions.FindEquipment(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, typeof(Weapon));
// Accessories cannot be added to Cyberweapons.
if (objWeapon.Category.StartsWith("Cyberware"))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberweaponNoAccessory"), LanguageManager.Instance.GetString("MessageTitle_CyberweaponNoAccessory"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Open the Weapons XML file and locate the selected Weapon.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + objWeapon.ExternalId + "\"]");
frmSelectWeaponAccessory frmPickWeaponAccessory = new frmSelectWeaponAccessory(_objCharacter);
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the Weapon allows Accessories to be added to it.
if (!Convert.ToBoolean(objXmlWeapon["allowaccessory"].InnerText))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
XmlNodeList objXmlMountList = objXmlWeapon.SelectNodes("accessorymounts/mount");
string strMounts = "";
foreach (XmlNode objXmlMount in objXmlMountList)
strMounts += objXmlMount.InnerText + "/";
frmPickWeaponAccessory.AllowedMounts = strMounts;
}
frmPickWeaponAccessory.WeaponCost = objWeapon.Cost;
frmPickWeaponAccessory.AccessoryMultiplier = objWeapon.AccessoryMultiplier;
frmPickWeaponAccessory.ShowDialog();
if (frmPickWeaponAccessory.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + frmPickWeaponAccessory.SelectedAccessory + "\"]");
TreeNode objNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlWeapon, objNode, frmPickWeaponAccessory.SelectedMount);
objAccessory.Parent = objWeapon;
objWeapon.WeaponAccessories.Add(objAccessory);
objNode.ContextMenuStrip = cmsWeaponAccessory;
treWeapons.SelectedNode.Nodes.Add(objNode);
treWeapons.SelectedNode.Expand();
UpdateCharacterInfo();
RefreshSelectedWeapon();
if (frmPickWeaponAccessory.AddAgain)
tsWeaponAddAccessory_Click(sender, e);
}
示例4: AddPACKSKit
/// <summary>
/// Add a PACKS Kit to the character.
/// </summary>
public void AddPACKSKit()
{
frmSelectPACKSKit frmPickPACKSKit = new frmSelectPACKSKit(_objCharacter);
frmPickPACKSKit.ShowDialog(this);
bool blnCreateChildren = true;
// If the form was canceled, don't do anything.
if (frmPickPACKSKit.DialogResult == DialogResult.Cancel)
return;
XmlDocument objXmlDocument = XmlManager.Instance.Load("packs.xml");
// Do not create child items for Gear if the chosen Kit is in the Custom category since these items will contain the exact plugins desired.
if (frmPickPACKSKit.SelectedCategory == "Custom")
blnCreateChildren = false;
XmlNode objXmlKit = objXmlDocument.SelectSingleNode("/chummer/packs/pack[name = \"" + frmPickPACKSKit.SelectedKit + "\" and category = \"" + frmPickPACKSKit.SelectedCategory + "\"]");
// Update Qualities.
if (objXmlKit["qualities"] != null)
{
XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");
// Positive Qualities.
foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/positive/quality"))
{
XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.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 (objXmlQuality.Attributes["select"] != null)
strForceValue = objXmlQuality.Attributes["select"].InnerText;
objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
_objCharacter.Qualities.Add(objQuality);
treQualities.Nodes[0].Nodes.Add(objNode);
treQualities.Nodes[0].Expand();
// Add any created Weapons to the character.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
// Create the Weapon Node if one exists.
foreach (TreeNode objWeaponNode in objWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
treWeapons.Nodes[0].Expand();
}
}
// Negative Qualities.
foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/negative/quality"))
{
XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.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 (objXmlQuality.Attributes["select"] != null)
strForceValue = objXmlQuality.Attributes["select"].InnerText;
objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
_objCharacter.Qualities.Add(objQuality);
treQualities.Nodes[1].Nodes.Add(objNode);
treQualities.Nodes[1].Expand();
// Add any created Weapons to the character.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
// Create the Weapon Node if one exists.
foreach (TreeNode objWeaponNode in objWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
treWeapons.Nodes[0].Expand();
}
}
}
// Update Attributes.
if (objXmlKit["attributes"] != null)
{
// Reset all Attributes back to 1 so we don't go over any BP limits.
nudBOD.Value = nudBOD.Minimum;
nudAGI.Value = nudAGI.Minimum;
nudREA.Value = nudREA.Minimum;
//.........这里部分代码省略.........
示例5: tsWeaponAddAccessory_Click
private void tsWeaponAddAccessory_Click(object sender, EventArgs e)
{
// Make sure a parent item is selected, then open the Select Accessory window.
try
{
if (treWeapons.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Locate the Weapon that is selected in the Tree.
Weapon objWeapon = _objFunctions.FindWeapon(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
// Accessories cannot be added to Cyberweapons.
if (objWeapon.Cyberware)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberweaponNoAccessory"), LanguageManager.Instance.GetString("MessageTitle_CyberweaponNoAccessory"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Open the Weapons XML file and locate the selected Weapon.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objWeapon.Name + "\"]");
frmSelectWeaponAccessory frmPickWeaponAccessory = new frmSelectWeaponAccessory(_objCharacter, true);
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the Weapon allows Accessories to be added to it.
if (!Convert.ToBoolean(objXmlWeapon["allowaccessory"].InnerText))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
XmlNodeList objXmlMountList = objXmlWeapon.SelectNodes("accessorymounts/mount");
string strMounts = "";
foreach (XmlNode objXmlMount in objXmlMountList)
strMounts += objXmlMount.InnerText + "/";
frmPickWeaponAccessory.AllowedMounts = strMounts;
}
frmPickWeaponAccessory.WeaponCost = objWeapon.Cost;
frmPickWeaponAccessory.AccessoryMultiplier = objWeapon.AccessoryMultiplier;
frmPickWeaponAccessory.ShowDialog();
if (frmPickWeaponAccessory.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + frmPickWeaponAccessory.SelectedAccessory + "\"]");
TreeNode objNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlWeapon, objNode, frmPickWeaponAccessory.SelectedMount);
objAccessory.Parent = objWeapon;
if (objAccessory.Cost.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objAccessory.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));
if (intMin != 0 || intMax != 0)
{
frmSelectNumber frmPickNumber = new frmSelectNumber();
if (intMax == 0)
intMax = 1000000;
frmPickNumber.Minimum = intMin;
frmPickNumber.Maximum = intMax;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_SelectVariableCost").Replace("{0}", objAccessory.DisplayNameShort);
frmPickNumber.AllowCancel = false;
frmPickNumber.ShowDialog();
objAccessory.Cost = frmPickNumber.SelectedValue.ToString();
}
}
// Check the item's Cost and make sure the character can afford it.
//.........这里部分代码省略.........
示例6: tsVehicleAddWeaponAccessory_Click
private void tsVehicleAddWeaponAccessory_Click(object sender, EventArgs e)
{
// Attempt to locate the selected VehicleWeapon.
bool blnWeaponFound = false;
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
Weapon objWeapon = _objFunctions.FindVehicleWeapon(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (objWeapon != null)
blnWeaponFound = true;
if (!blnWeaponFound)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleWeaponAccessories"), LanguageManager.Instance.GetString("MessageTitle_VehicleWeaponAccessories"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Open the Weapons XML file and locate the selected Weapon.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + treVehicles.SelectedNode.Text + "\"]");
frmSelectWeaponAccessory frmPickWeaponAccessory = new frmSelectWeaponAccessory(_objCharacter, true);
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the Weapon allows Accessories to be added to it.
if (!Convert.ToBoolean(objXmlWeapon["allowaccessory"].InnerText))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
XmlNodeList objXmlMountList = objXmlWeapon.SelectNodes("accessorymounts/mount");
string strMounts = "";
foreach (XmlNode objXmlMount in objXmlMountList)
{
// Run through the Weapon's currenct Accessories and filter out any used up Mount points.
bool blnFound = false;
foreach (WeaponAccessory objCurrentAccessory in objWeapon.WeaponAccessories)
{
if (objCurrentAccessory.Mount == objXmlMount.InnerText)
blnFound = true;
}
if (!blnFound)
strMounts += objXmlMount.InnerText + "/";
}
frmPickWeaponAccessory.AllowedMounts = strMounts;
}
frmPickWeaponAccessory.WeaponCost = objWeapon.Cost;
frmPickWeaponAccessory.AccessoryMultiplier = objWeapon.AccessoryMultiplier;
frmPickWeaponAccessory.ShowDialog();
if (frmPickWeaponAccessory.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + frmPickWeaponAccessory.SelectedAccessory + "\"]");
TreeNode objNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlWeapon, objNode, frmPickWeaponAccessory.SelectedMount);
objAccessory.Parent = objWeapon;
// Check the item's Cost and make sure the character can afford it.
int intOriginalCost = objWeapon.TotalCost;
objWeapon.WeaponAccessories.Add(objAccessory);
int intCost = objWeapon.TotalCost - intOriginalCost;
// Apply a markup if applicable.
if (frmPickWeaponAccessory.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickWeaponAccessory.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
// Multiply the cost if applicable.
if (objAccessory.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objAccessory.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
intCost *= _objOptions.ForbiddenCostMultiplier;
if (!frmPickWeaponAccessory.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
objWeapon.WeaponAccessories.Remove(objAccessory);
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickWeaponAccessory.AddAgain)
tsVehicleAddWeaponAccessory_Click(sender, e);
return;
}
else
{
//.........这里部分代码省略.........
示例7: TestWeapons
private void TestWeapons()
{
Character objCharacter = new Character();
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
pgbProgress.Minimum = 0;
pgbProgress.Value = 0;
pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/weapons/weapon").Count;
pgbProgress.Maximum += objXmlDocument.SelectNodes("/chummer/accessories/accessory").Count;
pgbProgress.Maximum += objXmlDocument.SelectNodes("/chummer/mods/mod").Count;
// Weapons.
foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/weapons/weapon"))
{
pgbProgress.Value++;
Application.DoEvents();
try
{
TreeNode objTempNode = new TreeNode();
Weapon objTemp = new Weapon(objCharacter);
objTemp.Create(objXmlGear, objCharacter, objTempNode, null, null, null);
try
{
int objValue = objTemp.TotalCost;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
}
try
{
string objValue = objTemp.TotalAP;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAP\n";
}
try
{
string objValue = objTemp.TotalAvail;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n";
}
try
{
string objValue = objTemp.TotalRC;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalRC\n";
}
try
{
int objValue = objTemp.TotalReach;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalReach\n";
}
try
{
string objValue = objTemp.CalculatedAmmo();
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedAmmo\n";
}
try
{
string objValue = objTemp.CalculatedConcealability();
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedConcealability\n";
}
try
{
string objValue = objTemp.CalculatedDamage();
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedDamage\n";
}
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
}
}
// Weapon Accessories.
foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/accessories/accessory"))
{
pgbProgress.Value++;
Application.DoEvents();
try
{
TreeNode objTempNode = new TreeNode();
WeaponAccessory objTemp = new WeaponAccessory(objCharacter);
//.........这里部分代码省略.........
示例8: lstAccessory_SelectedIndexChanged
private void lstAccessory_SelectedIndexChanged(object sender, EventArgs e)
{
// Retireve the information for the selected Accessory.
XmlNode objXmlAccessory = _objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + lstAccessory.SelectedValue + "\"]");
TreeNode objTreeNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlAccessory, objTreeNode, "Barrel");
lblRC.Text = objAccessory.RC;
string[] strMounts = objXmlAccessory["mount"].InnerText.Split('/');
string strMount = "";
foreach (string strCurrentMount in strMounts)
{
if (strCurrentMount != "")
strMount += LanguageManager.Instance.GetString("String_Mount" + strCurrentMount) + "/";
}
// Remove the trailing /
if (strMount != "" && strMount.Contains('/'))
strMount = strMount.Substring(0, strMount.Length - 1);
lblMount.Tag = objXmlAccessory["mount"].InnerText;
lblMount.Text = strMount;
lblAvail.Text = objAccessory.TotalAvail;
// If a Weapon Cost has been provided, create a dummy parent so that its cost can be considered.
if (_intWeaponCost != 0)
{
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Cost = _intWeaponCost;
objAccessory.Parent = objWeapon;
}
int intCost = objAccessory.TotalCost;
if (chkFreeItem.Checked)
intCost = 0;
// Apply any markup.
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(nudMarkup.Value, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
lblCost.Text = String.Format("{0:###,###,##0¥}", intCost);
lblTest.Text = _objCharacter.AvailTest(intCost, lblAvail.Text);
string strBook = _objCharacter.Options.LanguageBookShort(objAccessory.Source);
string strPage = objAccessory.Page;
lblSource.Text = strBook + " " + strPage;
tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objAccessory.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage);
}
示例9: CreateAllWeaponAccessoriesTest
public void CreateAllWeaponAccessoriesTest()
{
// Create a new Human character.
Character objCharacter = new Character();
objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));
TreeNode objNode = new TreeNode();
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/accessories/accessory"))
{
WeaponAccessory objAccessory = new WeaponAccessory(objCharacter);
objAccessory.Create(objXmlNode, objNode, "Barrel");
}
}