本文整理汇总了C#中Vehicle.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Vehicle.Create方法的具体用法?C# Vehicle.Create怎么用?C# Vehicle.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle.Create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdAddVehicle_Click
private void cmdAddVehicle_Click(object sender, EventArgs e)
{
frmSelectVehicle frmPickVehicle = new frmSelectVehicle(_objCharacter);
frmPickVehicle.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickVehicle.DialogResult == DialogResult.Cancel)
return;
// Open the Vehicles XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
XmlNode objXmlVehicle = objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + frmPickVehicle.SelectedVehicle + "\"]");
TreeNode objNode = new TreeNode();
Vehicle objVehicle = new Vehicle(_objCharacter);
objVehicle.Create(objXmlVehicle, objNode, cmsVehicle, cmsVehicleGear, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
// Update the Used Vehicle information if applicable.
if (frmPickVehicle.UsedVehicle)
{
objVehicle.Avail = frmPickVehicle.UsedAvail;
objVehicle.Cost = frmPickVehicle.UsedCost.ToString();
}
_objCharacter.Vehicles.Add(objVehicle);
objNode.ContextMenuStrip = cmsVehicle;
treVehicles.Nodes[0].Nodes.Add(objNode);
treVehicles.Nodes[0].Expand();
treVehicles.SelectedNode = objNode;
UpdateCharacterInfo();
RefreshSelectedVehicle();
_blnIsDirty = true;
UpdateWindowTitle();
if (frmPickVehicle.AddAgain)
cmdAddVehicle_Click(sender, e);
}
示例2: AddPACKSKit
/// <summary>
/// Add a PACKS Kit to the character.
/// </summary>
public void AddPACKSKit()
{
frmSelectPACKSKit frmPickPACKSKit = new frmSelectPACKSKit(_objCharacter);
frmPickPACKSKit.ShowDialog(this);
bool blnCreateChildren = true;
// If the form was canceled, don't do anything.
if (frmPickPACKSKit.DialogResult == DialogResult.Cancel)
return;
XmlDocument objXmlDocument = XmlManager.Instance.Load("packs.xml");
// Do not create child items for Gear if the chosen Kit is in the Custom category since these items will contain the exact plugins desired.
if (frmPickPACKSKit.SelectedCategory == "Custom")
blnCreateChildren = false;
XmlNode objXmlKit = objXmlDocument.SelectSingleNode("/chummer/packs/pack[name = \"" + frmPickPACKSKit.SelectedKit + "\" and category = \"" + frmPickPACKSKit.SelectedCategory + "\"]");
// Update Qualities.
if (objXmlKit["qualities"] != null)
{
XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");
// Positive Qualities.
foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/positive/quality"))
{
XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";
if (objXmlQuality.Attributes["select"] != null)
strForceValue = objXmlQuality.Attributes["select"].InnerText;
objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
_objCharacter.Qualities.Add(objQuality);
treQualities.Nodes[0].Nodes.Add(objNode);
treQualities.Nodes[0].Expand();
// Add any created Weapons to the character.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
// Create the Weapon Node if one exists.
foreach (TreeNode objWeaponNode in objWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
treWeapons.Nodes[0].Expand();
}
}
// Negative Qualities.
foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/negative/quality"))
{
XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.InnerText + "\"]");
TreeNode objNode = new TreeNode();
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
Quality objQuality = new Quality(_objCharacter);
string strForceValue = "";
if (objXmlQuality.Attributes["select"] != null)
strForceValue = objXmlQuality.Attributes["select"].InnerText;
objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
_objCharacter.Qualities.Add(objQuality);
treQualities.Nodes[1].Nodes.Add(objNode);
treQualities.Nodes[1].Expand();
// Add any created Weapons to the character.
foreach (Weapon objWeapon in objWeapons)
_objCharacter.Weapons.Add(objWeapon);
// Create the Weapon Node if one exists.
foreach (TreeNode objWeaponNode in objWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
treWeapons.Nodes[0].Expand();
}
}
}
// Update Attributes.
if (objXmlKit["attributes"] != null)
{
// Reset all Attributes back to 1 so we don't go over any BP limits.
nudBOD.Value = nudBOD.Minimum;
nudAGI.Value = nudAGI.Minimum;
nudREA.Value = nudREA.Minimum;
//.........这里部分代码省略.........
示例3: cmdAddVehicle_Click
private void cmdAddVehicle_Click(object sender, EventArgs e)
{
frmSelectVehicle frmPickVehicle = new frmSelectVehicle(_objCharacter, true);
frmPickVehicle.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickVehicle.DialogResult == DialogResult.Cancel)
return;
// Open the Vehicles XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
XmlNode objXmlVehicle = objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + frmPickVehicle.SelectedVehicle + "\"]");
TreeNode objNode = new TreeNode();
Vehicle objVehicle = new Vehicle(_objCharacter);
objVehicle.Create(objXmlVehicle, objNode, cmsVehicle, cmsVehicleGear, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
// Update the Used Vehicle information if applicable.
if (frmPickVehicle.UsedVehicle)
{
objVehicle.Avail = frmPickVehicle.UsedAvail;
objVehicle.Cost = frmPickVehicle.UsedCost.ToString();
}
int intCost = objVehicle.TotalCost;
// Apply a markup if applicable.
if (frmPickVehicle.Markup != 0)
{
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(frmPickVehicle.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
}
// Multiply the cost if applicable.
if (objVehicle.CalculatedAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
intCost *= _objOptions.RestrictedCostMultiplier;
if (objVehicle.CalculatedAvail.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 (!frmPickVehicle.FreeCost)
{
if (intCost > _objCharacter.Nuyen)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
if (frmPickVehicle.AddAgain)
cmdAddVehicle_Click(sender, e);
return;
}
else
{
// Create the Expense Log Entry.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseVehicle") + " " + objVehicle.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateNuyen(NuyenExpenseType.AddVehicle, objVehicle.InternalId);
objExpense.Undo = objUndo;
}
}
_objCharacter.Vehicles.Add(objVehicle);
objNode.ContextMenuStrip = cmsVehicle;
treVehicles.Nodes[0].Nodes.Add(objNode);
treVehicles.Nodes[0].Expand();
treVehicles.SelectedNode = objNode;
UpdateCharacterInfo();
RefreshSelectedVehicle();
_blnIsDirty = true;
UpdateWindowTitle();
if (frmPickVehicle.AddAgain)
cmdAddVehicle_Click(sender, e);
}
示例4: 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";
}
//.........这里部分代码省略.........
示例5: UpdateSelectedVehicle
/// <summary>
/// Refresh the information for the selected Vehicle.
/// </summary>
private void UpdateSelectedVehicle()
{
if (lstVehicle.Text == "")
return;
double dblCostModifier = 1.0;
// Retireve the information for the selected Vehicle.
XmlNode objXmlVehicle = _objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[id = \"" + lstVehicle.SelectedValue + "\"]");
TreeNode objTreeNode = new TreeNode();
Vehicle objVehicle = new Vehicle(_objCharacter);
objVehicle.Create(objXmlVehicle, objTreeNode, null, null, null, null, null, true);
if (chkUsedVehicle.Checked)
dblCostModifier = Convert.ToDouble(1 - (nudUsedVehicleDiscount.Value / 100), GlobalOptions.Instance.CultureInfo);
lblVehicleHandling.Text = objVehicle.TotalHandling.ToString();
lblVehicleAccel.Text = objVehicle.TotalAccel;
lblVehicleSpeed.Text = objVehicle.TotalSpeed.ToString();
lblVehiclePilot.Text = objVehicle.Pilot.ToString();
lblVehicleBody.Text = objVehicle.TotalBody.ToString();
lblVehicleArmor.Text = objVehicle.TotalArmor.ToString();
lblVehicleSensor.Text = objVehicle.CalculatedSensor.ToString();
if (chkUsedVehicle.Checked)
{
string strSuffix = "";
string strAvail = objXmlVehicle["avail"].InnerText;
if (strAvail.Contains("R") || strAvail.Contains("F"))
{
strSuffix = strAvail.Substring(strAvail.Length - 1, 1);
strAvail = strAvail.Replace(strSuffix, string.Empty);
strAvail = (Convert.ToInt32(strAvail) + 4).ToString() + strSuffix;
lblVehicleAvail.Text = strAvail;
}
else
lblVehicleAvail.Text = (Convert.ToInt32(objXmlVehicle["avail"].InnerText) + 4).ToString();
}
else
lblVehicleAvail.Text = objVehicle.TotalAvail;
//lblVehicleAvail.Text = lblVehicleAvail.Text.Replace("R", LanguageManager.Instance.GetString("String_AvailRestricted")).Replace("F", LanguageManager.Instance.GetString("String_AvailForbidden"));
// Apply the cost multiplier to the Vehicle (will be 1 unless Used Vehicle is selected)
int intCost = objVehicle.TotalCost;
intCost = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo) * dblCostModifier));
// Apply the markup if applicable.
double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
dblCost *= 1 + (Convert.ToDouble(nudMarkup.Value, GlobalOptions.Instance.CultureInfo) / 100.0);
intCost = Convert.ToInt32(dblCost);
if (chkFreeItem.Checked)
intCost = 0;
lblVehicleCost.Text = String.Format("{0:###,###,##0¥}", intCost);
lblTest.Text = _objCharacter.AvailTest(intCost, lblVehicleAvail.Text);
string strBook = _objCharacter.Options.LanguageBookShort(objVehicle.Source);
string strPage = objVehicle.Page;
lblSource.Text = strBook + " " + strPage;
tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objVehicle.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage);
}
示例6: CreateAllVehiclesTest
public void CreateAllVehiclesTest()
{
// Create a new Human character.
Character objCharacter = new Character();
objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));
TreeNode objNode = new TreeNode();
ContextMenuStrip cmsVehicle = new ContextMenuStrip();
ContextMenuStrip cmsVehicleGear = new ContextMenuStrip();
ContextMenuStrip cmsVehicleWeapon = new ContextMenuStrip();
ContextMenuStrip cmsVehicleWeaponAccessory = new ContextMenuStrip();
ContextMenuStrip cmsVehicleWeaponMod = new ContextMenuStrip();
XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/vehicles/vehicle"))
{
Vehicle objVehicle = new Vehicle(objCharacter);
objVehicle.Create(objXmlNode, objNode, cmsVehicle, cmsVehicleGear, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
}
}