本文整理汇总了C#中Weapon.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Weapon.Create方法的具体用法?C# Weapon.Create怎么用?C# Weapon.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowNewForm
/// <summary>
/// Create a new character and show the Create Form.
/// </summary>
private void ShowNewForm(object sender, EventArgs e)
{
string strFilePath = Path.Combine(Environment.CurrentDirectory, "settings", "default.xml");
if (!File.Exists(strFilePath))
{
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CharacterOptions_OpenOptions"), LanguageManager.Instance.GetString("MessageTitle_CharacterOptions_OpenOptions"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
frmOptions frmOptions = new frmOptions();
frmOptions.ShowDialog();
}
}
Character objCharacter = new Character();
string settingsPath = Path.Combine(Environment.CurrentDirectory, "settings");
string[] settingsFiles = Directory.GetFiles(settingsPath, "*.xml");
if (settingsFiles.Length > 1)
{
frmSelectSetting frmPickSetting = new frmSelectSetting();
frmPickSetting.ShowDialog(this);
if (frmPickSetting.DialogResult == DialogResult.Cancel)
return;
objCharacter.SettingsFile = frmPickSetting.SettingsFile;
}
else
{
string strSettingsFile = settingsFiles[0];
objCharacter.SettingsFile = Path.GetFileName(strSettingsFile);
}
// Show the BP selection window.
frmSelectBuildMethod frmBP = new frmSelectBuildMethod(objCharacter);
frmBP.ShowDialog();
if (frmBP.DialogResult == DialogResult.Cancel)
return;
if (objCharacter.BuildMethod == CharacterBuildMethod.Karma || objCharacter.BuildMethod == CharacterBuildMethod.LifeModule)
{
frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(objCharacter);
frmSelectMetatype.ShowDialog();
if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
{ return; }
}
// Show the Metatype selection window.
else if (objCharacter.BuildMethod == CharacterBuildMethod.Priority || objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen)
{
frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(objCharacter);
frmSelectMetatype.ShowDialog();
if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
{ return; }
}
// Add the Unarmed Attack Weapon to the character.
try
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]");
TreeNode objDummy = new TreeNode();
Weapon objWeapon = new Weapon(objCharacter);
objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null);
objCharacter.Weapons.Add(objWeapon);
}
catch
{
}
frmCreate frmNewCharacter = new frmCreate(objCharacter);
frmNewCharacter.MdiParent = this;
frmNewCharacter.WindowState = FormWindowState.Maximized;
frmNewCharacter.Show();
objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged;
}
示例2: 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";
}
示例3: Create
/// Create a Gear from an XmlNode and return the TreeNodes for it.
/// <param name="objXmlGear">XmlNode to create the object from.</param>
/// <param name="objCharacter">Character the Gear is being added to.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="intRating">Selected Rating for the Gear.</param>
/// <param name="objWeapons">List of Weapons that should be added to the character.</param>
/// <param name="objWeaponNodes">List of TreeNodes to represent the added Weapons</param>
/// <param name="strForceValue">Value to forcefully select for any ImprovementManager prompts.</param>
/// <param name="blnHacked">Whether or not a Matrix Program has been hacked (removing the Copy Protection and Registration plugins).</param>
/// <param name="blnInherent">Whether or not a Program is Inherent to an A.I.</param>
/// <param name="blnAddImprovements">Whether or not Improvements should be added to the character.</param>
/// <param name="blnCreateChildren">Whether or not child Gear should be created.</param>
/// <param name="blnAerodynamic">Whether or not Weapons should be created as Aerodynamic.</param>
public void Create(XmlNode objXmlGear, Character objCharacter, TreeNode objNode, int intRating, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, string strForceValue = "", bool blnHacked = false, bool blnInherent = false, bool blnAddImprovements = true, bool blnCreateChildren = true, bool blnAerodynamic = false)
{
_strName = objXmlGear["name"].InnerText;
_strCategory = objXmlGear["category"].InnerText;
_strAvail = objXmlGear["avail"].InnerText;
try
{
_strAvail3 = objXmlGear["avail3"].InnerText;
}
catch
{
}
try
{
_strAvail6 = objXmlGear["avail6"].InnerText;
}
catch
{
}
try
{
_strAvail10 = objXmlGear["avail10"].InnerText;
}
catch
{
}
try
{
_strCapacity = objXmlGear["capacity"].InnerText;
}
catch
{
}
try
{
_strArmorCapacity = objXmlGear["armorcapacity"].InnerText;
}
catch
{
}
try
{
_intCostFor = Convert.ToInt32(objXmlGear["costfor"].InnerText);
_intQty = Convert.ToInt32(objXmlGear["costfor"].InnerText);
}
catch
{
}
try
{
_strCost = objXmlGear["cost"].InnerText;
}
catch
{
}
try
{
_strCost3 = objXmlGear["cost3"].InnerText;
}
catch
{
}
try
{
_strCost6 = objXmlGear["cost6"].InnerText;
}
catch
{
}
try
{
_strCost10 = objXmlGear["cost10"].InnerText;
}
catch
{
}
_nodBonus = objXmlGear["bonus"];
_intMaxRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
try
{
_intMinRating = Convert.ToInt32(objXmlGear["minrating"].InnerText);
}
catch
{
}
_intRating = intRating;
_strSource = objXmlGear["source"].InnerText;
//.........这里部分代码省略.........
示例4: mnuNewCritter_Click
private void mnuNewCritter_Click(object sender, EventArgs e)
{
Character objCharacter = new Character();
string settingsPath = Path.Combine(Environment.CurrentDirectory, "settings");
string[] settingsFiles = Directory.GetFiles(settingsPath, "*.xml");
if (settingsFiles.Length > 1)
{
frmSelectSetting frmPickSetting = new frmSelectSetting();
frmPickSetting.ShowDialog(this);
if (frmPickSetting.DialogResult == DialogResult.Cancel)
return;
objCharacter.SettingsFile = frmPickSetting.SettingsFile;
}
else
{
string strSettingsFile = settingsFiles[0];
objCharacter.SettingsFile = Path.GetFileName(strSettingsFile);
}
// Override the defaults for the setting.
objCharacter.IgnoreRules = true;
objCharacter.IsCritter = true;
objCharacter.BuildMethod = CharacterBuildMethod.Karma;
objCharacter.BuildPoints = 0;
// Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book.
bool blnRunningWild = false;
blnRunningWild = (objCharacter.Options.Books.Contains("RW"));
if (!blnRunningWild)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Show the Metatype selection window.
if (objCharacter.BuildMethod == CharacterBuildMethod.Priority)
{
frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(objCharacter);
frmSelectMetatype.XmlFile = "critters.xml";
frmSelectMetatype.ShowDialog();
if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
return;
}
else
{
frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(objCharacter);
frmSelectMetatype.XmlFile = "critters.xml";
frmSelectMetatype.ShowDialog();
if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
return;
}
// Add the Unarmed Attack Weapon to the character.
try
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]");
TreeNode objDummy = new TreeNode();
Weapon objWeapon = new Weapon(objCharacter);
objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null);
objCharacter.Weapons.Add(objWeapon);
}
catch
{
}
frmCreate frmNewCharacter = new frmCreate(objCharacter);
frmNewCharacter.MdiParent = this;
frmNewCharacter.WindowState = FormWindowState.Maximized;
frmNewCharacter.Show();
objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged;
}
示例5: cmdAddWeapon_Click
private void cmdAddWeapon_Click(object sender, EventArgs e)
{
frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter);
frmPickWeapon.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickWeapon.DialogResult == DialogResult.Cancel)
return;
// Open the Weapons XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeaponMod);
_objCharacter.Weapons.Add(objWeapon);
objNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objNode);
treWeapons.Nodes[0].Expand();
treWeapons.SelectedNode = objNode;
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
if (frmPickWeapon.AddAgain)
cmdAddWeapon_Click(sender, e);
}
示例6: tsVehicleAddUnderbarrelWeapon_Click
private void tsVehicleAddUnderbarrelWeapon_Click(object sender, EventArgs e)
{
// Attempt to locate the selected VehicleWeapon.
bool blnWeaponFound = false;
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
Weapon objSelectedWeapon = _objFunctions.FindVehicleWeapon(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (objSelectedWeapon != null)
blnWeaponFound = true;
if (!blnWeaponFound)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleWeaponUnderbarrel"), LanguageManager.Instance.GetString("MessageTitle_VehicleWeaponUnderbarrel"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter);
frmPickWeapon.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickWeapon.DialogResult == DialogResult.Cancel)
return;
// Open the Weapons XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
objWeapon.VehicleMounted = true;
objWeapon.IsUnderbarrelWeapon = true;
objSelectedWeapon.UnderbarrelWeapons.Add(objWeapon);
objNode.ContextMenuStrip = cmsVehicleWeapon;
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
//treWeapons.SelectedNode = objNode;
UpdateCharacterInfo();
}
示例7: CreateCritter
/// <summary>
/// Create a Critter, put them into Career Mode, link them, and open the newly-created Critter.
/// </summary>
/// <param name="strCritterName">Name of the Critter's Metatype.</param>
/// <param name="intForce">Critter's Force.</param>
private void CreateCritter(string strCritterName, int intForce)
{
// The Critter should use the same settings file as the character.
Character objCharacter = new Character();
objCharacter.SettingsFile = _objSpirit.CharacterObject.SettingsFile;
// Override the defaults for the setting.
objCharacter.IgnoreRules = true;
objCharacter.IsCritter = true;
objCharacter.BuildMethod = CharacterBuildMethod.Karma;
objCharacter.BuildPoints = 0;
if (txtCritterName.Text != string.Empty)
objCharacter.Name = txtCritterName.Text;
// Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book.
bool blnRunningWild = false;
blnRunningWild = (objCharacter.Options.Books.Contains("RW"));
if (!blnRunningWild)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Ask the user to select a filename for the new character.
string strForce = LanguageManager.Instance.GetString("String_Force");
if (_objSpirit.EntityType == SpiritType.Sprite)
strForce = LanguageManager.Instance.GetString("String_Rating");
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*";
saveFileDialog.FileName = strCritterName + " (" + strForce + " " + _objSpirit.Force.ToString() + ").chum5";
if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
{
string strFileName = saveFileDialog.FileName;
objCharacter.FileName = strFileName;
}
else
return;
// Code from frmMetatype.
ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");
XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + strCritterName + "\"]");
// If the Critter could not be found, show an error and get out of here.
if (objXmlMetatype == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_UnknownCritterType").Replace("{0}", strCritterName), LanguageManager.Instance.GetString("MessageTitle_SelectCritterType"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Set Metatype information.
if (strCritterName == "Ally Spirit")
{
objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0));
objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0));
objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0));
objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0));
objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0));
objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0));
objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0));
objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0));
objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0));
objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0));
objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0));
objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
}
else
{
int intMinModifier = -3;
if (objXmlMetatype["category"].InnerText == "Mutant Critters")
intMinModifier = 0;
objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3));
objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3));
objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3));
objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3));
objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3));
objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3));
objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3));
objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3));
objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3));
objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3));
objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3));
objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
}
// If we're working with a Critter, set the Attributes to their default values.
objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0));
objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0));
objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0));
objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0));
//.........这里部分代码省略.........
示例8: Load
/// <summary>
/// Load the Character from an XML file.
/// </summary>
public bool Load()
{
XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument.Load(_strFileName);
XmlNode objXmlCharacter = objXmlDocument.SelectSingleNode("/character");
XmlNodeList objXmlNodeList;
try
{
_blnIgnoreRules = Convert.ToBoolean(objXmlCharacter["ignorerules"].InnerText);
}
catch
{
_blnIgnoreRules = false;
}
try
{
_blnCreated = Convert.ToBoolean(objXmlCharacter["created"].InnerText);
}
catch
{
}
ResetCharacter();
// Get the game edition of the file if possible and make sure it's intended to be used with this version of the application.
try
{
if (objXmlCharacter["gameedition"].InnerText != string.Empty && objXmlCharacter["gameedition"].InnerText != "SR5")
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_IncorrectGameVersion_SR4"), LanguageManager.Instance.GetString("MessageTitle_IncorrectGameVersion"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
catch
{
}
// Get the name of the settings file in use if possible.
try
{
_strSettingsFileName = objXmlCharacter["settings"].InnerText;
}
catch
{
}
// Load the character's settings file.
if (!_objOptions.Load(_strSettingsFileName))
return false;
try
{
_decEssenceAtSpecialStart = Convert.ToDecimal(objXmlCharacter["essenceatspecialstart"].InnerText, GlobalOptions.Instance.CultureInfo);
// fix to work around a mistake made when saving decimal values in previous versions.
if (_decEssenceAtSpecialStart > EssenceMaximum)
_decEssenceAtSpecialStart /= 10;
}
catch
{
}
try
{
_strVersionCreated = objXmlCharacter["createdversion"].InnerText;
}
catch
{
}
// Metatype information.
_strMetatype = objXmlCharacter["metatype"].InnerText;
try
{
_strWalk = objXmlCharacter["walk"].InnerText;
_strRun = objXmlCharacter["run"].InnerText;
_strSprint = objXmlCharacter["sprint"].InnerText;
}
catch
{
}
_intMetatypeBP = Convert.ToInt32(objXmlCharacter["metatypebp"].InnerText);
_strMetavariant = objXmlCharacter["metavariant"].InnerText;
try
{
_strMetatypeCategory = objXmlCharacter["metatypecategory"].InnerText;
}
catch
{
}
try
{
_intMutantCritterBaseSkills = Convert.ToInt32(objXmlCharacter["mutantcritterbaseskills"].InnerText);
}
catch
{
//.........这里部分代码省略.........
示例9: tsWeaponAddUnderbarrel_Click
private void tsWeaponAddUnderbarrel_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;
}
if (treWeapons.SelectedNode.Level > 1)
treWeapons.SelectedNode = treWeapons.SelectedNode.Parent;
// Get the information for the currently selected Weapon.
foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
{
if (treWeapons.SelectedNode.Tag.ToString() == objCharacterWeapon.InternalId)
{
if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
{
if (objCharacterWeapon.Category.StartsWith("Cyberware"))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberwareUnderbarrel"), LanguageManager.Instance.GetString("MessageTitle_WeaponUnderbarrel"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
}
}
// Locate the Weapon that is selected in the tree.
Weapon objSelectedWeapon = (Weapon)_objFunctions.FindEquipment(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, typeof(Weapon));
if (objSelectedWeapon == null)
return;
frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter, true);
frmPickWeapon.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickWeapon.DialogResult == DialogResult.Cancel)
return;
// Open the Weapons XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + frmPickWeapon.SelectedWeapon + "\"]");
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeapon);
objWeapon.IsUnderbarrelWeapon = true;
int intCost = objWeapon.TotalCost;
// Apply a markup if applicable.
if (frmPickWeapon.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickWeapon.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
// Check the item's Cost and make sure the character can afford it.
if (!frmPickWeapon.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickWeapon.AddAgain)
cmdAddWeapon_Click(sender, e);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.AddWeapon, objWeapon.InternalId);
objExpense.Undo = objUndo;
}
}
objSelectedWeapon.Weapons.Add(objWeapon);
objNode.ContextMenuStrip = cmsWeapon;
treWeapons.SelectedNode.Nodes.Add(objNode);
treWeapons.SelectedNode.Expand();
treWeapons.SelectedNode = objNode;//
UpdateCharacterInfo();
//.........这里部分代码省略.........
示例10: 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);
//.........这里部分代码省略.........
示例11: tsVehicleAddWeaponWeapon_Click
private void tsVehicleAddWeaponWeapon_Click(object sender, EventArgs e)
{
VehicleMod objMod = new VehicleMod(_objCharacter);
// Make sure that a Weapon Mount has been selected.
try
{
// Attempt to locate the selected VehicleMod.
objMod = (VehicleMod)_objFunctions.FindEquipment(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, typeof(VehicleMod));
if (!objMod.WeaponMount)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter, true);
frmPickWeapon.ShowDialog();
if (frmPickWeapon.DialogResult == DialogResult.Cancel)
return;
// Open the Weapons XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + frmPickWeapon.SelectedWeapon + "\"]");
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
objWeapon.VehicleMounted = true;
int intCost = objWeapon.TotalCost;
// Apply a markup if applicable.
if (frmPickWeapon.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickWeapon.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
if (!frmPickWeapon.FreeCost)
{
// Check the item's Cost and make sure the character can afford it.
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickWeapon.AddAgain)
tsVehicleAddWeaponWeapon_Click(sender, e);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseVehicleWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.AddVehicleWeapon, objWeapon.InternalId);
objExpense.Undo = objUndo;
}
}
objMod.Weapons.Add(objWeapon);
objNode.ContextMenuStrip = cmsVehicleWeapon;
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
if (frmPickWeapon.AddAgain)
tsVehicleAddWeaponWeapon_Click(sender, e);
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例12: Create
/// Create a Vehicle from an XmlNode and return the TreeNodes for it.
/// <param name="objXmlVehicle">XmlNode of the Vehicle to create.</param>
/// <param name="objNode">TreeNode to add to a TreeView.</param>
/// <param name="cmsVehicle">ContextMenuStrip to attach to Weapon Mounts.</param>
/// <param name="cmsVehicleGear">ContextMenuStrip to attach to Gear.</param>
/// <param name="cmsVehicleWeapon">ContextMenuStrip to attach to Vehicle Weapons.</param>
/// <param name="cmsVehicleWeaponAccessory">ContextMenuStrip to attach to Weapon Accessories.</param>
/// <param name="blnCreateChildren">Whether or not child items should be created.</param>
public void Create(XmlNode objXmlVehicle, TreeNode objNode, ContextMenuStrip cmsVehicle, ContextMenuStrip cmsVehicleGear, ContextMenuStrip cmsVehicleWeapon, ContextMenuStrip cmsVehicleWeaponAccessory, bool blnCreateChildren = true)
{
_strName = objXmlVehicle["name"].InnerText;
_strCategory = objXmlVehicle["category"].InnerText;
//Some vehicles have different Offroad Handling speeds. If so, we want to split this up for use with mods and such later.
if (objXmlVehicle["handling"].InnerText.Contains('/'))
{
_intHandling = Convert.ToInt32(objXmlVehicle["handling"].InnerText.Split('/')[0]);
_intOffroadHandling = Convert.ToInt32(objXmlVehicle["handling"].InnerText.Split('/')[1]);
}
else
{
_intHandling = Convert.ToInt32(objXmlVehicle["handling"].InnerText);
}
_intAccel = Convert.ToInt32(objXmlVehicle["accel"].InnerText);
_intSpeed = Convert.ToInt32(objXmlVehicle["speed"].InnerText);
_intPilot = Convert.ToInt32(objXmlVehicle["pilot"].InnerText);
_intBody = Convert.ToInt32(objXmlVehicle["body"].InnerText);
_intArmor = Convert.ToInt32(objXmlVehicle["armor"].InnerText);
_intSensor = Convert.ToInt32(objXmlVehicle["sensor"].InnerText);
try
{
_intDeviceRating = Convert.ToInt32(objXmlVehicle["devicerating"].InnerText);
}
catch
{
}
try
{
_intSeats = Convert.ToInt32(objXmlVehicle["seats"].InnerText);
}
catch
{
}
try
{
_intModSlots = Convert.ToInt32(objXmlVehicle["modslots"].InnerText);
}
catch (NullReferenceException e)
{
_intModSlots = _intBody;
}
_strAvail = objXmlVehicle["avail"].InnerText;
_strCost = objXmlVehicle["cost"].InnerText;
// Check for a Variable Cost.
if (objXmlVehicle["cost"].InnerText.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objXmlVehicle["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 (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}", DisplayNameShort);
frmPickNumber.AllowCancel = false;
frmPickNumber.ShowDialog();
_strCost = frmPickNumber.SelectedValue.ToString();
}
}
_strSource = objXmlVehicle["source"].InnerText;
_strPage = objXmlVehicle["page"].InnerText;
if (GlobalOptions.Instance.Language != "en-us")
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
XmlNode objVehicleNode = objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + _strName + "\"]");
if (objVehicleNode != null)
{
if (objVehicleNode["translate"] != null)
_strAltName = objVehicleNode["translate"].InnerText;
if (objVehicleNode["altpage"] != null)
_strAltPage = objVehicleNode["altpage"].InnerText;
}
objVehicleNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
if (objVehicleNode != null)
{
if (objVehicleNode.Attributes["translate"] != null)
_strAltCategory = objVehicleNode.Attributes["translate"].InnerText;
//.........这里部分代码省略.........
示例13: Create
/// Create a Armor Modification from an XmlNode and return the TreeNodes for it.
/// <param name="objXmlArmorNode">XmlNode to create the object from.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="intRating">Rating of the selected ArmorMod.</param>
/// <param name="objWeapons">List of Weapons that are created by the Armor.</param>
/// <param name="objWeaponNodes">List of Weapon Nodes that are created by the Armor.</param>
/// <param name="blnSkipCost">Whether or not creating the Armor should skip the Variable price dialogue (should only be used by frmSelectArmor).</param>
public void Create(XmlNode objXmlArmorNode, TreeNode objNode, int intRating, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, bool blnSkipCost = false)
{
_strName = objXmlArmorNode["name"].InnerText;
_strCategory = objXmlArmorNode["category"].InnerText;
_strArmorCapacity = objXmlArmorNode["armorcapacity"].InnerText;
_intA = Convert.ToInt32(objXmlArmorNode["armor"].InnerText);
_intRating = intRating;
_intMaxRating = Convert.ToInt32(objXmlArmorNode["maxrating"].InnerText);
_strAvail = objXmlArmorNode["avail"].InnerText;
_strCost = objXmlArmorNode["cost"].InnerText;
_strSource = objXmlArmorNode["source"].InnerText;
_strPage = objXmlArmorNode["page"].InnerText;
_nodBonus = objXmlArmorNode["bonus"];
if (GlobalOptions.Instance.Language != "en-us")
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("armor.xml");
XmlNode objArmorNode = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + _strName + "\"]");
if (objArmorNode != null)
{
if (objArmorNode["translate"] != null)
_strAltName = objArmorNode["translate"].InnerText;
if (objArmorNode["altpage"] != null)
_strAltPage = objArmorNode["altpage"].InnerText;
}
objArmorNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
if (objArmorNode != null)
{
if (objArmorNode.Attributes["translate"] != null)
_strAltCategory = objArmorNode.Attributes["translate"].InnerText;
}
}
if (objXmlArmorNode["bonus"] != null && !blnSkipCost)
{
ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.ArmorMod, _guiID.ToString(), objXmlArmorNode["bonus"], false, intRating, DisplayNameShort))
{
_guiID = Guid.Empty;
return;
}
if (objImprovementManager.SelectedValue != "")
{
_strExtra = objImprovementManager.SelectedValue;
objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
}
}
// Add Weapons if applicable.
if (objXmlArmorNode.InnerXml.Contains("<addweapon>"))
{
XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");
// More than one Weapon can be added, so loop through all occurrences.
foreach (XmlNode objXmlAddWeapon in objXmlArmorNode.SelectNodes("addweapon"))
{
XmlNode objXmlWeapon = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlAddWeapon.InnerText + "\" and starts-with(category, \"Cyberware\")]");
TreeNode objGearWeaponNode = new TreeNode();
Weapon objGearWeapon = new Weapon(_objCharacter);
objGearWeapon.Create(objXmlWeapon, _objCharacter, objGearWeaponNode, null, null);
objGearWeaponNode.ForeColor = SystemColors.GrayText;
objWeaponNodes.Add(objGearWeaponNode);
objWeapons.Add(objGearWeapon);
_guiWeaponID = Guid.Parse(objGearWeapon.InternalId);
}
}
objNode.Text = DisplayName;
objNode.Tag = _guiID.ToString();
}
示例14: 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);
}
示例15: cmdAddWeapon_Click
private void cmdAddWeapon_Click(object sender, EventArgs e)
{
frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter, true);
frmPickWeapon.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickWeapon.DialogResult == DialogResult.Cancel)
return;
// Open the Weapons XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeaponMod);
int intCost = objWeapon.TotalCost;
// Apply a markup if applicable.
if (frmPickWeapon.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickWeapon.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
// Multiply the cost if applicable.
if (objWeapon.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objWeapon.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
intCost *= _objOptions.ForbiddenCostMultiplier;
// Check the item's Cost and make sure the character can afford it.
if (!frmPickWeapon.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickWeapon.AddAgain)
cmdAddWeapon_Click(sender, e);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.AddWeapon, objWeapon.InternalId);
objExpense.Undo = objUndo;
}
}
_objCharacter.Weapons.Add(objWeapon);
objNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objNode);
treWeapons.Nodes[0].Expand();
treWeapons.SelectedNode = objNode;
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
if (frmPickWeapon.AddAgain)
cmdAddWeapon_Click(sender, e);
}