本文整理汇总了C#中WeaponMod.Create方法的典型用法代码示例。如果您正苦于以下问题:C# WeaponMod.Create方法的具体用法?C# WeaponMod.Create怎么用?C# WeaponMod.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeaponMod
的用法示例。
在下文中一共展示了WeaponMod.Create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: tsVehicleAddWeaponModification_Click
private void tsVehicleAddWeaponModification_Click(object sender, EventArgs e)
{
// Attempt to locate the selected VehicleWeapon.
bool blnFound = false;
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
Weapon objWeapon = _objFunctions.FindVehicleWeapon(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (objWeapon != null)
blnFound = true;
if (!blnFound)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleWeaponMods"), LanguageManager.Instance.GetString("MessageTitle_VehicleWeaponMods"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectVehicleMod frmPickVehicleMod = new frmSelectVehicleMod(_objCharacter);
// Make sure the Weapon allows Modifications to be added to it.
// 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 + "\"]");
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (objXmlWeapon["allowmod"] != null)
{
if (objXmlWeapon["allowmod"].InnerText == "false")
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
// Set the Weapon properties for the window.
frmPickVehicleMod.WeaponCost = objWeapon.Cost;
frmPickVehicleMod.TotalWeaponCost = objWeapon.TotalCost;
frmPickVehicleMod.ModMultiplier = objWeapon.ModMultiplier;
frmPickVehicleMod.InputFile = "weapons";
frmPickVehicleMod.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickVehicleMod.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + frmPickVehicleMod.SelectedMod + "\"]");
TreeNode objNode = new TreeNode();
WeaponMod objMod = new WeaponMod(_objCharacter);
objMod.Create(objXmlMod, objNode);
objMod.Rating = frmPickVehicleMod.SelectedRating;
objMod.Parent = objWeapon;
objWeapon.WeaponMods.Add(objMod);
objNode.Text = objMod.DisplayName;
objNode.ContextMenuStrip = cmsVehicleWeaponMod;
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
if (frmPickVehicleMod.AddAgain)
tsVehicleAddWeaponModification_Click(sender, e);
UpdateCharacterInfo();
}
示例3: tsWeaponAddModification_Click
private void tsWeaponAddModification_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_SelectWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponMod"), 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));
frmSelectVehicleMod frmPickVehicleMod = new frmSelectVehicleMod(_objCharacter);
// Make sure the Weapon allows Modifications to be added to it.
// 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 + "\"]");
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (objXmlWeapon["allowmod"] != null)
{
if (objXmlWeapon["allowmod"].InnerText == "false")
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
// Set the Weapon properties for the window.
frmPickVehicleMod.WeaponCost = objWeapon.Cost;
frmPickVehicleMod.TotalWeaponCost = objWeapon.TotalCost;
frmPickVehicleMod.ModMultiplier = objWeapon.ModMultiplier;
frmPickVehicleMod.WindowMode = frmSelectVehicleMod.Mode.WeaponMod;
frmPickVehicleMod.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickVehicleMod.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[id = \"" + frmPickVehicleMod.SelectedMod + "\"]");
TreeNode objNode = new TreeNode();
WeaponMod objMod = new WeaponMod(_objCharacter);
objMod.Create(objXmlMod, objNode);
objMod.Rating = frmPickVehicleMod.SelectedRating;
objMod.Parent = objWeapon;
objWeapon.WeaponMods.Add(objMod);
objNode.Text = objMod.DisplayName;
objNode.ContextMenuStrip = cmsWeaponMod;
treWeapons.SelectedNode.Nodes.Add(objNode);
treWeapons.SelectedNode.Expand();
UpdateCharacterInfo();
RefreshSelectedWeapon();
if (frmPickVehicleMod.AddAgain)
tsWeaponAddModification_Click(sender, e);
}
示例4: tsWeaponAddModification_Click
private void tsWeaponAddModification_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_SelectWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponMod"), 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);
frmSelectVehicleMod frmPickVehicleMod = new frmSelectVehicleMod(_objCharacter, true);
// Make sure the Weapon allows Modifications to be added to it.
// 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 + "\"]");
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (objXmlWeapon["allowmod"] != null)
{
if (objXmlWeapon["allowmod"].InnerText == "false")
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeaponMod"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
// Set the Weapon properties for the window.
frmPickVehicleMod.WeaponCost = objWeapon.Cost;
frmPickVehicleMod.TotalWeaponCost = objWeapon.TotalCost;
frmPickVehicleMod.ModMultiplier = objWeapon.ModMultiplier;
frmPickVehicleMod.InputFile = "weapons";
frmPickVehicleMod.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickVehicleMod.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + frmPickVehicleMod.SelectedMod + "\"]");
TreeNode objNode = new TreeNode();
WeaponMod objMod = new WeaponMod(_objCharacter);
objMod.Create(objXmlMod, objNode);
objMod.Rating = frmPickVehicleMod.SelectedRating;
objMod.Parent = objWeapon;
// Do not allow the user to add a new Weapon Mod if the Weapon's Capacity has been reached.
if (_objOptions.EnforceCapacity && objWeapon.SlotsRemaining - objMod.Slots < 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickVehicleMod.AddAgain)
tsWeaponAddModification_Click(sender, e);
return;
}
// Check the item's Cost and make sure the character can afford it.
int intOriginalCost = objWeapon.TotalCost;
objWeapon.WeaponMods.Add(objMod);
int intCost = objWeapon.TotalCost - intOriginalCost;
// Apply a markup if applicable.
if (frmPickVehicleMod.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickVehicleMod.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
// Multiply the cost if applicable.
if (objMod.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objMod.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
intCost *= _objOptions.ForbiddenCostMultiplier;
if (!frmPickVehicleMod.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
objWeapon.WeaponMods.Remove(objMod);
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickVehicleMod.AddAgain)
tsWeaponAddModification_Click(sender, e);
//.........这里部分代码省略.........
示例5: 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);
//.........这里部分代码省略.........
示例6: UpdateGearInfo
/// <summary>
/// Update the Mod's information based on the Mod selected and current Rating.
/// </summary>
private void UpdateGearInfo()
{
if (lstMod.Text != "")
{
// Retireve the information for the selected Mod.
XmlNode objXmlMod = _objXmlDocument.SelectSingleNode("/chummer/mods/mod[id = \"" + lstMod.SelectedValue + "\"]");
string strAvail = "";
string strModBook = "";
string strModPage = "";
int intItemCost = 0;
int intSlots = 0;
if (_objMode == Mode.Vehicle)
{
TreeNode objTreeNode = new TreeNode();
VehicleMod objVehicleMod = new VehicleMod(_objCharacter);
objVehicleMod.Create(objXmlMod, objTreeNode, Convert.ToInt32(nudRating.Value));
Vehicle objVehicle = new Vehicle(_objCharacter);
objVehicleMod.Parent = objVehicle;
if (_intVehicleCost != 0)
objVehicle.Cost = _intVehicleCost.ToString();
string strAccel = _intAccelWalking.ToString() + "/" + _intAccelRunning.ToString();
objVehicle.Accel = strAccel;
if (_intBody != 0)
objVehicle.Body = _intBody;
if (_intSpeed != 0)
objVehicle.Speed = _intSpeed;
strAvail = objVehicleMod.TotalAvail;
intItemCost = objVehicleMod.TotalCost;
intSlots = objVehicleMod.CalculatedSlots;
strModBook = objVehicleMod.Source;
strModPage = objVehicleMod.Page;
}
else if (_objMode == Mode.WeaponMod)
{
TreeNode objTreeNode = new TreeNode();
WeaponMod objWeaponMod = new WeaponMod(_objCharacter);
objWeaponMod.Create(objXmlMod, objTreeNode);
if (_intWeaponCost != 0)
{
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Cost = _intWeaponCost;
objWeaponMod.Parent = objWeapon;
}
strAvail = objWeaponMod.TotalAvail;
intItemCost = objWeaponMod.TotalCost;
intSlots = objWeaponMod.Slots;
strModBook = objWeaponMod.Source;
strModPage = objWeaponMod.Page;
}
lblAvail.Text = strAvail;
// Cost.
if (objXmlMod["cost"].InnerText.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objXmlMod["cost"].InnerText.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 (intMax == 0)
{
intMax = 1000000;
lblCost.Text = String.Format("{0:###,###,##0¥+}", intMin);
}
else
lblCost.Text = String.Format("{0:###,###,##0}", intMin) + "-" + String.Format("{0:###,###,##0¥}", intMax);
intItemCost = intMin;
}
else
{
int intCost = Convert.ToInt32(Convert.ToDouble(intItemCost, GlobalOptions.Instance.CultureInfo));
intCost *= _intModMultiplier;
// 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);
intItemCost = intCost;
}
//.........这里部分代码省略.........
示例7: CreateAllWeaponModsTest
public void CreateAllWeaponModsTest()
{
// 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/mods/mod"))
{
WeaponMod objMod = new WeaponMod(objCharacter);
objMod.Create(objXmlNode, objNode);
}
}