本文整理汇总了C#中VehicleMod类的典型用法代码示例。如果您正苦于以下问题:C# VehicleMod类的具体用法?C# VehicleMod怎么用?C# VehicleMod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VehicleMod类属于命名空间,在下文中一共展示了VehicleMod类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (!objMod.Name.StartsWith("Weapon Mount") && !objMod.Name.StartsWith("Heavy Weapon Mount") && !objMod.Name.StartsWith("Mechanical Arm"))
{
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);
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[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");
TreeNode objNode = new TreeNode();
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
objWeapon.VehicleMounted = true;
objMod.Weapons.Add(objWeapon);
objNode.ContextMenuStrip = cmsVehicleWeapon;
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
if (frmPickWeapon.AddAgain)
tsVehicleAddWeaponWeapon_Click(sender, e);
UpdateCharacterInfo();
}
示例2: 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);
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);
}
objFoundVehicle.Mods.Remove(objMod);
treVehicles.SelectedNode.Remove();
}
if (!blnFound)
{
// 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())
{
if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
return;
// Remove the Gear Weapon created by the Gear if applicable.
if (objGear.WeaponID != Guid.Empty.ToString())
{
//.........这里部分代码省略.........
示例3: tsVehicleAddMod_Click
private void tsVehicleAddMod_Click(object sender, EventArgs e)
{
// Make sure a parent items is selected, then open the Select Vehicle Mod window.
try
{
if (treVehicles.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (treVehicles.SelectedNode.Level > 1)
treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;
Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
frmSelectVehicleMod frmPickVehicleMod = new frmSelectVehicleMod(_objCharacter);
// Set the Vehicle properties for the window.
frmPickVehicleMod.VehicleCost = Convert.ToInt32(objSelectedVehicle.Cost);
frmPickVehicleMod.Body = objSelectedVehicle.TotalBody;
frmPickVehicleMod.Seats = objSelectedVehicle.Seats;
frmPickVehicleMod.Handling = objSelectedVehicle.Handling;
frmPickVehicleMod.Speed = objSelectedVehicle.Speed;
frmPickVehicleMod.Accel = objSelectedVehicle.Accel;
frmPickVehicleMod.DeviceRating = objSelectedVehicle.DeviceRating;
frmPickVehicleMod.HasModularElectronics = objSelectedVehicle.HasModularElectronics();
frmPickVehicleMod.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickVehicleMod.DialogResult == DialogResult.Cancel)
return;
// Open the Vehicles XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + frmPickVehicleMod.SelectedMod + "\"]");
TreeNode objNode = new TreeNode();
VehicleMod objMod = new VehicleMod(_objCharacter);
objMod.Create(objXmlMod, objNode, frmPickVehicleMod.SelectedRating);
// Make sure that the Armor Rating does not exceed the maximum allowed by the Vehicle.
if (objMod.Name.StartsWith("Armor"))
{
if (objMod.Rating > objSelectedVehicle.MaxArmor)
{
objMod.Rating = objSelectedVehicle.MaxArmor;
objNode.Text = objMod.DisplayName;
}
}
objSelectedVehicle.Mods.Add(objMod);
objNode.ContextMenuStrip = cmsVehicle;
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
RefreshSelectedVehicle();
// Check for Improved Sensor bonus.
if (objMod.Bonus != null)
{
if (objMod.Bonus["selecttext"] != null)
{
frmSelectText frmPickText = new frmSelectText();
frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText").Replace("{0}", objMod.DisplayNameShort);
frmPickText.ShowDialog(this);
objMod.Extra = frmPickText.SelectedValue;
objNode.Text = objMod.DisplayName;
}
if (objMod.Bonus["improvesensor"] != null)
{
ChangeVehicleSensor(objSelectedVehicle, true);
}
}
_blnIsDirty = true;
UpdateWindowTitle();
if (frmPickVehicleMod.AddAgain)
tsVehicleAddMod_Click(sender, e);
}
示例4: RefreshPasteStatus
//.........这里部分代码省略.........
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
{
// Gear can only be pasted into Vehicles and Vehicle Gear.
try
{
foreach (Vehicle objVehicle in _objCharacter.Vehicles)
{
if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
blnPasteEnabled = true;
break;
}
}
}
catch
{
}
try
{
Vehicle objVehicle = new Vehicle(_objCharacter);
Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
if (objGear != null)
blnPasteEnabled = true;
}
catch
{
}
}
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon)
{
// Weapons can only be pasted into Vehicle Mods that allow them (Weapon Mounts and Mechanical Arms).
try
{
VehicleMod objMod = new VehicleMod(_objCharacter);
foreach (Vehicle objVehicle in _objCharacter.Vehicles)
{
foreach (VehicleMod objVehicleMod in objVehicle.Mods)
{
if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
{
blnPasteEnabled = true;
break;
}
}
}
}
}
catch
{
}
}
try
{
foreach (Vehicle objVehicle in _objCharacter.Vehicles)
{
if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
blnCopyEnabled = true;
break;
}
}
}
catch
示例5: mnuEditPaste_Click
//.........这里部分代码省略.........
switch (objXmlNode["category"].InnerText)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Load(objXmlNode, true);
objGear = objCommlink;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Load(objXmlNode, true);
objGear = objNewGear;
break;
}
// Paste the Gear into a Vehicle.
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objCharacterVehicle.Gear.Add(objGear);
TreeNode objNode = new TreeNode();
objNode.Text = objGear.DisplayName;
objNode.Tag = objGear.InternalId;
objNode.ContextMenuStrip = cmsVehicleGear;
objVehicle = objCharacterVehicle;
_objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
}
}
// Paste the Gear into a Vehicle's Gear.
Vehicle objTempVehicle = objVehicle;
Gear objVehicleGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
if (objVehicle == null)
objVehicle = objTempVehicle;
if (objVehicleGear != null)
{
objVehicleGear.Children.Add(objGear);
objGear.Parent = objVehicleGear;
TreeNode objNode = new TreeNode();
objNode.Text = objGear.DisplayName;
objNode.Tag = objGear.InternalId;
objNode.ContextMenuStrip = cmsVehicleGear;
_objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);
treVehicles.SelectedNode.Nodes.Add(objNode);
treVehicles.SelectedNode.Expand();
}
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
return;
}
// Paste Weapon.
Weapon objWeapon = new Weapon(_objCharacter);
objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
if (objXmlNode != null)
{
objWeapon.Load(objXmlNode, true);
objWeapon.VehicleMounted = true;
try
{
// Weapons can only be added to Vehicle Mods that support them (Weapon Mounts and Mechanical Arms).
VehicleMod objMod = new VehicleMod(_objCharacter);
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
{
if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
{
objVehicleMod.Weapons.Add(objWeapon);
_objFunctions.CreateWeaponTreeNode(objWeapon, treVehicles.SelectedNode, cmsVehicleWeapon, cmsVehicleWeaponMod, cmsVehicleWeaponAccessory, null);
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
return;
}
}
}
}
}
catch
{
}
}
}
}
示例6: tsVehicleNotes_Click
private void tsVehicleNotes_Click(object sender, EventArgs e)
{
Vehicle objVehicle = new Vehicle(_objCharacter);
VehicleMod objMod = new VehicleMod(_objCharacter);
bool blnFoundVehicle = false;
bool blnFoundMod = false;
try
{
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objVehicle = objCharacterVehicle;
blnFoundVehicle = true;
break;
}
foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
{
if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objMod = objVehicleMod;
blnFoundMod = true;
break;
}
}
}
if (blnFoundVehicle)
{
frmNotes frmItemNotes = new frmNotes();
frmItemNotes.Notes = objVehicle.Notes;
string strOldValue = objVehicle.Notes;
frmItemNotes.ShowDialog(this);
if (frmItemNotes.DialogResult == DialogResult.OK)
{
objVehicle.Notes = frmItemNotes.Notes;
if (objVehicle.Notes != strOldValue)
{
_blnIsDirty = true;
UpdateWindowTitle();
}
}
if (objVehicle.Notes != string.Empty)
treVehicles.SelectedNode.ForeColor = Color.SaddleBrown;
else
treVehicles.SelectedNode.ForeColor = SystemColors.WindowText;
treVehicles.SelectedNode.ToolTipText = CommonFunctions.WordWrap(objVehicle.Notes, 100);
}
if (blnFoundMod)
{
frmNotes frmItemNotes = new frmNotes();
frmItemNotes.Notes = objMod.Notes;
string strOldValue = objMod.Notes;
frmItemNotes.ShowDialog(this);
if (frmItemNotes.DialogResult == DialogResult.OK)
{
objMod.Notes = frmItemNotes.Notes;
if (objMod.Notes != strOldValue)
{
_blnIsDirty = true;
UpdateWindowTitle();
}
}
if (objMod.Notes != string.Empty)
treVehicles.SelectedNode.ForeColor = Color.SaddleBrown;
else
{
if (objMod.IncludedInVehicle)
treVehicles.SelectedNode.ForeColor = SystemColors.GrayText;
else
treVehicles.SelectedNode.ForeColor = SystemColors.WindowText;
}
treVehicles.SelectedNode.ToolTipText = CommonFunctions.WordWrap(objMod.Notes, 100);
}
}
catch
{
}
}
示例7: AddPACKSKit
//.........这里部分代码省略.........
int i = 0;
foreach (XmlNode objXmlVehicle in objXmlKit.SelectNodes("vehicles/vehicle"))
{
i++;
pgbProgress.Value = i;
Application.DoEvents();
Gear objDefaultSensor = new Gear(_objCharacter);
TreeNode objNode = new TreeNode();
Vehicle objVehicle = new Vehicle(_objCharacter);
XmlNode objXmlVehicleNode = objXmlVehicleDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + objXmlVehicle["name"].InnerText + "\"]");
objVehicle.Create(objXmlVehicleNode, objNode, cmsVehicle, cmsVehicleGear, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod, blnCreateChildren);
_objCharacter.Vehicles.Add(objVehicle);
// Grab the default Sensor that comes with the Vehicle.
foreach (Gear objSensorGear in objVehicle.Gear)
{
if (objSensorGear.Category == "Sensors" && objSensorGear.Cost == "0" && objSensorGear.Rating == 0)
{
objDefaultSensor = objSensorGear;
break;
}
}
// Add any Vehicle Mods.
if (objXmlVehicle["mods"] != null)
{
foreach (XmlNode objXmlMod in objXmlVehicle.SelectNodes("mods/mod"))
{
TreeNode objModNode = new TreeNode();
VehicleMod objMod = new VehicleMod(_objCharacter);
int intRating = 0;
if (objXmlMod["rating"] != null)
intRating = Convert.ToInt32(objXmlMod["rating"].InnerText);
XmlNode objXmlModNode = objXmlVehicleDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
objMod.Create(objXmlModNode, objModNode, intRating);
objVehicle.Mods.Add(objMod);
objNode.Nodes.Add(objModNode);
objNode.Expand();
}
}
// Add any Vehicle Gear.
if (objXmlVehicle["gears"] != null)
{
XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
foreach (XmlNode objXmlGear in objXmlVehicle.SelectNodes("gears/gear"))
{
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
TreeNode objGearNode = new TreeNode();
Gear objGear = new Gear(_objCharacter);
int intQty = 1;
int intRating = 0;
if (objXmlGear["rating"] != null)
intRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
string strForceValue = "";
if (objXmlGear["name"].Attributes["select"] != null)
示例8: cmdVehicleMoveToInventory_Click
private void cmdVehicleMoveToInventory_Click(object sender, EventArgs e)
{
// Locate the selected Weapon.
bool blnFound = false;
Weapon objWeapon = new Weapon(_objCharacter);
Vehicle objVehicle = new Vehicle(_objCharacter);
VehicleMod objMod = new VehicleMod(_objCharacter);
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
foreach (Weapon objVehicleWeapon in objCharacterVehicle.Weapons)
{
if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objWeapon = objVehicleWeapon;
objVehicle = objCharacterVehicle;
blnFound = true;
break;
}
}
foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
{
foreach (Weapon objVehicleWeapon in objVehicleMod.Weapons)
{
if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objWeapon = objVehicleWeapon;
objVehicle = objCharacterVehicle;
objMod = objVehicleMod;
blnFound = true;
break;
}
}
}
}
if (blnFound){
// Move the Weapons from the Vehicle Mod (or Vehicle) to the character.
if (objMod.InternalId != Guid.Empty.ToString())
objMod.Weapons.Remove(objWeapon);
else
objVehicle.Weapons.Remove(objWeapon);
_objCharacter.Weapons.Add(objWeapon);
TreeNode objNode = new TreeNode();
objNode = treVehicles.SelectedNode;
treVehicles.SelectedNode.Remove();
treWeapons.Nodes[0].Nodes.Add(objNode);
objWeapon.VehicleMounted = false;
objNode.Expand();
}
else
{
// Locate the selected Gear.
Vehicle objSelectedVehicle = new Vehicle(_objCharacter);
Gear objSelectedGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objSelectedVehicle);
int intMove = 0;
if (objSelectedGear.Quantity == 1)
intMove = 1;
else
{
frmSelectNumber frmPickNumber = new frmSelectNumber();
frmPickNumber.Minimum = 1;
frmPickNumber.Maximum = objSelectedGear.Quantity;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_MoveGear");
frmPickNumber.ShowDialog(this);
if (frmPickNumber.DialogResult == DialogResult.Cancel)
return;
intMove = frmPickNumber.SelectedValue;
}
// See if the character already has a matching piece of Gear.
bool blnMatch = false;
Gear objFoundGear = new Gear(_objCharacter);
foreach (Gear objCharacterGear in _objCharacter.Gear)
{
if (objCharacterGear.Name == objSelectedGear.Name && objCharacterGear.Category == objSelectedGear.Category && objCharacterGear.Rating == objSelectedGear.Rating && objCharacterGear.Extra == objSelectedGear.Extra && objCharacterGear.GearName == objSelectedGear.GearName && objCharacterGear.Notes == objSelectedGear.Notes)
{
blnMatch = true;
objFoundGear = objCharacterGear;
if (objCharacterGear.Children.Count == objSelectedGear.Children.Count)
{
for (int i = 0; i <= objCharacterGear.Children.Count - 1; i++)
{
if (objCharacterGear.Children[i].Name != objSelectedGear.Children[i].Name || objCharacterGear.Children[i].Extra != objSelectedGear.Children[i].Extra || objCharacterGear.Children[i].Rating != objSelectedGear.Children[i].Rating)
{
blnMatch = false;
break;
}
}
}
else
blnMatch = false;
}
}
//.........这里部分代码省略.........
示例9: cmdWeaponMoveToVehicle_Click
private void cmdWeaponMoveToVehicle_Click(object sender, EventArgs e)
{
// Locate the selected Weapon.
Weapon objWeapon = new Weapon(_objCharacter);
foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
{
if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
{
objWeapon = objCharacterWeapon;
break;
}
}
List<Vehicle> lstVehicles = new List<Vehicle>();
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
{
// Only add a Vehicle to the list if it has a Weapon Mount or Mechanical Arm.
if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
{
lstVehicles.Add(objCharacterVehicle);
break;
}
}
}
// Cannot continue if there are no Vehicles with a Weapon Mount or Mechanical Arm.
if (lstVehicles.Count == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotMoveWeapons"), LanguageManager.Instance.GetString("MessageTitle_CannotMoveWeapons"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectItem frmPickItem = new frmSelectItem();
frmPickItem.Vehicles = lstVehicles;
frmPickItem.ShowDialog(this);
if (frmPickItem.DialogResult == DialogResult.Cancel)
return;
// Locate the selected Vehicle.
Vehicle objVehicle = new Vehicle(_objCharacter);
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
if (objCharacterVehicle.InternalId == frmPickItem.SelectedItem)
{
objVehicle = objCharacterVehicle;
break;
}
}
// Now display a list of the acceptable mounting points for the Weapon.
List<VehicleMod> lstMods = new List<VehicleMod>();
foreach (VehicleMod objVehicleMod in objVehicle.Mods)
{
if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
lstMods.Add(objVehicleMod);
}
frmPickItem.VehicleMods = lstMods;
frmPickItem.ShowDialog(this);
if (frmPickItem.DialogResult == DialogResult.Cancel)
return;
// Locate the selected Vehicle Mod.
VehicleMod objMod = new VehicleMod(_objCharacter);
foreach (VehicleMod objCharacterMod in objVehicle.Mods)
{
if (objCharacterMod.InternalId == frmPickItem.SelectedItem)
{
objMod = objCharacterMod;
break;
}
}
// Remove the Weapon from the character and add it to the Vehicle Mod.
_objCharacter.Weapons.Remove(objWeapon);
objMod.Weapons.Add(objWeapon);
objWeapon.VehicleMounted = true;
objWeapon.Location = string.Empty;
// Move the TreeNode to the Vehicle Mod.
TreeNode objNode = new TreeNode();
objNode = treWeapons.SelectedNode;
treWeapons.SelectedNode.Remove();
foreach (TreeNode objVehicleNode in treVehicles.Nodes[0].Nodes)
{
foreach (TreeNode objModNode in objVehicleNode.Nodes)
{
if (objModNode.Tag.ToString() == objMod.InternalId)
{
objModNode.Nodes.Add(objNode);
objModNode.Expand();
objNode.Expand();
break;
}
}
//.........这里部分代码省略.........
示例10: 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.
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (!objMod.Name.StartsWith("Weapon Mount") && !objMod.Name.StartsWith("Heavy Weapon Mount") && !objMod.Name.StartsWith("Mechanical Arm"))
{
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[name = \"" + 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);
}
// 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;
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();
}
示例11: tsVehicleAddMod_Click
private void tsVehicleAddMod_Click(object sender, EventArgs e)
{
// Make sure a parent items is selected, then open the Select Vehicle Mod window.
try
{
if (treVehicles.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (treVehicles.SelectedNode.Level > 1)
treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;
Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
frmSelectVehicleMod frmPickVehicleMod = new frmSelectVehicleMod(_objCharacter, true);
// Set the Vehicle properties for the window.
frmPickVehicleMod.VehicleCost = Convert.ToInt32(objSelectedVehicle.Cost);
frmPickVehicleMod.Body = objSelectedVehicle.Body;
frmPickVehicleMod.Speed = objSelectedVehicle.Speed;
frmPickVehicleMod.Accel = objSelectedVehicle.Accel;
frmPickVehicleMod.DeviceRating = objSelectedVehicle.DeviceRating;
frmPickVehicleMod.HasModularElectronics = objSelectedVehicle.HasModularElectronics();
frmPickVehicleMod.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickVehicleMod.DialogResult == DialogResult.Cancel)
return;
// Open the Vehicles XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + frmPickVehicleMod.SelectedMod + "\"]");
TreeNode objNode = new TreeNode();
VehicleMod objMod = new VehicleMod(_objCharacter);
objMod.Create(objXmlMod, objNode, frmPickVehicleMod.SelectedRating);
// Make sure that the Armor Rating does not exceed the maximum allowed by the Vehicle.
if (objMod.Name.StartsWith("Armor"))
{
if (objMod.Rating > objSelectedVehicle.MaxArmor)
{
objMod.Rating = objSelectedVehicle.MaxArmor;
objNode.Text = objMod.DisplayName;
}
}
// Check the item's Cost and make sure the character can afford it.
int intOriginalCost = objSelectedVehicle.TotalCost;
objSelectedVehicle.Mods.Add(objMod);
// Do not allow the user to add a new Vehicle Mod if the Vehicle's Capacity has been reached.
if (_objOptions.EnforceCapacity && objSelectedVehicle.Slots < objSelectedVehicle.SlotsUsed)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
objSelectedVehicle.Mods.Remove(objMod);
if (frmPickVehicleMod.AddAgain)
tsVehicleAddMod_Click(sender, e);
return;
}
int intCost = objSelectedVehicle.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)
{
objSelectedVehicle.Mods.Remove(objMod);
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickVehicleMod.AddAgain)
tsVehicleAddMod_Click(sender, e);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
//.........这里部分代码省略.........
示例12: TestVehicles
private void TestVehicles()
{
Character objCharacter = new Character();
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
pgbProgress.Minimum = 0;
pgbProgress.Value = 0;
pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/vehicles/vehicle").Count;
pgbProgress.Maximum += objXmlDocument.SelectNodes("/chummer/mods/mod").Count;
// Vehicles.
foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/vehicles/vehicle"))
{
pgbProgress.Value++;
Application.DoEvents();
try
{
TreeNode objTempNode = new TreeNode();
Vehicle objTemp = new Vehicle(objCharacter);
objTemp.Create(objXmlGear, objTempNode, null, null, null, null, null);
try
{
int objValue = objTemp.TotalCost;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
}
try
{
string objValue = objTemp.TotalAccel;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAccel\n";
}
try
{
int objValue = objTemp.TotalArmor;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalArmor\n";
}
try
{
int objValue = objTemp.TotalBody;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalBody\n";
}
try
{
int objValue = objTemp.TotalHandling;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalHandling\n";
}
try
{
int objValue = objTemp.TotalSpeed;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalSpeed\n";
}
try
{
string objValue = objTemp.CalculatedAvail;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedAvail\n";
}
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
}
}
// Vehicle Mods.
foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/mods/mod"))
{
pgbProgress.Value++;
Application.DoEvents();
try
{
TreeNode objTempNode = new TreeNode();
VehicleMod objTemp = new VehicleMod(objCharacter);
objTemp.Create(objXmlGear, objTempNode, 1);
try
{
int objValue = objTemp.TotalCost;
}
catch
{
txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
}
//.........这里部分代码省略.........
示例13: UpdateGearInfo
/// <summary>
/// Update the Mod's information based on the Mod selected and current Rating.
/// </summary>
private void UpdateGearInfo()
{
if (lstMod.Text != "")
{
// Retireve the information for the selected Mod.
XmlNode objXmlMod = _objXmlDocument.SelectSingleNode("/chummer/mods/mod[id = \"" + lstMod.SelectedValue + "\"]");
string strAvail = "";
string strModBook = "";
string strModPage = "";
int intItemCost = 0;
int intSlots = 0;
if (_objMode == Mode.Vehicle)
{
TreeNode objTreeNode = new TreeNode();
VehicleMod objVehicleMod = new VehicleMod(_objCharacter);
objVehicleMod.Create(objXmlMod, objTreeNode, Convert.ToInt32(nudRating.Value));
Vehicle objVehicle = new Vehicle(_objCharacter);
objVehicleMod.Parent = objVehicle;
if (_intVehicleCost != 0)
objVehicle.Cost = _intVehicleCost.ToString();
string strAccel = _intAccelWalking.ToString() + "/" + _intAccelRunning.ToString();
objVehicle.Accel = strAccel;
if (_intBody != 0)
objVehicle.Body = _intBody;
if (_intSpeed != 0)
objVehicle.Speed = _intSpeed;
strAvail = objVehicleMod.TotalAvail;
intItemCost = objVehicleMod.TotalCost;
intSlots = objVehicleMod.CalculatedSlots;
strModBook = objVehicleMod.Source;
strModPage = objVehicleMod.Page;
}
else if (_objMode == Mode.WeaponMod)
{
TreeNode objTreeNode = new TreeNode();
WeaponMod objWeaponMod = new WeaponMod(_objCharacter);
objWeaponMod.Create(objXmlMod, objTreeNode);
if (_intWeaponCost != 0)
{
Weapon objWeapon = new Weapon(_objCharacter);
objWeapon.Cost = _intWeaponCost;
objWeaponMod.Parent = objWeapon;
}
strAvail = objWeaponMod.TotalAvail;
intItemCost = objWeaponMod.TotalCost;
intSlots = objWeaponMod.Slots;
strModBook = objWeaponMod.Source;
strModPage = objWeaponMod.Page;
}
lblAvail.Text = strAvail;
// Cost.
if (objXmlMod["cost"].InnerText.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objXmlMod["cost"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
if (strCost.Contains("-"))
{
string[] strValues = strCost.Split('-');
intMin = Convert.ToInt32(strValues[0]);
intMax = Convert.ToInt32(strValues[1]);
}
else
intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));
if (intMax == 0)
{
intMax = 1000000;
lblCost.Text = String.Format("{0:###,###,##0¥+}", intMin);
}
else
lblCost.Text = String.Format("{0:###,###,##0}", intMin) + "-" + String.Format("{0:###,###,##0¥}", intMax);
intItemCost = intMin;
}
else
{
int intCost = Convert.ToInt32(Convert.ToDouble(intItemCost, GlobalOptions.Instance.CultureInfo));
intCost *= _intModMultiplier;
// Apply any markup.
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(nudMarkup.Value, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
lblCost.Text = String.Format("{0:###,###,##0¥}", intCost);
intItemCost = intCost;
}
//.........这里部分代码省略.........
示例14: CreateAllVehicleModsTest
public void CreateAllVehicleModsTest()
{
// Create a new Human character.
Character objCharacter = new Character();
objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));
TreeNode objNode = new TreeNode();
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/mods/mod"))
{
VehicleMod objMod = new VehicleMod(objCharacter);
objMod.Create(objXmlNode, objNode, 1);
}
}