本文整理汇总了C#中Chummer.ExpenseLogEntry.Create方法的典型用法代码示例。如果您正苦于以下问题:C# ExpenseLogEntry.Create方法的具体用法?C# ExpenseLogEntry.Create怎么用?C# ExpenseLogEntry.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chummer.ExpenseLogEntry
的用法示例。
在下文中一共展示了ExpenseLogEntry.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: tsVehicleAddNexus_Click
private void tsVehicleAddNexus_Click(object sender, EventArgs e)
{
// Make sure a parent items is selected, then open the Select Gear window.
try
{
if (treVehicles.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (treVehicles.SelectedNode.Level > 1)
treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;
// Attempt to locate the selected Vehicle.
Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
frmSelectNexus frmPickNexus = new frmSelectNexus(_objCharacter, true);
frmPickNexus.ShowDialog(this);
if (frmPickNexus.DialogResult == DialogResult.Cancel)
return;
Gear objGear = new Gear(_objCharacter);
objGear = frmPickNexus.SelectedNexus;
int intCost = objGear.TotalCost;
// Multiply the cost if applicable.
if (objGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objGear.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 (!frmPickNexus.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseVehicleGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.AddVehicleGear, objGear.InternalId, 1);
objExpense.Undo = objUndo;
}
}
TreeNode nodNexus = new TreeNode();
nodNexus.Text = objGear.Name;
nodNexus.Tag = objGear.InternalId;
nodNexus.ContextMenuStrip = cmsVehicleGear;
foreach (Gear objChild in objGear.Children)
{
TreeNode nodModule = new TreeNode();
nodModule.Text = objChild.Name;
nodModule.Tag = objChild.InternalId;
nodModule.ContextMenuStrip = cmsVehicleGear;
nodNexus.Nodes.Add(nodModule);
nodNexus.Expand();
}
treVehicles.SelectedNode.Nodes.Add(nodNexus);
treVehicles.SelectedNode.Expand();
objSelectedVehicle.Gear.Add(objGear);
UpdateCharacterInfo();
RefreshSelectedVehicle();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例2: cmdSwapQuality_Click
private void cmdSwapQuality_Click(object sender, EventArgs e)
{
// Locate the selected Quality.
try
{
if (treQualities.SelectedNode.Level == 0)
return;
}
catch
{
return;
}
Quality objQuality = _objFunctions.FindQuality(treQualities.SelectedNode.Tag.ToString(), _objCharacter.Qualities);
// Qualities that come from a Metatype cannot be removed.
if (objQuality.OriginSource == QualitySource.Metatype)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_MetavariantQualitySwap"), LanguageManager.Instance.GetString("MessageTitle_MetavariantQualitySwap"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectQuality frmPickQuality = new frmSelectQuality(_objCharacter);
frmPickQuality.ForceCategory = objQuality.Type.ToString();
frmPickQuality.IgnoreQuality = objQuality.Name;
frmPickQuality.ShowDialog(this);
// Don't do anything else if the form was canceled.
if (frmPickQuality.DialogResult == DialogResult.Cancel)
return;
XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
XmlNode objXmlQuality = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + frmPickQuality.SelectedQuality + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objNewQuality = new Quality(_objCharacter);
objNewQuality.Create(objXmlQuality, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes);
objNode.ContextMenuStrip = cmsQuality;
if (objQuality.InternalId == Guid.Empty.ToString())
return;
bool blnAddItem = true;
int intKarmaCost = (objNewQuality.BP - objQuality.BP) * _objOptions.KarmaQuality;
// Make sure the character has enough Karma to pay for the Quality.
if (objNewQuality.Type == QualityType.Positive)
{
if (intKarmaCost > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
blnAddItem = false;
}
if (blnAddItem)
{
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_QualitySwap").Replace("{0}", objQuality.DisplayNameShort).Replace("{1}", objNewQuality.DisplayNameShort)))
blnAddItem = false;
}
if (blnAddItem)
{
// Create the Karma expense.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseSwapPositiveQuality").Replace("{0}", objQuality.DisplayNameShort).Replace("{1}", objNewQuality.DisplayNameShort), ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaCost;
}
}
else
{
// This should only happen when a character is trading up to a less-costly Quality.
if (intKarmaCost > 0)
{
if (intKarmaCost > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
blnAddItem = false;
}
if (blnAddItem)
{
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_QualitySwap").Replace("{0}", objQuality.Name).Replace("{1}", objNewQuality.Name)))
blnAddItem = false;
}
if (blnAddItem)
{
// Create the Karma expense.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseSwapNegativeQuality").Replace("{0}", objQuality.DisplayNameShort).Replace("{1}", objNewQuality.DisplayNameShort), ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaCost;
}
}
}
if (blnAddItem)
//.........这里部分代码省略.........
示例3: SaveCharacterAsCreated
/// <summary>
/// Save the character as Created and re-open it in Career Mode.
/// </summary>
private void SaveCharacterAsCreated()
{
// If the character was built with Karma, record their staring Karma amount (if any).
if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
{
if (_objCharacter.Karma > 0)
{
ExpenseLogEntry objKarma = new ExpenseLogEntry();
objKarma.Create(_objCharacter.Karma, "Starting Karma", ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objKarma);
// Create an Undo entry so that the starting Karma amount can be modified if needed.
ExpenseUndo objKarmaUndo = new ExpenseUndo();
objKarmaUndo.CreateKarma(KarmaExpenseType.ManualAdd, "");
objKarma.Undo = objKarmaUndo;
}
}
// Create an Expense Entry for Starting Nuyen.
ExpenseLogEntry objNuyen = new ExpenseLogEntry();
objNuyen.Create(_objCharacter.Nuyen, "Starting Nuyen", ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objNuyen);
// Create an Undo entry so that the Starting Nuyen amount can be modified if needed.
ExpenseUndo objNuyenUndo = new ExpenseUndo();
objNuyenUndo.CreateNuyen(NuyenExpenseType.ManualAdd, "");
objNuyen.Undo = objNuyenUndo;
_blnSkipToolStripRevert = true;
_objCharacter.Save();
GlobalOptions.Instance.MainForm.LoadCharacter(_objCharacter.FileName, false);
this.Close();
}
示例4: cmdIncreasePowerPoints_Click
private void cmdIncreasePowerPoints_Click(object sender, EventArgs e)
{
// Make sure the character has enough Karma to improve the Attribute.
int intKarmaCost = 5;
if (intKarmaCost > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (_objCharacter.MAGAdept + 1 > _objCharacter.MAG.TotalValue)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughMagic"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughMagic"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSpend").Replace("{0}", LanguageManager.Instance.GetString("String_PowerPoint")).Replace("{1}", (intKarmaCost).ToString())))
return;
// Create the Karma expense.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_PowerPoint"), ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.AddPowerPoint, "");
objExpense.Undo = objUndo;
_objCharacter.MAGAdept += 1;
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例5: cmdNuyenSpent_Click
private void cmdNuyenSpent_Click(object sender, EventArgs e)
{
frmExpense frmNewExpense = new frmExpense();
frmNewExpense.Mode = ExpenseType.Nuyen;
frmNewExpense.ShowDialog(this);
if (frmNewExpense.DialogResult == DialogResult.Cancel)
return;
// Make sure the Nuyen expense would not put the character's remaining Nuyen amount below 0.
if (_objCharacter.Nuyen - frmNewExpense.Amount < 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Create the Expense Log Entry.
ExpenseLogEntry objEntry = new ExpenseLogEntry();
objEntry.Create(frmNewExpense.Amount * -1, frmNewExpense.strReason, ExpenseType.Nuyen, frmNewExpense.SelectedDate);
_objCharacter.ExpenseEntries.Add(objEntry);
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.ManualSubtract, "");
objEntry.Undo = objUndo;
// Adjust the character's Nuyen total.
_objCharacter.Nuyen += frmNewExpense.Amount * -1;
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例6: cmdImproveInitiation_Click
private void cmdImproveInitiation_Click(object sender, EventArgs e)
{
if (_objCharacter.MAGEnabled)
{
// Make sure that the Initiate Grade is not attempting to go above the character's MAG Attribute.
if (_objCharacter.InitiateGrade + 1 > _objCharacter.MAG.TotalValue)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotIncreaseInitiateGrade"), LanguageManager.Instance.GetString("MessageTitle_CannotIncreaseInitiateGrade"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the character has enough Karma.
double dblMultiplier = 1.0;
dblMultiplier = Math.Round(dblMultiplier, 2);
int intKarmaExpense = Convert.ToInt32(Math.Ceiling(Convert.ToDouble((10 + ((_objCharacter.InitiateGrade + 1) * _objOptions.KarmaInitiation)), GlobalOptions.Instance.CultureInfo) * dblMultiplier));
if (intKarmaExpense > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpense").Replace("{0}", LanguageManager.Instance.GetString("String_InitiateGrade")).Replace("{1}", (_objCharacter.InitiateGrade + 1).ToString()).Replace("{2}", intKarmaExpense.ToString())))
return;
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaExpense * -1, LanguageManager.Instance.GetString("String_ExpenseInitiateGrade") + " " + _objCharacter.InitiateGrade.ToString() + " -> " + (_objCharacter.InitiateGrade + 1).ToString(), ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaExpense;
// Create the Initiate Grade object.
InitiationGrade objGrade = new InitiationGrade(_objCharacter);
objGrade.Create(_objCharacter.InitiateGrade + 1, _objCharacter.RESEnabled, chkInitiationGroup.Checked, chkInitiationOrdeal.Checked, chkInitiationSchooling.Checked);
_objCharacter.InitiationGrades.Add(objGrade);
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.ImproveInitiateGrade, objGrade.InternalId);
objExpense.Undo = objUndo;
// Set the character's Initiate Grade.
_objCharacter.InitiateGrade += 1;
// Remove any existing Initiation Improvements.
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Initiation, "Initiation");
// Create the replacement Improvement.
_objImprovementManager.CreateImprovement("MAG", Improvement.ImprovementSource.Initiation, "Initiation", Improvement.ImprovementType.Attribute, "", 0, 1, 0, _objCharacter.InitiateGrade);
_objImprovementManager.Commit();
// Update any Metamagic Improvements the character might have.
foreach (Metamagic objMetamagic in _objCharacter.Metamagics)
{
if (objMetamagic.Bonus != null)
{
// If the Bonus contains "Rating", remove the existing Improvement and create new ones.
if (objMetamagic.Bonus.InnerXml.Contains("Rating"))
{
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Metamagic, objMetamagic.InternalId);
_objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metamagic, objMetamagic.InternalId, objMetamagic.Bonus, false, _objCharacter.InitiateGrade, objMetamagic.DisplayNameShort);
}
}
}
int intAmount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble((10 + ((_objCharacter.InitiateGrade + 1) * _objOptions.KarmaInitiation)), GlobalOptions.Instance.CultureInfo) * dblMultiplier));
string strInitTip = LanguageManager.Instance.GetString("Tip_ImproveInitiateGrade").Replace("{0}", (_objCharacter.InitiateGrade + 1).ToString()).Replace("{1}", intAmount.ToString());
tipTooltip.SetToolTip(cmdAddMetamagic, strInitTip);
}
else if (_objCharacter.RESEnabled)
{
// Make sure that the Initiate Grade is not attempting to go above the character's RES Attribute.
if (_objCharacter.SubmersionGrade + 1 > _objCharacter.RES.TotalValue)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotIncreaseSubmersionGrade"), LanguageManager.Instance.GetString("MessageTitle_CannotIncreaseSubmersionGrade"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the character has enough Karma.
double dblMultiplier = 1.0;
dblMultiplier = Math.Round(dblMultiplier, 2);
int intKarmaExpense = Convert.ToInt32(Math.Ceiling(Convert.ToDouble((10 + ((_objCharacter.SubmersionGrade + 1) * _objOptions.KarmaInitiation)), GlobalOptions.Instance.CultureInfo) * dblMultiplier));
if (intKarmaExpense > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpense").Replace("{0}", LanguageManager.Instance.GetString("String_SubmersionGrade")).Replace("{1}", (_objCharacter.SubmersionGrade + 1).ToString()).Replace("{2}", intKarmaExpense.ToString())))
return;
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaExpense * -1, LanguageManager.Instance.GetString("String_ExpenseSubmersionGrade") + " " + _objCharacter.SubmersionGrade.ToString() + " -> " + (_objCharacter.SubmersionGrade + 1).ToString(), ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaExpense;
//.........这里部分代码省略.........
示例7: cmdImproveWIL_Click
private void cmdImproveWIL_Click(object sender, EventArgs e)
{
// Make sure the character has enough Karma to improve the Attribute.
int intKarmaCost = (_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers + 1) * _objOptions.KarmaAttribute;
if (_objOptions.AlternateMetatypeAttributeKarma)
intKarmaCost -= (_objCharacter.WIL.MetatypeMinimum - 1) * _objOptions.KarmaAttribute;
if (intKarmaCost > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpense").Replace("{0}", LanguageManager.Instance.GetString("String_AttributeWILShort")).Replace("{1}", (_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers + 1).ToString()).Replace("{2}", intKarmaCost.ToString())))
return;
// Create the Karma expense.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseAttribute") + " " + LanguageManager.Instance.GetString("String_AttributeWILShort") + " " + (_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers).ToString() + " -> " + (_objCharacter.WIL.Value + _objCharacter.WIL.AttributeValueModifiers + 1).ToString(), ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.ImproveAttribute, "WIL");
objExpense.Undo = objUndo;
_objCharacter.WIL.Value += 1;
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例8: tsWeaponSell_Click
private void tsWeaponSell_Click(object sender, EventArgs e)
{
// Delete the selected Weapon.
try
{
if (treWeapons.SelectedNode.Level == 1)
{
Weapon objWeapon = new Weapon(_objCharacter);
// Locate the Weapon that is selected in the tree.
foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
{
if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
{
objWeapon = objCharacterWeapon;
break;
}
}
// Cyberweapons cannot be removed through here and must be done by removing the piece of Cyberware.
if (objWeapon.Cyberware)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveCyberweapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveCyberweapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (objWeapon.Category == "Gear")
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveGearWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveGearWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (objWeapon.Category.StartsWith("Quality"))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveQualityWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveQualityWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSellItem frmSell = new frmSellItem();
frmSell.ShowDialog(this);
if (frmSell.DialogResult == DialogResult.Cancel)
return;
// Create the Expense Log Entry for the sale.
int intAmount = Convert.ToInt32(Convert.ToDouble(objWeapon.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen += intAmount;
_objCharacter.Weapons.Remove(objWeapon);
treWeapons.SelectedNode.Remove();
}
else if (treWeapons.SelectedNode.Level > 1)
{
Weapon objWeapon = new Weapon(_objCharacter);
// Locate the Weapon that is selected in the tree.
foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
{
if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Parent.Tag.ToString())
{
objWeapon = objCharacterWeapon;
break;
}
}
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
// Locate the Accessory that is selected in the tree.
foreach (WeaponAccessory objCharacterAccessory in objWeapon.WeaponAccessories)
{
if (objCharacterAccessory.InternalId == treWeapons.SelectedNode.Tag.ToString())
{
objAccessory = objCharacterAccessory;
break;
}
}
if (objAccessory.Name != "")
{
frmSellItem frmSell = new frmSellItem();
frmSell.ShowDialog(this);
if (frmSell.DialogResult == DialogResult.Cancel)
return;
// Record the Weapon's original cost.
int intOriginal = objWeapon.TotalCost;
objWeapon.WeaponAccessories.Remove(objAccessory);
treWeapons.SelectedNode.Remove();
int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objWeapon.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeaponAccessory") + " " + objAccessory.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen += intAmount;
}
WeaponMod objMod = new WeaponMod(_objCharacter);
// Locate the Mod that is selected in the tree.
foreach (WeaponMod objCharacterMod in objWeapon.WeaponMods)
{
//.........这里部分代码省略.........
示例9: chkJoinGroup_CheckedChanged
private void chkJoinGroup_CheckedChanged(object sender, EventArgs e)
{
if (_blnSkipRefresh || _blnLoading)
return;
// Joining a Network does not cost Karma for Technomancers, so this only applies to Magicians/Adepts.
if (_objCharacter.MAGEnabled)
{
if (chkJoinGroup.Checked)
{
int intKarmaExpense = _objOptions.KarmaJoinGroup;
if (intKarmaExpense > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
_blnSkipRefresh = true;
chkJoinGroup.Checked = false;
_blnSkipRefresh = false;
return;
}
string strMessage = "";
string strExpense = "";
if (_objCharacter.MAGEnabled)
{
strMessage = LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseJoinGroup");
strExpense = LanguageManager.Instance.GetString("String_ExpenseJoinGroup");
}
else
{
strMessage = LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseJoinNetwork");
strExpense = LanguageManager.Instance.GetString("String_ExpenseJoinNetwork");
}
if (!ConfirmKarmaExpense(strMessage.Replace("{0}", intKarmaExpense.ToString())))
{
_blnSkipRefresh = true;
chkJoinGroup.Checked = false;
_blnSkipRefresh = false;
return;
}
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaExpense * -1, strExpense, ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaExpense;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.JoinGroup, "");
objExpense.Undo = objUndo;
_objCharacter.GroupMember = chkJoinGroup.Checked;
UpdateCharacterInfo();
}
else
{
int intKarmaExpense = _objOptions.KarmaLeaveGroup;
if (intKarmaExpense > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
_blnSkipRefresh = true;
chkJoinGroup.Checked = true;
_blnSkipRefresh = false;
return;
}
string strMessage = "";
string strExpense = "";
if (_objCharacter.MAGEnabled)
{
strMessage = LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseLeaveGroup");
strExpense = LanguageManager.Instance.GetString("String_ExpenseLeaveGroup");
}
else
{
strMessage = LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseLeaveNetwork");
strExpense = LanguageManager.Instance.GetString("String_ExpenseLeaveNetwork");
}
if (!ConfirmKarmaExpense(strMessage.Replace("{0}", intKarmaExpense.ToString())))
{
_blnSkipRefresh = true;
chkJoinGroup.Checked = true;
_blnSkipRefresh = false;
return;
}
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaExpense * -1, strExpense, ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaExpense;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.LeaveGroup, "");
objExpense.Undo = objUndo;
_objCharacter.GroupMember = chkJoinGroup.Checked;
//.........这里部分代码省略.........
示例10: 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.
//.........这里部分代码省略.........
示例11: 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);
//.........这里部分代码省略.........
示例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 "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";
//.........这里部分代码省略.........
示例13: tsVehicleSell_Click
private void tsVehicleSell_Click(object sender, EventArgs e)
{
// Delete the selected Vehicle.
try
{
if (treVehicles.SelectedNode.Level == 1)
{
Vehicle objVehicle = new Vehicle(_objCharacter);
// Locate the Vehicle that is selected in the tree.
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objVehicle = objCharacterVehicle;
break;
}
}
frmSellItem frmSell = new frmSellItem();
frmSell.ShowDialog(this);
if (frmSell.DialogResult == DialogResult.Cancel)
return;
// Create the Expense Log Entry for the sale.
int intAmount = Convert.ToInt32(Convert.ToDouble(objVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicle") + " " + objVehicle.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen += intAmount;
_objCharacter.Vehicles.Remove(objVehicle);
treVehicles.SelectedNode.Remove();
}
else if (treVehicles.SelectedNode.Level == 2)
{
// Locate the VehicleMod that is selected in the tree.
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
foreach (VehicleMod objMod in objCharacterVehicle.Mods)
{
if (objMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
// Do not allow VehicleMods that come with a Vehicle to be removed.
if (objMod.IncludedInVehicle)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveVehicleMod"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveVehicleMod"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
frmSellItem frmSell = new frmSellItem();
frmSell.ShowDialog(this);
if (frmSell.DialogResult == DialogResult.Cancel)
return;
// Record the original value of the Vehicle.
int intOriginal = objCharacterVehicle.TotalCost;
// Check for Improved Sensor bonus.
if (objMod.Bonus != null)
{
if (objMod.Bonus["improvesensor"] != null)
{
ChangeVehicleSensor(objCharacterVehicle, false);
}
}
objCharacterVehicle.Mods.Remove(objMod);
treVehicles.SelectedNode.Remove();
// Create the Expense Log Entry for the sale.
int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen += intAmount;
}
break;
}
}
}
// Locate the Sensor or Ammunition that is selected in the tree.
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
foreach (Gear objGear in objCharacterVehicle.Gear)
{
if (objGear.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
frmSellItem frmSell = new frmSellItem();
frmSell.ShowDialog(this);
if (frmSell.DialogResult == DialogResult.Cancel)
return;
// Record the original value of the vehicle.
int intOriginal = objCharacterVehicle.TotalCost;
//.........这里部分代码省略.........
示例14: 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
{
//.........这里部分代码省略.........
示例15: cmdDeleteVehicle_Click
private void cmdDeleteVehicle_Click(object sender, EventArgs e)
{
// Delete the selected Vehicle.
try
{
if (treVehicles.SelectedNode.Level == 0)
return;
}
catch
{
return;
}
if (treVehicles.SelectedNode.Level != 2)
{
if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
return;
}
if (treVehicles.SelectedNode.Level == 1)
{
// Locate the Vehicle that is selected in the tree.
Vehicle objVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
// Remove any Gear Improvements from the character (primarily those provided by an Emotitoy).
foreach (Gear objGear in objVehicle.Gear)
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
_objCharacter.Vehicles.Remove(objVehicle);
treVehicles.SelectedNode.Remove();
}
else if (treVehicles.SelectedNode.Level == 2)
{
bool blnFound = false;
// Locate the VehicleMod that is selected in the tree.
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
VehicleMod objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (objMod != null)
{
blnFound = true;
if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
return;
// Check for Improved Sensor bonus.
if (objMod.Bonus != null)
{
if (objMod.Bonus["improvesensor"] != null)
{
ChangeVehicleSensor(objFoundVehicle, false);
}
}
// If this is the Obsolete Mod, the user must select a percentage. This will create an Expense that costs X% of the Vehicle's base cost to remove the special Obsolete Mod.
if (objMod.Name == "Obsolete" || (objMod.Name == "Obsolescent" && _objOptions.AllowObsolescentUpgrade))
{
frmSelectNumber frmModPercent = new frmSelectNumber();
frmModPercent.Minimum = 0;
frmModPercent.Maximum = 1000;
frmModPercent.Description = LanguageManager.Instance.GetString("String_Retrofit");
frmModPercent.ShowDialog(this);
if (frmModPercent.DialogResult == DialogResult.Cancel)
return;
int intPercentage = frmModPercent.SelectedValue;
int intVehicleCost = Convert.ToInt32(objFoundVehicle.Cost);
// Make sure the character has enough Nuyen for the expense.
int intCost = Convert.ToInt32(Convert.ToDouble(intVehicleCost, GlobalOptions.Instance.CultureInfo) * (Convert.ToDouble(intPercentage, GlobalOptions.Instance.CultureInfo) / 100.0), GlobalOptions.Instance.CultureInfo);
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Create a Vehicle Mod for the Retrofit.
VehicleMod objRetrofit = new VehicleMod(_objCharacter);
XmlDocument objVehiclesDoc = XmlManager.Instance.Load("vehicles.xml");
XmlNode objXmlNode = objVehiclesDoc.SelectSingleNode("/chummer/mods/mod[name = \"Retrofit\"]");
TreeNode objTreeNode = new TreeNode();
objRetrofit.Create(objXmlNode, objTreeNode, 0);
objRetrofit.Cost = intCost.ToString();
objFoundVehicle.Mods.Add(objRetrofit);
treVehicles.SelectedNode.Parent.Nodes.Add(objTreeNode);
// Create an Expense Log Entry for removing the Obsolete Mod.
ExpenseLogEntry objEntry = new ExpenseLogEntry();
objEntry.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpenseVehicleRetrofit").Replace("{0}", objFoundVehicle.DisplayName), ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objEntry);
// Adjust the character's Nuyen total.
_objCharacter.Nuyen += intCost * -1;
}
objFoundVehicle.Mods.Remove(objMod);
treVehicles.SelectedNode.Remove();
}
//.........这里部分代码省略.........