本文整理汇总了C#中Weapon.CalculatedDamage方法的典型用法代码示例。如果您正苦于以下问题:C# Weapon.CalculatedDamage方法的具体用法?C# Weapon.CalculatedDamage怎么用?C# Weapon.CalculatedDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon.CalculatedDamage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshSelectedVehicle
//.........这里部分代码省略.........
cboVehicleGearFirewall.DataSource = objASDF;
cboVehicleGearFirewall.SelectedIndex = 3;
DisplayVehicleWeaponStats(false);
DisplayVehicleCommlinkStats(true);
if (_objCharacter.Metatype == "A.I.")
{
chkVehicleHomeNode.Visible = true;
chkVehicleHomeNode.Checked = objCommlink.HomeNode;
}
}
}
else
{
// Look for the selected Vehicle Weapon.
Weapon objWeapon = new Weapon(_objCharacter);
foreach (Vehicle objVehicle in _objCharacter.Vehicles)
{
objWeapon = _objFunctions.FindWeapon(treVehicles.SelectedNode.Tag.ToString(), objVehicle.Weapons);
if (objWeapon != null)
break;
}
nudVehicleRating.Enabled = false;
DisplayVehicleWeaponStats(true);
DisplayVehicleCommlinkStats(false);
DisplayVehicleStats(false);
lblVehicleWeaponName.Text = objWeapon.DisplayNameShort;
lblVehicleWeaponCategory.Text = objWeapon.DisplayCategory;
lblVehicleWeaponDamage.Text = objWeapon.CalculatedDamage();
lblVehicleWeaponAP.Text = objWeapon.TotalAP;
lblVehicleWeaponAmmo.Text = objWeapon.CalculatedAmmo();
lblVehicleWeaponMode.Text = objWeapon.CalculatedMode;
lblVehicleWeaponRangeShort.Text = objWeapon.RangeShort;
lblVehicleWeaponRangeMedium.Text = objWeapon.RangeMedium;
lblVehicleWeaponRangeLong.Text = objWeapon.RangeLong;
lblVehicleWeaponRangeExtreme.Text = objWeapon.RangeExtreme;
lblVehicleName.Text = objWeapon.DisplayNameShort;
lblVehicleCategory.Text = LanguageManager.Instance.GetString("String_VehicleWeapon");
lblVehicleAvail.Text = objWeapon.TotalAvail;
lblVehicleCost.Text = String.Format("{0:###,###,##0¥}", objWeapon.TotalCost);
lblVehicleSlots.Text = "6 (" + objWeapon.SlotsRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
string strBook = _objOptions.LanguageBookShort(objWeapon.Source);
string strPage = objWeapon.Page;
lblVehicleSource.Text = strBook + " " + strPage;
_blnSkipRefresh = true;
chkVehicleBlackMarketDiscount.Checked = objWeapon.DiscountCost;
_blnSkipRefresh = false;
tipTooltip.SetToolTip(lblVehicleSource, _objOptions.LanguageBookLong(objWeapon.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objWeapon.Page);
}
}
if (blnVehicleMod)
{
chkVehicleWeaponAccessoryInstalled.Enabled = true;
chkVehicleWeaponAccessoryInstalled.Checked = objMod.Installed;
}
else
chkVehicleWeaponAccessoryInstalled.Enabled = false;
chkVehicleIncludedInWeapon.Checked = false;
}
示例2: lstWeapon_SelectedIndexChanged
private void lstWeapon_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstWeapon.Text == "")
return;
// Retireve the information for the selected Weapon.
XmlNode objXmlWeapon = _objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + lstWeapon.SelectedValue + "\"]");
Weapon objWeapon = new Weapon(_objCharacter);
TreeNode objNode = new TreeNode();
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, null, null, null);
lblWeaponReach.Text = objWeapon.TotalReach.ToString();
lblWeaponDamage.Text = objWeapon.CalculatedDamage();
lblWeaponAP.Text = objWeapon.TotalAP;
lblWeaponMode.Text = objWeapon.CalculatedMode;
lblWeaponRC.Text = objWeapon.TotalRC;
lblWeaponAmmo.Text = objWeapon.CalculatedAmmo();
lblWeaponAccuracy.Text = objWeapon.TotalAccuracy.ToString();
lblWeaponAvail.Text = objWeapon.TotalAvail;
int intItemCost = 0;
double dblCost = 0;
try
{
dblCost = Convert.ToDouble(objXmlWeapon["cost"].InnerText, GlobalOptions.Instance.CultureInfo);
}
catch { }
dblCost *= 1 + (Convert.ToDouble(nudMarkup.Value, GlobalOptions.Instance.CultureInfo) / 100.0);
lblWeaponCost.Text = String.Format("{0:###,###,##0¥}", dblCost);
try
{
intItemCost = Convert.ToInt32(dblCost);
}
catch
{
}
if (chkFreeItem.Checked)
{
lblWeaponCost.Text = String.Format("{0:###,###,##0¥}", 0);
intItemCost = 0;
}
lblTest.Text = _objCharacter.AvailTest(intItemCost, lblWeaponAvail.Text);
string strBook = _objCharacter.Options.LanguageBookShort(objXmlWeapon["source"].InnerText);
string strPage = objXmlWeapon["page"].InnerText;
if (objXmlWeapon["altpage"] != null)
strPage = objXmlWeapon["altpage"].InnerText;
lblSource.Text = strBook + " " + strPage;
// Build a list of included Accessories and Modifications that come with the weapon.
string strAccessories = "";
XmlNodeList objXmlNodeList = objXmlWeapon.SelectNodes("accessories/accessory");
foreach (XmlNode objXmlAccessory in objXmlNodeList)
{
XmlNode objXmlItem = _objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + objXmlAccessory.InnerText + "\"]");
if (objXmlItem["translate"] != null)
strAccessories += objXmlItem["translate"].InnerText + "\n";
else
strAccessories += objXmlItem["name"].InnerText + "\n";
}
objXmlNodeList = objXmlWeapon.SelectNodes("mods/mod");
foreach (XmlNode objXmlMod in objXmlNodeList)
{
XmlNode objXmlItem = _objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod.InnerText + "\"]");
if (objXmlItem["translate"] != null)
strAccessories += objXmlItem["translate"].InnerText + "\n";
else
strAccessories += objXmlItem["name"].InnerText + "\n";
}
if (strAccessories == "")
lblIncludedAccessories.Text = LanguageManager.Instance.GetString("String_None");
else
lblIncludedAccessories.Text = strAccessories;
tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objXmlWeapon["source"].InnerText) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage);
}
示例3: tmrSearch_Tick
private void tmrSearch_Tick(object sender, EventArgs e)
{
tmrSearch.Stop();
tmrSearch.Enabled = false;
if (txtSearch.Text == "")
{
cboCategory_SelectedIndexChanged(sender, e);
return;
}
// Treat everything as being uppercase so the search is case-insensitive.
string strSearch = "/chummer/weapons/weapon[(" + _objCharacter.Options.BookXPath() + ") and category != \"Cyberware\" and category != \"Gear\" and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]";
XmlNodeList objXmlWeaponList = _objXmlDocument.SelectNodes(strSearch);
if (dgvWeapons.Visible)
{
DataTable tabWeapons = new DataTable("weapons");
tabWeapons.Columns.Add("WeaponName");
tabWeapons.Columns.Add("Dice");
tabWeapons.Columns.Add("Accuracy");
tabWeapons.Columns["Accuracy"].DataType = typeof(Int32);
tabWeapons.Columns.Add("Damage");
tabWeapons.Columns.Add("AP");
tabWeapons.Columns.Add("RC");
tabWeapons.Columns["RC"].DataType = typeof(Int32);
tabWeapons.Columns.Add("Ammo");
tabWeapons.Columns.Add("Mode");
tabWeapons.Columns.Add("Reach");
tabWeapons.Columns.Add("Accessories");
tabWeapons.Columns.Add("Avail");
tabWeapons.Columns.Add("Source");
tabWeapons.Columns.Add("Cost");
tabWeapons.Columns["Cost"].DataType = typeof(Int32);
// Populate the Weapon list.
foreach (XmlNode objXmlWeapon in objXmlWeaponList)
{
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, null, null, null);
string strWeaponName = objWeapon.Name;
string strDice = objWeapon.DicePool;
int intAccuracy = Convert.ToInt32(objWeapon.TotalAccuracy);
string strDamage = objWeapon.CalculatedDamage();
string strAP = objWeapon.TotalAP;
if (strAP == "-")
strAP = "0";
int intRC = Convert.ToInt32(objWeapon.TotalRC);
string strAmmo = objWeapon.Ammo;
string strMode = objWeapon.Mode;
string strReach = objWeapon.TotalReach.ToString();
string strAccessories = "";
foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
{
if (strAccessories.Length > 0)
strAccessories += "\n";
strAccessories += objAccessory.Name;
}
string strAvail = objWeapon.Avail.ToString();
string strSource = objWeapon.Source + " " + objWeapon.Page;
int intCost = objWeapon.Cost;
if (objWeapon.DisplayCategory == "Blades" || objWeapon.DisplayCategory == "Clubs" || objWeapon.DisplayCategory == "Improvised Weapons" || objWeapon.DisplayCategory == "Exotic Melee Weapons" || objWeapon.DisplayCategory == "Unarmed")
{
strAmmo = "";
strMode = "";
}
else
{
strReach = "";
}
tabWeapons.Rows.Add(strWeaponName, strDice, intAccuracy, strDamage, strAP, intRC, strAmmo, strMode, strReach, strAccessories, strAvail, strSource, intCost);
}
DataSet set = new DataSet("weapons");
set.Tables.Add(tabWeapons);
dgvWeapons.Columns[5].Visible = true;
dgvWeapons.Columns[6].Visible = true;
dgvWeapons.Columns[7].Visible = true;
dgvWeapons.Columns[8].Visible = true;
dgvWeapons.Columns[12].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight;
dgvWeapons.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgvWeapons.DataSource = set;
dgvWeapons.DataMember = "weapons";
}
else
{
List<ListItem> lstWeapons = new List<ListItem>();
foreach (XmlNode objXmlWeapon in objXmlWeaponList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlWeapon["name"].InnerText;
if (objXmlWeapon["translate"] != null)
objItem.Name = objXmlWeapon["translate"].InnerText;
//.........这里部分代码省略.........
示例4: LoadGrid
private void LoadGrid()
{
DataTable tabWeapons = new DataTable("weapons");
tabWeapons.Columns.Add("WeaponName");
tabWeapons.Columns.Add("Dice");
tabWeapons.Columns.Add("Accuracy");
tabWeapons.Columns["Accuracy"].DataType = typeof(Int32);
tabWeapons.Columns.Add("Damage");
tabWeapons.Columns.Add("AP");
tabWeapons.Columns.Add("RC");
tabWeapons.Columns["RC"].DataType = typeof(Int32);
tabWeapons.Columns.Add("Ammo");
tabWeapons.Columns.Add("Mode");
tabWeapons.Columns.Add("Reach");
tabWeapons.Columns.Add("Accessories");
tabWeapons.Columns.Add("Avail");
tabWeapons.Columns.Add("Source");
tabWeapons.Columns.Add("Cost");
tabWeapons.Columns["Cost"].DataType = typeof(Int32);
// Populate the Weapon list.
XmlNodeList objXmlWeaponList;
if (txtSearch.Text.Length > 1)
{
string strSearch = "/chummer/weapons/weapon[(" + _objCharacter.Options.BookXPath() + ") and category != \"Cyberware\" and category != \"Gear\" and ((contains(translate(name,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\") and not(translate)) or contains(translate(translate,'abcdefghijklmnopqrstuvwxyzàáâãäåçèéêëìíîïñòóôõöùúûüýß','ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝß'), \"" + txtSearch.Text.ToUpper() + "\"))]";
objXmlWeaponList = _objXmlDocument.SelectNodes(strSearch);
}
else
{
objXmlWeaponList = _objXmlDocument.SelectNodes("/chummer/weapons/weapon[category = \"" + cboCategory.SelectedValue + "\" and (" + _objCharacter.Options.BookXPath() + ")]");
}
foreach (XmlNode objXmlWeapon in objXmlWeaponList)
{
bool blnCyberware = false;
try
{
if (objXmlWeapon["cyberware"].InnerText == "yes")
blnCyberware = true;
}
catch
{ }
if (!blnCyberware)
{
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, null, null, null);
string strWeaponName = objWeapon.Name;
string strDice = objWeapon.DicePool;
int intAccuracy = Convert.ToInt32(objWeapon.TotalAccuracy);
string strDamage = objWeapon.CalculatedDamage(_objCharacter.STR.Augmented);
string strAP = objWeapon.TotalAP;
if (strAP == "-")
strAP = "0";
int intRC = Convert.ToInt32(objWeapon.TotalRC);
string strAmmo = objWeapon.Ammo;
string strMode = objWeapon.Mode;
string strReach = objWeapon.TotalReach.ToString();
string strAccessories = "";
foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
{
if (strAccessories.Length > 0)
strAccessories += "\n";
strAccessories += objAccessory.Name;
}
string strAvail = objWeapon.Avail.ToString();
string strSource = objWeapon.Source + " " + objWeapon.Page;
int intCost = objWeapon.Cost;
tabWeapons.Rows.Add(strWeaponName, strDice, intAccuracy, strDamage, strAP, intRC, strAmmo, strMode, strReach, strAccessories, strAvail, strSource, intCost);
}
}
DataSet set = new DataSet("weapons");
set.Tables.Add(tabWeapons);
if (cboCategory.SelectedValue.ToString() == "Blades" || cboCategory.SelectedValue.ToString() == "Clubs" || cboCategory.SelectedValue.ToString() == "Improvised Weapons" || cboCategory.SelectedValue.ToString() == "Exotic Melee Weapons" || cboCategory.SelectedValue.ToString() == "Unarmed")
{
dgvWeapons.Columns[5].Visible = false;
dgvWeapons.Columns[6].Visible = false;
dgvWeapons.Columns[7].Visible = false;
dgvWeapons.Columns[8].Visible = true;
}
else
{
dgvWeapons.Columns[5].Visible = true;
dgvWeapons.Columns[6].Visible = true;
dgvWeapons.Columns[7].Visible = true;
dgvWeapons.Columns[8].Visible = false;
}
dgvWeapons.Columns[12].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight;
dgvWeapons.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgvWeapons.DataSource = set;
dgvWeapons.DataMember = "weapons";
}
示例5: RefreshSelectedVehicle
//.........这里部分代码省略.........
{
Commlink objCommlink = (Commlink)objGear;
lblVehicleDevice.Text = objCommlink.DeviceRating.ToString();
lblVehicleAttack.Text = objCommlink.Attack.ToString();
lblVehicleSleaze.Text = objCommlink.Sleaze.ToString();
lblVehicleDataProcessing.Text = objCommlink.DataProcessing.ToString();
lblVehicleFirewall.Text = objCommlink.Firewall.ToString();
}
if ((_objCharacter.Metatype.EndsWith("A.I.") || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients") && objGear.GetType() == typeof(Commlink))
{
chkVehicleHomeNode.Visible = true;
chkVehicleHomeNode.Checked = objGear.HomeNode;
}
}
else
{
// Look for the selected Vehicle Weapon.
Weapon objWeapon = new Weapon(_objCharacter);
Vehicle objCurrentVehicle = new Vehicle(_objCharacter);
foreach (Vehicle objVehicle in _objCharacter.Vehicles)
{
objWeapon = _objFunctions.FindWeapon(treVehicles.SelectedNode.Tag.ToString(), objVehicle.Weapons);
if (objWeapon != null)
{
objCurrentVehicle = objVehicle;
break;
}
}
lblVehicleWeaponName.Text = objWeapon.DisplayNameShort;
lblVehicleWeaponCategory.Text = objWeapon.DisplayCategory;
lblVehicleWeaponDamage.Text = objWeapon.CalculatedDamage();
lblVehicleWeaponAP.Text = objWeapon.TotalAP;
lblVehicleWeaponAmmo.Text = objWeapon.CalculatedAmmo();
lblVehicleWeaponMode.Text = objWeapon.CalculatedMode;
if (objWeapon.WeaponType == "Ranged" || (objWeapon.WeaponType == "Melee" && objWeapon.Ammo != "0"))
{
cmdFireVehicleWeapon.Enabled = true;
cmdReloadVehicleWeapon.Enabled = true;
lblVehicleWeaponAmmoRemaining.Text = objWeapon.AmmoRemaining.ToString();
cmsVehicleAmmoSingleShot.Enabled = objWeapon.AllowMode("SS") || objWeapon.AllowMode("SA");
cmsVehicleAmmoShortBurst.Enabled = objWeapon.AllowMode("BF");
cmsVehicleAmmoLongBurst.Enabled = objWeapon.AllowMode("FA");
cmsVehicleAmmoFullBurst.Enabled = objWeapon.AllowMode("FA");
cmsVehicleAmmoSuppressiveFire.Enabled = objWeapon.AllowMode("FA");
// Melee Weapons with Ammo are considered to be Single Shot.
if (objWeapon.WeaponType == "Melee" && objWeapon.Ammo != "0")
cmsVehicleAmmoSingleShot.Enabled = true;
if (cmsVehicleAmmoFullBurst.Enabled)
cmsVehicleAmmoFullBurst.Text = LanguageManager.Instance.GetString("String_FullBurst").Replace("{0}", objWeapon.FullBurst.ToString());
if (cmsVehicleAmmoSuppressiveFire.Enabled)
cmsVehicleAmmoSuppressiveFire.Text = LanguageManager.Instance.GetString("String_SuppressiveFire").Replace("{0}", objWeapon.Suppressive.ToString());
List<ListItem> lstAmmo = new List<ListItem>();
int intCurrentSlot = objWeapon.ActiveAmmoSlot;
for (int i = 1; i <= objWeapon.AmmoSlots; i++)
{
Gear objVehicleGear = new Gear(_objCharacter);
ListItem objAmmo = new ListItem();
objWeapon.ActiveAmmoSlot = i;
objVehicleGear = _objFunctions.FindGear(objWeapon.AmmoLoaded, objCurrentVehicle.Gear);
示例6: RefreshSelectedWeapon
//.........这里部分代码省略.........
cmdWeaponBuyAmmo.Enabled = false;
lblWeaponAmmoRemaining.Text = "";
cboWeaponAmmo.Enabled = false;
}
// If this is a Cyberweapon, grab the STR of the limb.
int intUseSTR = 0;
if (objWeapon.Cyberware)
{
foreach (Cyberware objCyberware in _objCharacter.Cyberware)
{
foreach (Cyberware objPlugin in objCyberware.Children)
{
if (objPlugin.WeaponID == objWeapon.InternalId)
{
intUseSTR = objCyberware.TotalStrength;
break;
}
}
}
}
// Show the Weapon Ranges.
lblWeaponRangeShort.Text = objWeapon.RangeShort;
lblWeaponRangeMedium.Text = objWeapon.RangeMedium;
lblWeaponRangeLong.Text = objWeapon.RangeLong;
lblWeaponRangeExtreme.Text = objWeapon.RangeExtreme;
_blnSkipRefresh = false;
lblWeaponAvail.Text = objWeapon.TotalAvail;
lblWeaponCost.Text = String.Format("{0:###,###,##0¥}", objWeapon.TotalCost);
lblWeaponConceal.Text = objWeapon.CalculatedConcealability();
lblWeaponDamage.Text = objWeapon.CalculatedDamage(intUseSTR);
lblWeaponAccuracy.Text = objWeapon.TotalAccuracy.ToString();
lblWeaponRC.Text = objWeapon.TotalRC;
lblWeaponAP.Text = objWeapon.TotalAP;
lblWeaponReach.Text = objWeapon.TotalReach.ToString();
lblWeaponMode.Text = objWeapon.CalculatedMode;
lblWeaponAmmo.Text = objWeapon.CalculatedAmmo();
lblWeaponSlots.Text = "6 (" + objWeapon.SlotsRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
lblWeaponDicePool.Text = objWeapon.DicePool;
tipTooltip.SetToolTip(lblWeaponDicePool, objWeapon.DicePoolTooltip);
tipTooltip.SetToolTip(lblWeaponRC, objWeapon.RCToolTip);
UpdateCharacterInfo();
}
else
{
// See if this is an Underbarrel Weapon.
bool blnUnderbarrel = false;
Weapon objWeapon = new Weapon(_objCharacter);
foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
{
if (objCharacterWeapon.UnderbarrelWeapons.Count > 0)
{
foreach (Weapon objUnderbarrelWeapon in objCharacterWeapon.UnderbarrelWeapons)
{
if (objUnderbarrelWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
{
objWeapon = objUnderbarrelWeapon;
blnUnderbarrel = true;
break;
}
}
}
示例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: WeaponTest
public void WeaponTest()
{
// Create a new Human character.
Character objCharacter = new Character();
objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));
// Add a Combat Axe.
Weapon objWeapon = new Weapon(objCharacter);
objWeapon.Category = "Blades";
objWeapon.WeaponType = "Melee";
objWeapon.Spec = "Axes";
objWeapon.Reach = 2;
objWeapon.Damage = "(STR/2+9)P";
objWeapon.AP = "-4";
objWeapon.RC = "0";
objWeapon.Accuracy = "4";
objWeapon.Ammo = "0";
objWeapon.Concealability = 0;
objWeapon.Avail = "9R";
objWeapon.Cost = 500;
objWeapon.Source = "SR5";
objWeapon.Page = "900";
// Add the Weapon to the character.
objCharacter.Weapons.Add(objWeapon);
// Set the character's Blades Skill to 3.
Skill objSkill = new Skill(objCharacter);
objSkill = objCharacter.Skills.Find(o => o.DisplayName == "Blades");
objSkill.Rating = 3;
// Set the character's STR to 4 and make sure the Weapon attributes are calculated correctly.
objCharacter.STR.Value = 4;
Assert.AreEqual("11P", objWeapon.CalculatedDamage(), "Weapon DV does not match the expected value of 11P.");
// Dice Pool should be 4 since the character has Blades 3 + AGI 1.
Assert.AreEqual("4", objWeapon.DicePool, "Weapon Dice Pool does not match the expected value of 4.");
// Add the Specialization to the Skill and check its value again. Should be 4 (6).
objSkill.Specialization = "Axes";
Assert.AreEqual("4 (6)", objWeapon.DicePool, "Weapon Dice Pool with Specialization does not match the expected value of 4 (6).");
// Set the character's STR to 5 and make sure the Weapon attributes are calculated correctly. DV should be 12 since fractions are rounded up.
objCharacter.STR.Value = 5;
Assert.AreEqual("12P", objWeapon.CalculatedDamage(), "Weapon DV does not match the expected value of 11P.");
}