本文整理汇总了C#中WeaponAccessory类的典型用法代码示例。如果您正苦于以下问题:C# WeaponAccessory类的具体用法?C# WeaponAccessory怎么用?C# WeaponAccessory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WeaponAccessory类属于命名空间,在下文中一共展示了WeaponAccessory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 = _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);
//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";
//.........这里部分代码省略.........
开发者ID:cormanater,项目名称:chummer5a,代码行数:101,代码来源:frmCreate.cs
示例2: FindWeaponGear
/// <summary>
/// Locate a piece of Gear within the character's Weapons.
/// </summary>
/// <param name="strGuid">InternalId of the Gear to find.</param>
/// <param name="lstWeapons">List of Weapons to search.</param>
/// <param name="objFoundAccessory">WeaponAccessory that the Gear was found in.</param>
public Gear FindWeaponGear(string strGuid, List<Weapon> lstWeapons, out WeaponAccessory objFoundAccessory)
{
Gear objReturn = new Gear(_objCharacter);
foreach (Weapon objWeapon in lstWeapons)
{
foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
{
objReturn = FindGear(strGuid, objAccessory.Gear);
if (objReturn != null)
{
if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
{
objFoundAccessory = objAccessory;
return objReturn;
}
}
}
if (objWeapon.UnderbarrelWeapons.Count > 0)
{
objReturn = FindWeaponGear(strGuid, objWeapon.UnderbarrelWeapons, out objFoundAccessory);
if (objReturn != null)
{
if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
return objReturn;
}
}
}
objFoundAccessory = null;
return objReturn;
}
开发者ID:hollis21,项目名称:Chummer,代码行数:40,代码来源:clsCommon.cs
示例3: FindVehicleGear
/// <summary>
/// Locate a piece of Gear within the character's Vehicles.
/// </summary>
/// <param name="strGuid">InternalId of the Gear to find.</param>
/// <param name="lstVehicles">List of Vehicles to search.</param>
/// <param name="objFoundVehicle">Vehicle that the Gear was found in.</param>
public Gear FindVehicleGear(string strGuid, List<Vehicle> lstVehicles, out Vehicle objFoundVehicle)
{
Gear objReturn = new Gear(_objCharacter);
foreach (Vehicle objVehicle in lstVehicles)
{
objReturn = FindGear(strGuid, objVehicle.Gear);
if (objReturn != null)
{
if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
{
objFoundVehicle = objVehicle;
return objReturn;
}
}
// Look for any Gear that might be attached to this Vehicle through Weapon Accessories or Cyberware.
foreach (VehicleMod objMod in objVehicle.Mods)
{
// Weapon Accessories.
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objReturn = FindWeaponGear(strGuid, objMod.Weapons, out objAccessory);
if (objReturn != null)
{
if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
{
objFoundVehicle = objVehicle;
return objReturn;
}
}
// Cyberware.
Cyberware objCyberware = new Cyberware(_objCharacter);
objReturn = FindCyberwareGear(strGuid, objMod.Cyberware, out objCyberware);
if (objReturn != null)
{
if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
{
objFoundVehicle = objVehicle;
return objReturn;
}
}
}
}
objFoundVehicle = null;
objReturn = null;
return objReturn;
}
开发者ID:hollis21,项目名称:Chummer,代码行数:57,代码来源:clsCommon.cs
示例4: 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);
}
开发者ID:janhelke,项目名称:chummer2,代码行数:53,代码来源:frmSelectWeaponAccessory.cs
示例5: FindWeaponAccessory
/// <summary>
/// Locate a WeaponAccessory within the character's Weapons.
/// </summary>
/// <param name="strGuid">InternalId of the WeaponAccessory to find.</param>
/// <param name="lstWeapons">List of Weapons to search.</param>
public WeaponAccessory FindWeaponAccessory(string strGuid, List<Weapon> lstWeapons)
{
WeaponAccessory objReturn = new WeaponAccessory(_objCharacter);
foreach (Weapon objWeapon in lstWeapons)
{
foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
{
if (objAccessory.InternalId == strGuid)
return objAccessory;
}
// Look within Underbarrel Weapons.
objReturn = FindWeaponAccessory(strGuid, objWeapon.UnderbarrelWeapons);
if (objReturn != null)
return objReturn;
}
return null;
}
开发者ID:hollis21,项目名称:Chummer,代码行数:24,代码来源:clsCommon.cs
示例6: RefreshPasteStatus
//.........这里部分代码省略.........
}
// Weapons Tab.
if (tabStreetGearTabs.SelectedTab == tabWeapons)
{
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon)
blnPasteEnabled = true;
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
{
// Check if the copied Gear can be pasted into the selected Weapon Accessory.
Gear objGear = new Gear(_objCharacter);
XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");
if (objXmlNode != null)
{
switch (objXmlNode["category"].InnerText)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Load(objXmlNode, true);
objGear = objCommlink;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Load(objXmlNode, true);
objGear = objNewGear;
break;
}
objGear.Parent = null;
// Make sure that a Weapon Accessory is selected and that it allows Gear of the item's Category.
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
try
{
foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
{
foreach (WeaponAccessory objWeaponAccessory in objCharacterWeapon.WeaponAccessories)
{
if (objWeaponAccessory.InternalId == treWeapons.SelectedNode.Tag.ToString())
{
objAccessory = objWeaponAccessory;
break;
}
}
}
if (objAccessory.AllowGear != null)
{
foreach (XmlNode objAllowed in objAccessory.AllowGear.SelectNodes("gearcategory"))
{
if (objAllowed.InnerText == objGear.Category)
{
blnPasteEnabled = true;
break;
}
}
}
}
catch
{
}
}
}
try
开发者ID:cormanater,项目名称:chummer5a,代码行数:67,代码来源:frmCreate.cs
示例7: 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("-"))
{
//.........这里部分代码省略.........
开发者ID:cormanater,项目名称:chummer5a,代码行数:101,代码来源:frmCreate.cs
示例8: 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
{
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs
示例9: 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.
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs
示例10: RefreshSelectedWeapon
/// <summary>
/// Refresh the information for the currently displayed Weapon.
/// </summary>
public void RefreshSelectedWeapon()
{
lblWeaponDeviceRating.Text = "";
lblWeaponAttack.Text = "";
lblWeaponSleaze.Text = "";
lblWeaponDataProcessing.Text = "";
lblWeaponFirewall.Text = "";
bool blnClear = false;
try
{
if (treWeapons.SelectedNode.Level == 0)
blnClear = true;
}
catch
{
blnClear = true;
}
if (blnClear)
{
lblWeaponName.Text = "";
lblWeaponCategory.Text = "";
lblWeaponAvail.Text = "";
lblWeaponCost.Text = "";
lblWeaponConceal.Text = "";
lblWeaponAccuracy.Text = "";
lblWeaponDamage.Text = "";
lblWeaponRC.Text = "";
lblWeaponAP.Text = "";
lblWeaponReach.Text = "";
lblWeaponMode.Text = "";
lblWeaponAmmo.Text = "";
lblWeaponSource.Text = "";
cboWeaponAmmo.Enabled = false;
tipTooltip.SetToolTip(lblWeaponSource, null);
chkWeaponAccessoryInstalled.Enabled = false;
chkIncludedInWeapon.Enabled = false;
chkIncludedInWeapon.Checked = false;
// Disable the fire button.
cmdFireWeapon.Enabled = false;
cmdReloadWeapon.Enabled = false;
cmdWeaponBuyAmmo.Enabled = false;
cboWeaponAmmo.Enabled = false;
// Hide Weapon Ranges.
lblWeaponRangeShort.Text = "";
lblWeaponRangeMedium.Text = "";
lblWeaponRangeLong.Text = "";
lblWeaponRangeExtreme.Text = "";
return;
}
lblWeaponDicePool.Text = "";
tipTooltip.SetToolTip(lblWeaponDicePool, "");
cmdWeaponMoveToVehicle.Enabled = false;
// Locate the selected Weapon.
if (treWeapons.SelectedNode.Level == 1)
{
Weapon objWeapon = _objFunctions.FindWeapon(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
if (objWeapon == null)
return;
_blnSkipRefresh = true;
lblWeaponName.Text = objWeapon.DisplayNameShort;
lblWeaponCategory.Text = objWeapon.DisplayCategory;
string strBook = _objOptions.LanguageBookShort(objWeapon.Source);
string strPage = objWeapon.Page;
lblWeaponSource.Text = strBook + " " + strPage;
tipTooltip.SetToolTip(lblWeaponSource, _objOptions.LanguageBookLong(objWeapon.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objWeapon.Page);
chkWeaponAccessoryInstalled.Enabled = false;
chkIncludedInWeapon.Enabled = false;
chkIncludedInWeapon.Checked = false;
// Do not allow Cyberware of Gear Weapons to be moved.
if (!objWeapon.Cyberware && objWeapon.Category != "Gear")
{
if (_objCharacter.Vehicles.Count > 0)
cmdWeaponMoveToVehicle.Enabled = true;
else
cmdWeaponMoveToVehicle.Enabled = false;
}
// Enable the fire button if the Weapon is Ranged.
if (objWeapon.WeaponType == "Ranged" || (objWeapon.WeaponType == "Melee" && objWeapon.Ammo != "0"))
{
cmdFireWeapon.Enabled = true;
cmdReloadWeapon.Enabled = true;
cmdWeaponBuyAmmo.Enabled = true;
lblWeaponAmmoRemaining.Text = objWeapon.AmmoRemaining.ToString();
//lblWeaponAmmoType.Text = "External Source";
cmsAmmoSingleShot.Enabled = objWeapon.AllowMode(LanguageManager.Instance.GetString("String_ModeSingleShot")) || objWeapon.AllowMode(LanguageManager.Instance.GetString("String_ModeSemiAutomatic"));
cmsAmmoShortBurst.Enabled = objWeapon.AllowMode(LanguageManager.Instance.GetString("String_ModeBurstFire")) || objWeapon.AllowMode(LanguageManager.Instance.GetString("String_ModeFullAutomatic"));
cmsAmmoLongBurst.Enabled = objWeapon.AllowMode(LanguageManager.Instance.GetString("String_ModeFullAutomatic"));
cmsAmmoFullBurst.Enabled = objWeapon.AllowMode(LanguageManager.Instance.GetString("String_ModeFullAutomatic"));
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs
示例11: tsUndoNuyenExpense_Click
//.........这里部分代码省略.........
{
if (objUnderbarrelWeapon.InternalId == objEntry.Undo.ObjectId)
{
// Remove the Underbarrel Weapon.
objWeapon.UnderbarrelWeapons.Remove(objUnderbarrelWeapon);
// Remove the Underbarrel Weapon from the Tree.
foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes)
{
foreach (TreeNode objNode in objVNode.Nodes)
{
foreach (TreeNode objChild in objNode.Nodes)
{
foreach (TreeNode objSubChild in objChild.Nodes)
{
if (objSubChild.Tag.ToString() == objEntry.Undo.ObjectId)
{
objSubChild.Remove();
break;
}
}
}
}
}
break;
}
}
}
}
}
}
}
break;
case NuyenExpenseType.AddVehicleWeaponAccessory:
// Locate the Weapon Accessory that was added.
foreach (Vehicle objVehicle in _objCharacter.Vehicles)
{
foreach (VehicleMod objMod in objVehicle.Mods)
{
foreach (Weapon objWeapon in objMod.Weapons)
{
foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
{
if (objAccessory.InternalId == objEntry.Undo.ObjectId)
{
// Remove the Weapon Accessory.
objWeapon.WeaponAccessories.Remove(objAccessory);
// Remove the Weapon Accessory from the Tree.
foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes)
{
foreach (TreeNode objNode in objVNode.Nodes)
{
foreach (TreeNode objWNode in objNode.Nodes)
{
foreach (TreeNode objChild in objWNode.Nodes)
{
if (objChild.Tag.ToString() == objEntry.Undo.ObjectId)
{
objChild.Remove();
break;
}
}
}
}
}
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:67,代码来源:frmCareer.cs
示例12: 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 "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 = "
|
请发表评论