本文整理汇总了C#中Commlink类的典型用法代码示例。如果您正苦于以下问题:C# Commlink类的具体用法?C# Commlink怎么用?C# Commlink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Commlink类属于命名空间,在下文中一共展示了Commlink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindCommlink
/// <summary>
/// Locate a Commlink.
/// </summary>
/// <param name="strGuid">InternalId of the Gear to find.</param>
/// <param name="lstCommlink">List of Commlinks to search.</param>
public Commlink FindCommlink(string strGuid, List<Gear> lstCommlink)
{
Commlink objReturn = new Commlink(_objCharacter);
List<Gear> lstCheckGear = new List<Gear>();
foreach (Gear objGear in lstCommlink)
{
if (objGear.Category == "Commlinks")
{
lstCheckGear.Add(objGear);
}
}
foreach (Commlink objCommlink in lstCheckGear)
{
if (objCommlink.InternalId == strGuid)
objReturn = objCommlink;
else
{
if (objCommlink.Children.Count > 0)
objReturn = FindCommlink(strGuid, objCommlink.Children);
}
if (objReturn != null)
{
if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
return objReturn;
}
}
objReturn = null;
return objReturn;
}
示例2: PrintToStream
//.........这里部分代码省略.........
foreach (Cyberware objCyberware in _lstCyberware)
{
objCyberware.Print(objWriter);
}
// </cyberwares>
objWriter.WriteEndElement();
// Load the Qualities file so we can figure out whether or not each Quality should be printed.
objXmlDocument = XmlManager.Instance.Load("qualities.xml");
// <qualities>
objWriter.WriteStartElement("qualities");
foreach (Quality objQuality in _lstQualities)
{
objQuality.Print(objWriter);
}
// </qualities>
objWriter.WriteEndElement();
// <lifestyles>
objWriter.WriteStartElement("lifestyles");
foreach (Lifestyle objLifestyle in _lstLifestyles)
{
objLifestyle.Print(objWriter);
}
// </lifestyles>
objWriter.WriteEndElement();
// <gears>
objWriter.WriteStartElement("gears");
foreach (Gear objGear in _lstGear)
{
// Use the Gear's SubClass if applicable.
if (objGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = new Commlink(this);
objCommlink = (Commlink)objGear;
objCommlink.Print(objWriter);
}
else if (objGear.GetType() == typeof(OperatingSystem))
{
OperatingSystem objOperatinSystem = new OperatingSystem(this);
objOperatinSystem = (OperatingSystem)objGear;
objOperatinSystem.Print(objWriter);
}
else
{
objGear.Print(objWriter);
}
}
// If the character is a Technomander, write out the Living Persona "Commlink".
if (_blnTechnomancerEnabled)
{
int intFirewall = _attWIL.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaFirewall);
int intResponse = _attINT.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaResponse);
int intSignal = Convert.ToInt32(Math.Ceiling((Convert.ToDecimal(_attRES.TotalValue, GlobalOptions.Instance.CultureInfo) / 2))) + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaSignal);
int intSystem = _attLOG.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.LivingPersonaSystem);
// Make sure none of the Attributes exceed the Technomancer's RES.
intFirewall = Math.Min(intFirewall, _attRES.TotalValue);
intResponse = Math.Min(intResponse, _attRES.TotalValue);
intSignal = Math.Min(intSignal, _attRES.TotalValue);
intSystem = Math.Min(intSystem, _attRES.TotalValue);
Commlink objLivingPersona = new Commlink(this);
objLivingPersona.Name = LanguageManager.Instance.GetString("String_LivingPersona");
示例3: tsVehicleAddGear_Click
private void tsVehicleAddGear_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;
// Locate the selected Vehicle.
Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter);
//frmPickGear.ShowPositiveCapacityOnly = true;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode 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, false);
objCommlink.Quantity = frmPickGear.SelectedQty;
objGear = objCommlink;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, false, true, frmPickGear.Aerodynamic);
objNewGear.Quantity = frmPickGear.SelectedQty;
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";
}
objGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objGear.DisplayName;
try
{
nudVehicleRating.Increment = objGear.CostFor;
nudVehicleRating.Minimum = nudGearQty.Increment;
}
catch
{
//.........这里部分代码省略.........
示例4: ChangeActiveCommlink
/// <summary>
/// Change the active Commlink for the Character.
/// </summary>
/// <param name="objActiveCommlink"></param>
private void ChangeActiveCommlink(Commlink objActiveCommlink)
{
List<Commlink> lstCommlinks = _objFunctions.FindCharacterCommlinks(_objCharacter.Gear);
foreach (Commlink objCommlink in lstCommlinks)
{
if (objCommlink.InternalId != objActiveCommlink.InternalId)
objCommlink.IsActive = false;
}
}
示例5: RefreshPasteStatus
/// <summary>
/// Enable/Disable the Paste Menu and ToolStrip items as appropriate.
/// </summary>
private void RefreshPasteStatus()
{
bool blnPasteEnabled = false;
bool blnCopyEnabled = false;
if (tabCharacterTabs.SelectedTab == tabStreetGear)
{
// Lifestyle Tab.
if (tabStreetGearTabs.SelectedTab == tabLifestyle)
{
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Lifestyle)
blnPasteEnabled = true;
try
{
foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
{
if (objLifestyle.InternalId == treLifestyles.SelectedNode.Tag.ToString())
{
blnCopyEnabled = true;
break;
}
}
}
catch
{
}
}
// Armor Tab.
if (tabStreetGearTabs.SelectedTab == tabArmor)
{
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Armor)
blnPasteEnabled = true;
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
{
// Gear can only be pasted into Armor, not Armor Mods.
try
{
foreach (Armor objArmor in _objCharacter.Armor)
{
if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
{
blnPasteEnabled = true;
break;
}
}
}
catch
{
}
}
try
{
foreach (Armor objArmor in _objCharacter.Armor)
{
if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
{
blnCopyEnabled = true;
break;
}
}
}
catch
{
}
try
{
Armor objArmor = new Armor(_objCharacter);
Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objArmor);
if (objGear != null)
blnCopyEnabled = true;
}
catch
{
}
}
// Weapons Tab.
if (tabStreetGearTabs.SelectedTab == tabWeapons)
{
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon)
blnPasteEnabled = true;
if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
{
// Check if the copied Gear can be pasted into the selected Weapon Accessory.
Gear objGear = new Gear(_objCharacter);
XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");
if (objXmlNode != null)
{
switch (objXmlNode["category"].InnerText)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
//.........这里部分代码省略.........
示例6: PickGear
/// <summary>
/// Select a piece of Gear to be added to the character.
/// </summary>
private bool PickGear()
{
bool blnNullParent = false;
Gear objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
if (objSelectedGear == null)
{
objSelectedGear = new Gear(_objCharacter);
blnNullParent = true;
}
// Open the Gear XML file and locate the selected Gear.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSelectedGear.Name + "\" and category = \"" + objSelectedGear.Category + "\"]");
bool blnFakeCareerMode = false;
if (_objCharacter.Metatype == "A.I." || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients")
blnFakeCareerMode = true;
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, blnFakeCareerMode, objSelectedGear.ChildAvailModifier, objSelectedGear.ChildCostMultiplier);
try
{
if (treGear.SelectedNode.Level > 0)
{
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 += objSelectedGear.Category + ",";
// If the Gear has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
if (!objSelectedGear.Capacity.Contains('['))
frmPickGear.MaximumCapacity = objSelectedGear.CapacityRemaining;
if (objSelectedGear.Category == "Commlinks" || objSelectedGear.Category == "Cyberdecks")
{
Commlink objCommlink = (Commlink)objSelectedGear;
frmPickGear.CommlinkResponse = objCommlink.DeviceRating;
}
}
}
catch
{
}
frmPickGear.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickGear.DialogResult == DialogResult.Cancel)
return false;
TreeNode objNode = new TreeNode();
// Open the Cyberware XML file and locate the selected piece.
objXmlDocument = XmlManager.Instance.Load("gear.xml");
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>();
Gear objNewGear = 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;
try
{
_blnSkipRefresh = true;
nudGearQty.Increment = objCommlink.CostFor;
//nudGearQty.Minimum = nudGearQty.Increment;
_blnSkipRefresh = false;
}
catch
{
}
objNode.Text = objCommlink.DisplayName;
// If a Commlink has just been added, see if the character already has one. If not, make it the active Commlink.
if (_objFunctions.FindCharacterCommlinks(_objCharacter.Gear).Count == 0 && frmPickGear.SelectedCategory == "Commlinks")
objCommlink.IsActive = true;
objNewGear = objCommlink;
break;
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;
//.........这里部分代码省略.........
示例7: chkGearHomeNode_CheckedChanged
private void chkGearHomeNode_CheckedChanged(object sender, EventArgs e)
{
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink = _objFunctions.FindCommlink(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
objCommlink.HomeNode = chkGearHomeNode.Checked;
_objCharacter.HasHomeNode = chkGearHomeNode.Checked;
_objFunctions.ReplaceHomeNodes(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear, _objCharacter.Vehicles);
RefreshSelectedGear();
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例8: Save
//.........这里部分代码省略.........
// <cyberwares>
objWriter.WriteStartElement("cyberwares");
foreach (Cyberware objCyberware in _lstCyberware)
{
objCyberware.Save(objWriter);
}
// </cyberwares>
objWriter.WriteEndElement();
// <qualities>
objWriter.WriteStartElement("qualities");
foreach (Quality objQuality in _lstQualities)
{
objQuality.Save(objWriter);
}
// </qualities>
objWriter.WriteEndElement();
// <lifestyles>
objWriter.WriteStartElement("lifestyles");
foreach (Lifestyle objLifestyle in _lstLifestyles)
{
objLifestyle.Save(objWriter);
}
// </lifestyles>
objWriter.WriteEndElement();
// <gears>
objWriter.WriteStartElement("gears");
foreach (Gear objGear in _lstGear)
{
// Use the Gear's SubClass if applicable.
if (objGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = new Commlink(this);
objCommlink = (Commlink)objGear;
objCommlink.Save(objWriter);
}
else
{
objGear.Save(objWriter);
}
}
// </gears>
objWriter.WriteEndElement();
// <vehicles>
objWriter.WriteStartElement("vehicles");
foreach (Vehicle objVehicle in _lstVehicles)
{
objVehicle.Save(objWriter);
}
// </vehicles>
objWriter.WriteEndElement();
// <metamagics>
objWriter.WriteStartElement("metamagics");
foreach (Metamagic objMetamagic in _lstMetamagics)
{
objMetamagic.Save(objWriter);
}
// </metamagics>
objWriter.WriteEndElement();
// <arts>
示例9: 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";
//.........这里部分代码省略.........
示例10: tsCyberwareAddGear_Click
private void tsCyberwareAddGear_Click(object sender, EventArgs e)
{
// Make sure a parent items is selected, then open the Select Gear window.
try
{
if (treCyberware.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectCyberware"), LanguageManager.Instance.GetString("MessageTitle_SelectCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectCyberware"), LanguageManager.Instance.GetString("MessageTitle_SelectCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Cyberware objCyberware = new Cyberware(_objCharacter);
foreach (Cyberware objCharacterCyberware in _objCharacter.Cyberware)
{
if (objCharacterCyberware.InternalId == treCyberware.SelectedNode.Tag.ToString())
{
objCyberware = objCharacterCyberware;
break;
}
foreach (Cyberware objChild in objCharacterCyberware.Children)
{
if (objChild.InternalId == treCyberware.SelectedNode.Tag.ToString())
{
objCyberware = objChild;
break;
}
}
}
// Make sure the Cyberware is allowed to accept Gear.
if (objCyberware.AllowGear == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberwareGear"), LanguageManager.Instance.GetString("MessageTitle_CyberwareGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true);
string strCategories = "";
foreach (XmlNode objXmlCategory in objCyberware.AllowGear)
strCategories += objXmlCategory.InnerText + ",";
frmPickGear.AllowedCategories = strCategories;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
TreeNode objNode = new TreeNode();
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode 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>();
Gear objNewGear = 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;
objNewGear = objCommlink;
break;
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";
//.........这里部分代码省略.........
示例11: PickGear
/// <summary>
/// Select a piece of Gear to be added to the character.
/// </summary>
/// <param name="blnAmmoOnly">Whether or not only Ammunition should be shown in the window.</param>
/// <param name="objStackGear">Whether or not the selected item should stack with a matching item on the character.</param>
/// <param name="strForceItemValue">Force the user to select an item with the passed name..</param>
private bool PickGear(bool blnAmmoOnly = false, Gear objStackGear = null, string strForceItemValue = "")
{
bool blnNullParent = false;
Gear objSelectedGear = new Gear(_objCharacter);
if (treGear.SelectedNode != null)
objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
if (objSelectedGear == null)
{
objSelectedGear = new Gear(_objCharacter);
blnNullParent = true;
}
ExpenseUndo objUndo = new ExpenseUndo();
// Open the Gear XML file and locate the selected Gear.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSelectedGear.Name + "\" and category = \"" + objSelectedGear.Category + "\"]");
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true, objSelectedGear.ChildAvailModifier, objSelectedGear.ChildCostMultiplier);
try
{
if (treGear.SelectedNode.Level > 0)
{
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 += objSelectedGear.Category + ",";
// If the Gear has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
if (!objSelectedGear.Capacity.Contains('['))
{
frmPickGear.MaximumCapacity = objSelectedGear.CapacityRemaining;
// Do not allow the user to add a new piece of Gear if its Capacity has been reached.
if (_objOptions.EnforceCapacity && objSelectedGear.CapacityRemaining < 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
}
if (objSelectedGear.Category == "Commlink")
{
Commlink objCommlink = (Commlink)objSelectedGear;
frmPickGear.CommlinkResponse = objCommlink.DeviceRating;
// If a Commlink has just been added, see if the character already has one. If not, make it the active Commlink.
if (_objFunctions.FindCharacterCommlinks(_objCharacter.Gear).Count == 0)
objCommlink.IsActive = true;
}
}
}
catch
{
}
if (blnAmmoOnly)
{
frmPickGear.AllowedCategories = "Ammunition";
frmPickGear.SelectedGear = objSelectedGear.Name;
}
frmPickGear.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickGear.DialogResult == DialogResult.Cancel)
return false;
TreeNode objNode = new TreeNode();
// Open the Cyberware XML file and locate the selected piece.
objXmlDocument = XmlManager.Instance.Load("gear.xml");
objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");
// Create the new piece of Gear.
Gear objNewGear = new Gear(_objCharacter);
List<Weapon> objWeapons = new List<Weapon>();
List<TreeNode> objWeaponNodes = new List<TreeNode>();
switch (frmPickGear.SelectedCategory)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(_objCharacter);
//.........这里部分代码省略.........
示例12: PickArmorGear
/// <summary>
/// Select a piece of Gear and add it to a piece of Armor.
/// </summary>
/// <param name="blnShowArmorCapacityOnly">Whether or not only items that consume capacity should be shown.</param>
private bool PickArmorGear(bool blnShowArmorCapacityOnly = false)
{
bool blnNullParent = true;
Gear objSelectedGear = new Gear(_objCharacter);
Armor objSelectedArmor = new Armor(_objCharacter);
ExpenseUndo objUndo = new ExpenseUndo();
foreach (Armor objArmor in _objCharacter.Armor)
{
if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
objSelectedArmor = objArmor;
}
if (treArmor.SelectedNode.Level > 1)
{
objSelectedGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objSelectedArmor);
if (objSelectedGear != null)
blnNullParent = false;
}
// Open the Gear XML file and locate the selected Gear.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSelectedGear.Name + "\" and category = \"" + objSelectedGear.Category + "\"]");
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true);
frmPickGear.EnableStack = false;
frmPickGear.ShowArmorCapacityOnly = blnShowArmorCapacityOnly;
frmPickGear.CapacityDisplayStyle = objSelectedArmor.CapacityDisplayStyle;
try
{
if (treArmor.SelectedNode.Level > 1)
{
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 += objSelectedGear.Category + ",";
// If the Gear has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
if (!objSelectedGear.Capacity.Contains('['))
{
frmPickGear.MaximumCapacity = objSelectedGear.CapacityRemaining;
// Do not allow the user to add a new piece of Gear if its Capacity has been reached.
if (_objOptions.EnforceCapacity && objSelectedGear.CapacityRemaining < 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
}
if (objSelectedGear.Category == "Commlink")
{
Commlink objCommlink = (Commlink)objSelectedGear;
frmPickGear.CommlinkResponse = objCommlink.DeviceRating;
}
}
else if (treArmor.SelectedNode.Level == 1)
{
// Open the Armor XML file and locate the selected Gear.
objXmlDocument = XmlManager.Instance.Load("armor.xml");
objXmlGear = objXmlDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + objSelectedArmor.Name + "\"]");
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);
}
}
}
catch
{
}
frmPickGear.ShowDialog(this);
// Make sure the dialogue window was not canceled.
if (frmPickGear.DialogResult == DialogResult.Cancel)
return false;
TreeNode objNode = new TreeNode();
// Open the Cyberware XML file and locate the selected piece.
objXmlDocument = XmlManager.Instance.Load("gear.xml");
//.........这里部分代码省略.........
示例13: tsVehicleAddGear_Click
private void tsVehicleAddGear_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;
// Locate the selected Vehicle.
Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, true);
frmPickGear.ShowPositiveCapacityOnly = true;
frmPickGear.ShowDialog(this);
if (frmPickGear.DialogResult == DialogResult.Cancel)
return;
// Open the Gear XML file and locate the selected piece.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode 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 "Commlink":
case "Commlink Upgrade":
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objCommlink.Quantity = frmPickGear.SelectedQty;
objGear = objCommlink;
break;
case "Commlink Operating System":
case "Commlink Operating System Upgrade":
OperatingSystem objOperatingSystem = new OperatingSystem(_objCharacter);
objOperatingSystem.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
objOperatingSystem.Quantity = frmPickGear.SelectedQty;
objGear = objOperatingSystem;
break;
default:
Gear objNewGear = new Gear(_objCharacter);
objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, false, true, frmPickGear.Aerodynamic);
objNewGear.Quantity = frmPickGear.SelectedQty;
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";
}
objGear.Quantity = frmPickGear.SelectedQty;
objNode.Text = objGear.DisplayName;
//.........这里部分代码省略.........
示例14: Save
//.........这里部分代码省略.........
// <cyberwares>
objWriter.WriteStartElement("cyberwares");
foreach (Cyberware objCyberware in _lstCyberware)
{
objCyberware.Save(objWriter);
}
// </cyberwares>
objWriter.WriteEndElement();
// <qualities>
objWriter.WriteStartElement("qualities");
foreach (Quality objQuality in _lstQualities)
{
objQuality.Save(objWriter);
}
// </qualities>
objWriter.WriteEndElement();
// <lifestyles>
objWriter.WriteStartElement("lifestyles");
foreach (Lifestyle objLifestyle in _lstLifestyles)
{
objLifestyle.Save(objWriter);
}
// </lifestyles>
objWriter.WriteEndElement();
// <gears>
objWriter.WriteStartElement("gears");
foreach (Gear objGear in _lstGear)
{
// Use the Gear's SubClass if applicable.
if (objGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = new Commlink(this);
objCommlink = (Commlink)objGear;
objCommlink.Save(objWriter);
}
else if (objGear.GetType() == typeof(OperatingSystem))
{
OperatingSystem objOperatinSystem = new OperatingSystem(this);
objOperatinSystem = (OperatingSystem)objGear;
objOperatinSystem.Save(objWriter);
}
else
{
objGear.Save(objWriter);
}
}
// </gears>
objWriter.WriteEndElement();
// <vehicles>
objWriter.WriteStartElement("vehicles");
foreach (Vehicle objVehicle in _lstVehicles)
{
objVehicle.Save(objWriter);
}
// </vehicles>
objWriter.WriteEndElement();
// <metamagics>
objWriter.WriteStartElement("metamagics");
foreach (Metamagic objMetamagic in _lstMetamagics)
{
示例15: Load
//.........这里部分代码省略.........
// Martial Art Maneuvers.
objXmlNodeList = objXmlDocument.SelectNodes("/character/martialartmaneuvers/martialartmaneuver");
foreach (XmlNode objXmlManeuver in objXmlNodeList)
{
MartialArtManeuver objManeuver = new MartialArtManeuver(this);
objManeuver.Load(objXmlManeuver);
_lstMartialArtManeuvers.Add(objManeuver);
}
// Limit Modifiers.
objXmlNodeList = objXmlDocument.SelectNodes("/character/limitmodifiers/limitmodifier");
foreach (XmlNode objXmlLimit in objXmlNodeList)
{
LimitModifier obLimitModifier = new LimitModifier(this);
obLimitModifier.Load(objXmlLimit);
_lstLimitModifiers.Add(obLimitModifier);
}
// Lifestyles.
objXmlNodeList = objXmlDocument.SelectNodes("/character/lifestyles/lifestyle");
foreach (XmlNode objXmlLifestyle in objXmlNodeList)
{
Lifestyle objLifestyle = new Lifestyle(this);
objLifestyle.Load(objXmlLifestyle);
_lstLifestyles.Add(objLifestyle);
}
// <gears>
objXmlNodeList = objXmlDocument.SelectNodes("/character/gears/gear");
foreach (XmlNode objXmlGear in objXmlNodeList)
{
switch (objXmlGear["category"].InnerText)
{
case "Commlinks":
case "Cyberdecks":
case "Rigger Command Consoles":
Commlink objCommlink = new Commlink(this);
objCommlink.Load(objXmlGear);
_lstGear.Add(objCommlink);
break;
default:
Gear objGear = new Gear(this);
objGear.Load(objXmlGear);
_lstGear.Add(objGear);
break;
}
}
// Vehicles.
objXmlNodeList = objXmlDocument.SelectNodes("/character/vehicles/vehicle");
foreach (XmlNode objXmlVehicle in objXmlNodeList)
{
Vehicle objVehicle = new Vehicle(this);
objVehicle.Load(objXmlVehicle);
_lstVehicles.Add(objVehicle);
}
// Metamagics/Echoes.
objXmlNodeList = objXmlDocument.SelectNodes("/character/metamagics/metamagic");
foreach (XmlNode objXmlMetamagic in objXmlNodeList)
{
Metamagic objMetamagic = new Metamagic(this);
objMetamagic.Load(objXmlMetamagic);
_lstMetamagics.Add(objMetamagic);
}