本文整理汇总了C#中Gear.TotalAvail方法的典型用法代码示例。如果您正苦于以下问题:C# Gear.TotalAvail方法的具体用法?C# Gear.TotalAvail怎么用?C# Gear.TotalAvail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gear
的用法示例。
在下文中一共展示了Gear.TotalAvail方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshSelectedGear
/// <summary>
/// Refresh the information for the currently displayed Gear.
/// </summary>
public void RefreshSelectedGear()
{
bool blnClear = false;
try
{
if (treGear.SelectedNode.Level == 0)
blnClear = true;
}
catch
{
blnClear = true;
}
if (blnClear)
{
_blnSkipRefresh = true;
nudGearRating.Minimum = 0;
nudGearRating.Maximum = 0;
nudGearRating.Enabled = false;
nudGearQty.Enabled = false;
chkGearEquipped.Text = LanguageManager.Instance.GetString("Checkbox_Equipped");
chkGearEquipped.Visible = false;
chkActiveCommlink.Visible = false;
_blnSkipRefresh = false;
return;
}
chkGearHomeNode.Visible = false;
if (treGear.SelectedNode.Level > 0)
{
Gear objGear = new Gear(_objCharacter);
objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
lblGearName.Text = objGear.DisplayNameShort;
lblGearCategory.Text = objGear.DisplayCategory;
lblGearAvail.Text = objGear.TotalAvail(true);
try
{
lblGearCost.Text = String.Format("{0:###,###,##0¥}", objGear.TotalCost);
}
catch
{
lblGearCost.Text = objGear.Cost;
}
lblGearCapacity.Text = objGear.CalculatedCapacity + " (" + objGear.CapacityRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
string strBook = _objOptions.LanguageBookShort(objGear.Source);
string strPage = objGear.Page;
lblGearSource.Text = strBook + " " + strPage;
tipTooltip.SetToolTip(lblGearSource, _objOptions.LanguageBookLong(objGear.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objGear.Page);
if (objGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = (Commlink)objGear;
List<string> objASDF = new List<string>() { objCommlink.Attack.ToString(), objCommlink.Sleaze.ToString(), objCommlink.DataProcessing.ToString(), objCommlink.Firewall.ToString() };
cboGearAttack.BindingContext = new BindingContext();
cboGearAttack.ValueMember = "Value";
cboGearAttack.DisplayMember = "Name";
cboGearAttack.DataSource = objASDF;
cboGearAttack.SelectedIndex = 0;
cboGearAttack.Visible = true;
cboGearSleaze.BindingContext = new BindingContext();
cboGearSleaze.ValueMember = "Value";
cboGearSleaze.DisplayMember = "Name";
cboGearSleaze.DataSource = objASDF;
cboGearSleaze.SelectedIndex = 1;
cboGearDataProcessing.BindingContext = new BindingContext();
cboGearDataProcessing.ValueMember = "Value";
cboGearDataProcessing.DisplayMember = "Name";
cboGearDataProcessing.DataSource = objASDF;
cboGearDataProcessing.SelectedIndex = 2;
cboGearFirewall.BindingContext = new BindingContext();
cboGearFirewall.ValueMember = "Value";
cboGearFirewall.DisplayMember = "Name";
cboGearFirewall.DataSource = objASDF;
cboGearFirewall.SelectedIndex = 3;
lblGearDeviceRating.Text = objCommlink.TotalDeviceRating.ToString();
lblGearDeviceRating.Visible = true;
cboGearAttack.Visible = true;
cboGearSleaze.Visible = true;
cboGearDataProcessing.Visible = true;
cboGearFirewall.Visible = true;
lblGearDeviceRatingLabel.Visible = true;
lblGearAttackLabel.Visible = true;
lblGearSleazeLabel.Visible = true;
lblGearDataProcessingLabel.Visible = true;
lblGearFirewallLabel.Visible = true;
_blnSkipRefresh = true;
chkActiveCommlink.Checked = objCommlink.IsActive;
_blnSkipRefresh = false;
if (objCommlink.Category != "Commlink Upgrade")
chkActiveCommlink.Visible = true;
if (_objCharacter.Metatype == "A.I.")
{
//.........这里部分代码省略.........
示例2: tsWeaponAccessoryGearMenuAddAsPlugin_Click
//.........这里部分代码省略.........
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";
objGear.Cost10 = "0";
}
objNode.Text = objGear.DisplayName;
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 (!frmPickGear.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
_objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickGear.AddAgain)
tsVehicleSensorAddAsPlugin_Click(sender, e);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseWeaponGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.AddWeaponGear, objGear.InternalId, frmPickGear.SelectedQty);
objExpense.Undo = objUndo;
}
}
objNode.ContextMenuStrip = cmsCyberwareGear;
treWeapons.SelectedNode.Nodes.Add(objNode);
treWeapons.SelectedNode.Expand();
objGear.Parent = objSensor;
objSensor.Children.Add(objGear);
if (frmPickGear.AddAgain)
tsWeaponAccessoryGearMenuAddAsPlugin_Click(sender, e);
UpdateCharacterInfo();
RefreshSelectedWeapon();
}
示例3: RefreshSelectedGear
/// <summary>
/// Refresh the information for the currently displayed Gear.
/// </summary>
public void RefreshSelectedGear()
{
bool blnClear = false;
try
{
if (treGear.SelectedNode.Level == 0)
blnClear = true;
}
catch
{
blnClear = true;
}
if (blnClear)
{
lblGearRating.Text = "";
lblGearQty.Text = "";
cmdGearIncreaseQty.Enabled = false;
cmdGearReduceQty.Enabled = false;
chkGearEquipped.Text = LanguageManager.Instance.GetString("Checkbox_Equipped");
chkGearEquipped.Visible = false;
chkActiveCommlink.Visible = false;
cmdGearSplitQty.Enabled = false;
cmdGearMergeQty.Enabled = false;
cmdGearMoveToVehicle.Enabled = false;
return;
}
cmdGearIncreaseQty.Enabled = false;
chkGearHomeNode.Visible = false;
if (treGear.SelectedNode.Level > 0)
{
Gear objGear = new Gear(_objCharacter);
objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
lblGearName.Text = objGear.DisplayNameShort;
lblGearCategory.Text = objGear.DisplayCategory;
lblGearAvail.Text = objGear.TotalAvail(true);
try
{
lblGearCost.Text = String.Format("{0:###,###,##0¥}", objGear.TotalCost);
}
catch
{
lblGearCost.Text = objGear.Cost;
}
lblGearCapacity.Text = objGear.CalculatedCapacity + " (" + objGear.CapacityRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
string strBook = _objOptions.LanguageBookShort(objGear.Source);
string strPage = objGear.Page;
lblGearSource.Text = strBook + " " + strPage;
tipTooltip.SetToolTip(lblGearSource, _objOptions.LanguageBookLong(objGear.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objGear.Page);
if (objGear.Category == "Ammunition")
cmdGearIncreaseQty.Enabled = true;
if (objGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = (Commlink)objGear;
lblGearDeviceRating.Text = objCommlink.TotalDeviceRating.ToString();
lblGearAttack.Text = objCommlink.Attack.ToString();
lblGearSleaze.Text = objCommlink.Sleaze.ToString();
lblGearDataProcessing.Text = objCommlink.DataProcessing.ToString();
lblGearFirewall.Text = objCommlink.Firewall.ToString();
_blnSkipRefresh = true;
chkActiveCommlink.Checked = objCommlink.IsActive;
_blnSkipRefresh = false;
lblGearDeviceRating.Visible = true;
lblGearAttack.Visible = true;
lblGearSleaze.Visible = true;
lblGearDataProcessing.Visible = true;
lblGearFirewall.Visible = true;
lblGearDeviceRatingLabel.Visible = true;
lblGearAttackLabel.Visible = true;
lblGearSleazeLabel.Visible = true;
lblGearDataProcessingLabel.Visible = true;
lblGearFirewallLabel.Visible = true;
if (objCommlink.Category != "Commlink Upgrade")
chkActiveCommlink.Visible = true;
}
else
{
lblGearDeviceRating.Text = objGear.DeviceRating.ToString();
chkActiveCommlink.Visible = false;
lblGearAttack.Visible = false;
lblGearSleaze.Visible = false;
lblGearDataProcessing.Visible = false;
lblGearFirewall.Visible = false;
lblGearAttackLabel.Visible = false;
lblGearSleazeLabel.Visible = false;
lblGearDataProcessingLabel.Visible = false;
lblGearFirewallLabel.Visible = false;
}
if (objGear.MaxRating > 0)
lblGearRating.Text = objGear.Rating.ToString();
else
//.........这里部分代码省略.........
示例4: tsVehicleAddGear_Click
//.........这里部分代码省略.........
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";
objGear.Cost10 = "0";
}
objGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objGear.DisplayName;
// Change the cost of the Sensor itself to 0.
//if (frmPickGear.SelectedCategory == "Sensors")
//{
// objGear.Cost = "0";
// objGear.Cost3 = "0";
// objGear.Cost6 = "0";
// objGear.Cost10 = "0";
//}
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 (!frmPickGear.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickGear.AddAgain)
tsVehicleAddGear_Click(sender, e);
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;
}
}
objNode.ContextMenuStrip = cmsVehicleGear;
bool blnMatchFound = false;
示例5: 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();
}
示例6: PickGear
//.........这里部分代码省略.........
else
{
foreach (Gear objCharacterGear in _objCharacter.Gear)
{
if (objCharacterGear.Name == objNewGear.Name && objCharacterGear.Category == objNewGear.Category && objCharacterGear.Rating == objNewGear.Rating && objCharacterGear.Extra == objNewGear.Extra)
{
blnMatchFound = true;
objStackWith = objCharacterGear;
break;
}
}
}
}
if (blnMatchFound)
{
// If a match was found, we need to use the cost of a single item in the stack which can include plugins.
foreach (Gear objPlugin in objStackWith.Children)
intCost += (objPlugin.TotalCost * frmPickGear.SelectedQty);
}
if (!blnNullParent && !blnAmmoOnly)
intCost *= objSelectedGear.Quantity;
// Apply a markup if applicable.
if (frmPickGear.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickGear.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
// Multiply the cost if applicable.
if (objNewGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objNewGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
intCost *= _objOptions.ForbiddenCostMultiplier;
// Do not allow the user to add a new piece of Cyberware if its Capacity has been reached.
// This is wrapped in a try statement since the character may not have a piece of Gear selected and has clicked the Buy Additional Ammo button for a Weapon.
try
{
if (!blnMatchFound && treGear.SelectedNode.Level > 0)
{
if (_objOptions.EnforceCapacity && objSelectedGear.CapacityRemaining - objNewGear.PluginCapacity < 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
}
}
catch
{
}
// Check the item's Cost and make sure the character can afford it.
if (!frmPickGear.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
// Remove any Improvements created by the Gear.
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objNewGear.InternalId);
return frmPickGear.AddAgain;
}
else
示例7: tsCyberwareAddGear_Click
//.........这里部分代码省略.........
default:
Gear objGear = new Gear(_objCharacter);
objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, true, true, frmPickGear.Aerodynamic);
objGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objGear.DisplayName;
objNewGear = objGear;
break;
}
if (objNewGear.InternalId == Guid.Empty.ToString())
return;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objNewGear.Cost = (Convert.ToDouble(objNewGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Reduce the cost to 10% for Hacked programs.
if (frmPickGear.Hacked)
{
if (objNewGear.Cost != "")
objNewGear.Cost = "(" + objNewGear.Cost + ") * 0.1";
if (objNewGear.Cost3 != "")
objNewGear.Cost3 = "(" + objNewGear.Cost3 + ") * 0.1";
if (objNewGear.Cost6 != "")
objNewGear.Cost6 = "(" + objNewGear.Cost6 + ") * 0.1";
if (objNewGear.Cost10 != "")
objNewGear.Cost10 = "(" + objNewGear.Cost10 + ") * 0.1";
if (objNewGear.Extra == "")
objNewGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
else
objNewGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
}
// If the item was marked as free, change its cost.
if (frmPickGear.FreeCost)
{
objNewGear.Cost = "0";
objNewGear.Cost3 = "0";
objNewGear.Cost6 = "0";
objNewGear.Cost10 = "0";
}
int intCost = objNewGear.TotalCost;
// Multiply the cost if applicable.
if (objNewGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objNewGear.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 (!frmPickGear.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
_objFunctions.DeleteGear(objNewGear, treWeapons, _objImprovementManager);
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickGear.AddAgain)
tsCyberwareAddGear_Click(sender, e);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseCyberwearGear") + " " + objNewGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.AddCyberwareGear, objNewGear.InternalId, 1);
objExpense.Undo = objUndo;
}
}
// Create any Weapons that came with this Gear.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
foreach (TreeNode objWeaponNode in objWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
treWeapons.Nodes[0].Expand();
}
objCyberware.Gear.Add(objNewGear);
objNode.ContextMenuStrip = cmsCyberwareGear;
treCyberware.SelectedNode.Nodes.Add(objNode);
treCyberware.SelectedNode.Expand();
UpdateCharacterInfo();
if (frmPickGear.AddAgain)
tsCyberwareAddGear_Click(sender, e);
_blnIsDirty = true;
UpdateWindowTitle();
}
示例8: PickArmorGear
//.........这里部分代码省略.........
objCommlink.Quantity = frmPickGear.SelectedQty;
objNewGear = objCommlink;
break;
default:
Gear objGear = new Gear(_objCharacter);
objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", false, false, true, true, frmPickGear.Aerodynamic);
objGear.Quantity = frmPickGear.SelectedQty;
objNewGear = objGear;
break;
}
if (objNewGear.InternalId == Guid.Empty.ToString())
return false;
if (!blnNullParent)
objNewGear.Parent = objSelectedGear;
// Reduce the cost for Do It Yourself components.
if (frmPickGear.DoItYourself)
objNewGear.Cost = (Convert.ToDouble(objNewGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
// Apply a markup if applicable.
int intCost = objNewGear.TotalCost;
if (frmPickGear.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickGear.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
// Multiply the cost if applicable.
if (objNewGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objNewGear.TotalAvail().EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
intCost *= _objOptions.ForbiddenCostMultiplier;
// Do not allow the user to add new Gear if the Armor's Capacity has been reached.
if (_objOptions.EnforceCapacity)
{
objSelectedArmor.Gear.Add(objSelectedGear);
if (treArmor.SelectedNode.Level > 1)
{
if (objSelectedGear.CapacityRemaining < 0)
{
objSelectedArmor.Gear.Remove(objSelectedGear);
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return frmPickGear.AddAgain;
}
else
objSelectedArmor.Gear.Remove(objSelectedGear);
}
else
{
if (objSelectedArmor.CapacityRemaining < 0)
{
objSelectedArmor.Gear.Remove(objSelectedGear);
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return frmPickGear.AddAgain;
}
else
objSelectedArmor.Gear.Remove(objSelectedGear);
}
}
示例9: TestGear
private void TestGear()
{
Character objCharacter = new Character();
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
pgbProgress.Minimum = 0;
pgbProgress.Value = 0;
pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/gears/gear").Count;
// Gear.
foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/gears/gear"))
{
pgbProgress.Value++;
Application.DoEvents();
try
{
TreeNode objTempNode = new TreeNode();
Gear objTemp = new Gear(objCharacter);
List<Weapon> lstWeapons = new List<Weapon>();
List<TreeNode> lstNodes = new List<TreeNode>();
objTemp.Create(objXmlGear, objCharacter, objTempNode, 1, lstWeapons, lstNodes, "Blades");
try
{
int objValue = objTemp.TotalCost;
}
catch
{
if (objXmlGear["category"].InnerText != "Mook")
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
}
try
{
string objValue = objTemp.TotalAvail();
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n";
}
try
{
string objValue = objTemp.CalculatedArmorCapacity;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedArmorCapacity\n";
}
try
{
string objValue = objTemp.CalculatedCapacity;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCapacity\n";
}
try
{
int objValue = objTemp.CalculatedCost;
}
catch
{
if (objXmlGear["category"].InnerText != "Mook")
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCost\n";
}
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
}
}
}
示例10: RefreshSelectedGear
/// <summary>
/// Refresh the information for the currently displayed Gear.
/// </summary>
public void RefreshSelectedGear()
{
bool blnClear = false;
try
{
if (treGear.SelectedNode.Level == 0)
blnClear = true;
}
catch
{
blnClear = true;
}
if (blnClear)
{
_blnSkipRefresh = true;
nudGearRating.Minimum = 0;
nudGearRating.Maximum = 0;
nudGearRating.Enabled = false;
nudGearQty.Enabled = false;
chkGearEquipped.Text = LanguageManager.Instance.GetString("Checkbox_Equipped");
chkGearEquipped.Visible = false;
chkActiveCommlink.Visible = false;
_blnSkipRefresh = false;
return;
}
chkGearHomeNode.Visible = false;
if (treGear.SelectedNode.Level > 0)
{
Gear objGear = new Gear(_objCharacter);
objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
lblGearName.Text = objGear.DisplayNameShort;
lblGearCategory.Text = objGear.DisplayCategory;
lblGearAvail.Text = objGear.TotalAvail(true);
try
{
lblGearCost.Text = String.Format("{0:###,###,##0¥}", objGear.TotalCost);
}
catch
{
lblGearCost.Text = objGear.Cost;
}
lblGearCapacity.Text = objGear.CalculatedCapacity + " (" + objGear.CapacityRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
string strBook = _objOptions.LanguageBookShort(objGear.Source);
string strPage = objGear.Page;
lblGearSource.Text = strBook + " " + strPage;
tipTooltip.SetToolTip(lblGearSource, _objOptions.LanguageBookLong(objGear.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objGear.Page);
if (objGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = (Commlink)objGear;
lblGearResponse.Text = objCommlink.TotalResponse.ToString();
lblGearSignal.Text = objCommlink.TotalSignal.ToString();
if (objCommlink.Category != "Commlink Upgrade")
{
lblGearSystem.Text = objCommlink.TotalSystem.ToString();
lblGearFirewall.Text = objCommlink.TotalFirewall.ToString();
}
else
{
lblGearSystem.Text = "";
lblGearFirewall.Text = "";
}
_blnSkipRefresh = true;
chkActiveCommlink.Checked = objCommlink.IsActive;
_blnSkipRefresh = false;
if (objCommlink.Category != "Commlink Upgrade")
chkActiveCommlink.Visible = true;
}
else if (objGear.GetType() == typeof(OperatingSystem))
{
OperatingSystem objOS = (OperatingSystem)objGear;
lblGearResponse.Text = "";
lblGearSignal.Text = "";
lblGearSystem.Text = objOS.System.ToString();
lblGearFirewall.Text = objOS.Firewall.ToString();
chkActiveCommlink.Visible = false;
}
else
{
lblGearResponse.Text = objGear.Response.ToString();
lblGearSignal.Text = objGear.Signal.ToString();
lblGearSystem.Text = objGear.System.ToString();
lblGearFirewall.Text = objGear.Firewall.ToString();
chkActiveCommlink.Visible = false;
}
if (objGear.MaxRating > 0)
{
_blnSkipRefresh = true;
if (objGear.MinRating > 0)
nudGearRating.Minimum = objGear.MinRating;
else if (objGear.MinRating == 0 && objGear.Name.Contains("Credstick,"))
nudGearRating.Minimum = 0;
//.........这里部分代码省略.........
示例11: RefreshSelectedGear
/// <summary>
/// Refresh the information for the currently displayed Gear.
/// </summary>
public void RefreshSelectedGear()
{
bool blnClear = false;
try
{
if (treGear.SelectedNode.Level == 0)
blnClear = true;
}
catch
{
blnClear = true;
}
if (blnClear)
{
lblGearRating.Text = "";
lblGearQty.Text = "";
cmdGearIncreaseQty.Enabled = false;
cmdGearReduceQty.Enabled = false;
chkGearEquipped.Text = LanguageManager.Instance.GetString("Checkbox_Equipped");
chkGearEquipped.Visible = false;
chkActiveCommlink.Visible = false;
cmdGearSplitQty.Enabled = false;
cmdGearMergeQty.Enabled = false;
cmdGearMoveToVehicle.Enabled = false;
tabGearMatrixCM.Visible = false;
return;
}
cmdGearIncreaseQty.Enabled = false;
chkGearHomeNode.Visible = false;
if (treGear.SelectedNode.Level > 0)
{
Gear objGear = new Gear(_objCharacter);
objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
lblGearName.Text = objGear.DisplayNameShort;
lblGearCategory.Text = objGear.DisplayCategory;
lblGearAvail.Text = objGear.TotalAvail(true);
try
{
lblGearCost.Text = String.Format("{0:###,###,##0¥}", objGear.TotalCost);
}
catch
{
lblGearCost.Text = objGear.Cost;
}
lblGearCapacity.Text = objGear.CalculatedCapacity + " (" + objGear.CapacityRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
string strBook = _objOptions.LanguageBookShort(objGear.Source);
string strPage = objGear.Page;
lblGearSource.Text = strBook + " " + strPage;
tipTooltip.SetToolTip(lblGearSource, _objOptions.LanguageBookLong(objGear.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objGear.Page);
_blnSkipRefresh = true;
if (objGear.DeviceRating > 0)
{
tabGearMatrixCM.Visible = true;
foreach (CheckBox objMatrixCM in tabMatrixCM.Controls.OfType<CheckBox>())
{
if (Convert.ToInt32(objMatrixCM.Tag.ToString()) <= objGear.MatrixCM)
{
if (Convert.ToInt32(objMatrixCM.Tag.ToString()) <= objGear.MatrixCMFilled)
objMatrixCM.Checked = true;
else
objMatrixCM.Checked = false;
objMatrixCM.Visible = true;
}
else
{
objMatrixCM.Checked = false;
objMatrixCM.Visible = false;
objMatrixCM.Text = "";
}
}
}
else
{
tabGearMatrixCM.Visible = false;
}
_blnSkipRefresh = false;
if (objGear.Category == "Ammunition")
cmdGearIncreaseQty.Enabled = true;
if (objGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = (Commlink)objGear;
lblGearDeviceRating.Text = objCommlink.TotalDeviceRating.ToString();
_blnSkipRefresh = true;
chkActiveCommlink.Checked = objCommlink.IsActive;
_blnSkipRefresh = false;
cboGearOverclocker.Visible = _objCharacter.Overclocker;
lblGearOverclocker.Visible = _objCharacter.Overclocker;
ArrayList lstOverclocker = new ArrayList();
ListItem objAttribute = new ListItem();
objAttribute.Value = "None";
//.........这里部分代码省略.........
示例12: UpdateGearInfo
/// <summary>
/// Update the Gear's information based on the Gear selected and current Rating.
/// </summary>
private void UpdateGearInfo()
{
if (lstGear.Text != "")
{
// Retireve the information for the selected piece of Cyberware.
XmlNode objXmlGear;
int intItemCost = 0;
string strCategory = "";
objXmlGear = _objXmlDocument.SelectSingleNode("/chummer/gears/gear[id = \"" + lstGear.SelectedValue + "\"]");
strCategory = cboCategory.SelectedValue.ToString();
TreeNode objTreeNode = new TreeNode();
List<Weapon> lstWeapons = new List<Weapon>();
List<TreeNode> lstTreeNodes = new List<TreeNode>();
Gear objGear = new Gear(_objCharacter);
Commlink objCommlink = new Commlink(_objCharacter);
OperatingSystem objOperatingSystem = new OperatingSystem(_objCharacter);
if (objXmlGear["category"].InnerText == "Commlink" || objXmlGear["category"].InnerText == "Commlink Upgrade")
{
objCommlink.Create(objXmlGear, _objCharacter, objTreeNode, Convert.ToInt32(nudRating.Value), false, true);
objGear = (Gear)objCommlink;
}
else if (objXmlGear["category"].InnerText == "Operating System" || objXmlGear["category"].InnerText == "Operating System Upgrade")
{
objOperatingSystem.Create(objXmlGear, _objCharacter, objTreeNode, Convert.ToInt32(nudRating.Value), false, true);
objGear = (Gear)objCommlink;
}
else
objGear.Create(objXmlGear, _objCharacter, objTreeNode, Convert.ToInt32(nudRating.Value), lstWeapons, lstTreeNodes, "", chkHacked.Checked, false, false, true, chkAerodynamic.Checked);
if (_objCharacter.Metatype == "A.I." || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
{
if ((strCategory == "Matrix Programs" || strCategory == "Skillsofts" || strCategory == "Autosofts" || strCategory == "Autosofts, Agent" || strCategory == "Autosofts, Drone") && _objCharacter.Options.BookEnabled("UN") && !lstGear.SelectedValue.ToString().StartsWith("Suite:"))
chkInherentProgram.Visible = true;
else
chkInherentProgram.Visible = false;
chkInherentProgram.Enabled = !chkHacked.Checked;
if (!chkInherentProgram.Enabled)
chkInherentProgram.Checked = false;
}
else
chkInherentProgram.Visible = false;
if (objGear.GetType() == typeof(Commlink))
{
lblGearResponse.Text = objCommlink.TotalResponse.ToString();
lblGearSignal.Text = objCommlink.TotalSignal.ToString();
lblGearSystem.Text = "";
lblGearFirewall.Text = "";
}
else if (objGear.GetType() == typeof(OperatingSystem))
{
lblGearResponse.Text = "";
lblGearSignal.Text = "";
lblGearSystem.Text = objOperatingSystem.System.ToString();
lblGearFirewall.Text = objOperatingSystem.Firewall.ToString();
}
else
{
lblGearResponse.Text = "";
lblGearSignal.Text = "";
lblGearSystem.Text = "";
lblGearFirewall.Text = "";
}
if (objXmlGear["category"].InnerText.EndsWith("Software") || objXmlGear["category"].InnerText.EndsWith("Programs") || objXmlGear["category"].InnerText == "Program Options" || objXmlGear["category"].InnerText.StartsWith("Autosofts") || objXmlGear["category"].InnerText.StartsWith("Skillsoft") || objXmlGear["category"].InnerText == "Program Packages" || objXmlGear["category"].InnerText == "Software Suites")
chkHacked.Visible = true;
else
chkHacked.Visible = false;
string strBook = _objCharacter.Options.LanguageBookShort(objGear.Source);
string strPage = objGear.Page;
lblSource.Text = strBook + " " + strPage;
// Avail.
lblAvail.Text = objGear.TotalAvail();
double dblMultiplier = Convert.ToDouble(nudGearQty.Value / nudGearQty.Increment, GlobalOptions.Instance.CultureInfo);
if (chkDoItYourself.Checked)
dblMultiplier *= 0.5;
// Cost.
if (objGear.Cost.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objGear.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));
//.........这里部分代码省略.........