本文整理汇总了C#中Chummer.Improvement类的典型用法代码示例。如果您正苦于以下问题:C# Improvement类的具体用法?C# Improvement怎么用?C# Improvement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Improvement类属于Chummer命名空间,在下文中一共展示了Improvement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: frmSelectCyberwareSuite
public frmSelectCyberwareSuite(Improvement.ImprovementSource objSource, Character objCharacter)
{
InitializeComponent();
_objSource = objSource;
LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);
if (_objSource == Improvement.ImprovementSource.Cyberware)
_strType = "cyberware";
else
{
_strType = "bioware";
this.Text = LanguageManager.Instance.GetString("Title_SelectBiowareSuite");
lblCyberwareLabel.Text = LanguageManager.Instance.GetString("Label_SelectBiowareSuite_PartsInSuite");
}
_objCharacter = objCharacter;
}
示例2: frmCreateCyberwareSuite
public frmCreateCyberwareSuite(Character objCharacter, Improvement.ImprovementSource objSource)
{
InitializeComponent();
_objSource = objSource;
LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);
_objCharacter = objCharacter;
if (_objSource == Improvement.ImprovementSource.Cyberware)
_strType = "cyberware";
else
{
_strType = "bioware";
this.Text = LanguageManager.Instance.GetString("Title_CreateBiowareSuite");
}
txtFileName.Text = "custom_" + _strType + ".xml";
}
示例3: CreateCyberwareSuite
/// <summary>
/// Create a Cyberware Suite from the Cyberware the character currently has.
/// </summary>
private void CreateCyberwareSuite(Improvement.ImprovementSource objSource)
{
// Make sure all of the Cyberware the character has is of the same grade.
string strGrade = "";
bool blnOK = true;
foreach (Cyberware objCyberware in _objCharacter.Cyberware)
{
if (objCyberware.SourceType == objSource)
{
if (strGrade == "")
strGrade = objCyberware.Grade.ToString();
else
{
if (strGrade != objCyberware.Grade.ToString())
{
blnOK = false;
break;
}
}
}
}
if (!blnOK)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberwareGradeMismatch"), LanguageManager.Instance.GetString("MessageTitle_CyberwareGradeMismatch"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// The character has no Cyberware!
if (strGrade == "")
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NoCyberware"), LanguageManager.Instance.GetString("MessageTitle_NoCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
frmCreateCyberwareSuite frmBuildCyberwareSuite = new frmCreateCyberwareSuite(_objCharacter, objSource);
frmBuildCyberwareSuite.ShowDialog(this);
}
示例4: PickCyberware
/// <summary>
/// Open the Select Cyberware window and handle adding to the Tree and Character.
/// </summary>
private bool PickCyberware(Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Cyberware)
{
Cyberware objSelectedCyberware = new Cyberware(_objCharacter);
int intNode = 0;
if (objSource == Improvement.ImprovementSource.Bioware)
intNode = 1;
// Attempt to locate the selected piece of Cyberware.
try
{
if (treCyberware.SelectedNode.Level > 0)
objSelectedCyberware = _objFunctions.FindCyberware(treCyberware.SelectedNode.Tag.ToString(), _objCharacter.Cyberware);
}
catch
{
}
frmSelectCyberware frmPickCyberware = new frmSelectCyberware(_objCharacter);
double dblMultiplier = 1;
// Apply the character's Cyberware Essence cost multiplier if applicable.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.CyberwareEssCost) != 0 && objSource == Improvement.ImprovementSource.Cyberware)
{
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.CyberwareEssCost && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.CharacterESSMultiplier = dblMultiplier;
}
// Apply the character's Bioware Essence cost multiplier if applicable.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.BiowareEssCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.BiowareEssCost && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.CharacterESSMultiplier = dblMultiplier;
}
// Apply the character's Basic Bioware Essence cost multiplier if applicable.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.BasicBiowareEssCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
double dblBasicMultiplier = 1;
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.BasicBiowareEssCost && objImprovement.Enabled)
dblBasicMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.BasicBiowareESSMultiplier = dblBasicMultiplier;
}
// Genetech Cost multiplier.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.GenetechCostMultiplier) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
dblMultiplier = 1;
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.GenetechCostMultiplier && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.GenetechCostMultiplier = dblMultiplier;
}
// Transgenics Cost multiplier.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.TransgenicsBiowareCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
dblMultiplier = 1;
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.TransgenicsBiowareCost && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.TransgenicsBiowareCostMultiplier = dblMultiplier;
}
try
{
if (treCyberware.SelectedNode.Level > 0)
{
frmPickCyberware.SetGrade = cboCyberwareGrade.SelectedValue.ToString();
frmPickCyberware.LockGrade();
// If the Cyberware has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
if (!objSelectedCyberware.Capacity.Contains('['))
{
frmPickCyberware.ShowOnlySubsystems = true;
frmPickCyberware.Subsystems = objSelectedCyberware.Subsytems;
frmPickCyberware.MaximumCapacity = objSelectedCyberware.CapacityRemaining;
}
}
}
catch
{
}
if (objSource == Improvement.ImprovementSource.Bioware)
//.........这里部分代码省略.........
示例5: HasImprovement
/// <summary>
/// Determine whether or not the character has any Improvements of a given ImprovementType.
/// </summary>
/// <param name="objImprovementType">ImprovementType to search for.</param>
public bool HasImprovement(Improvement.ImprovementType objImprovementType, bool blnRequireEnabled = false)
{
foreach (Improvement objImprovement in _lstImprovements)
{
if (objImprovement.ImproveType == objImprovementType)
{
if (!blnRequireEnabled || (blnRequireEnabled && objImprovement.Enabled))
return true;
}
}
return false;
}
示例6: CMOverflowTest
public void CMOverflowTest()
{
// Create a new Human character.
Character objCharacter = new Character();
objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));
// Set the character's BOD to 4 and verify the Overflow.
objCharacter.BOD.Value = 4;
Assert.AreEqual(5, objCharacter.CMOverflow, "CM Overflow does not equal the expected value of 5.");
// Add an Overflow Improvement and verify it is correct.
Improvement objImprovement = new Improvement();
objImprovement.ImproveType = Improvement.ImprovementType.CMOverflow;
objImprovement.Value = 1;
objImprovement.ImproveSource = Improvement.ImprovementSource.Quality;
objCharacter.Improvements.Add(objImprovement);
Assert.AreEqual(6, objCharacter.CMOverflow, "CM Overflow does not equal the expected value of 6.");
}
示例7: RemoveImprovements
/// <summary>
/// Remove all of the Improvements for an XML Node.
/// </summary>
/// <param name="objImprovementSource">Type of object that granted these Improvements.</param>
/// <param name="strSourceName">Name of the item that granted these Improvements.</param>
public void RemoveImprovements(Improvement.ImprovementSource objImprovementSource, string strSourceName)
{
Log.Enter("RemoveImprovements");
Log.Info("objImprovementSource = " + objImprovementSource.ToString());
Log.Info("strSourceName = " + strSourceName);
// If there is no character object, don't try to remove any Improvements.
if (_objCharacter == null)
{
Log.Exit("RemoveImprovements");
return;
}
// A List of Improvements to hold all of the items that will eventually be deleted.
List<Improvement> objImprovementList = new List<Improvement>();
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveSource == objImprovementSource && objImprovement.SourceName == strSourceName)
objImprovementList.Add(objImprovement);
}
// Now that we have all of the applicable Improvements, remove them from the character.
foreach (Improvement objImprovement in objImprovementList)
{
// Remove the Improvement.
_objCharacter.Improvements.Remove(objImprovement);
if (objImprovement.ImproveType == Improvement.ImprovementType.SkillLevel)
{
//TODO: Come back here and figure out wtf this did? Think it removed nested lifemodule skills? //Didn't this handle the collapsing knowledge skills thing?
//for (int i = _objCharacter.SkillsSection.Skills.Count - 1; i >= 0; i--)
//{
// //wrote as foreach first, modify collection, not want rename
// Skill skill = _objCharacter.SkillsSection.Skills[i];
// for (int j = skill.Fold.Count - 1; j >= 0; j--)
// {
// Skill fold = skill.Fold[i];
// if (fold.Id.ToString() == objImprovement.ImprovedName)
// {
// skill.Free(fold);
// _objCharacter.SkillsSection.Skills.Remove(fold);
// }
// }
// if (skill.Id.ToString() == objImprovement.ImprovedName)
// {
// while(skill.Fold.Count > 0) skill.Free(skill.Fold[0]);
// //empty list, can't call clear as exposed list is RO
// _objCharacter.SkillsSection.Skills.Remove(skill);
// }
//}
}
if (objImprovement.ImproveType == Improvement.ImprovementType.SkillsoftAccess)
{
_objCharacter.SkillsSection.KnowledgeSkills.RemoveAll(_objCharacter.SkillsSection.KnowsoftSkills.Contains);
}
if (objImprovement.ImproveType == Improvement.ImprovementType.SkillKnowledgeForced)
{
Guid guid = Guid.Parse(objImprovement.ImprovedName);
_objCharacter.SkillsSection.KnowledgeSkills.RemoveAll(skill => skill.Id == guid);
_objCharacter.SkillsSection.KnowsoftSkills.RemoveAll(skill => skill.Id == guid);
}
// Remove "free" adept powers if any.
if (objImprovement.ImproveType == Improvement.ImprovementType.AdeptPower)
{
// Load the power from XML.
// objImprovement.Notes = name of the mentor spirit choice. Find the power name from here.
// TODO: Fix this properly. Generates a null exception if multiple adept powers are added by the improvement, as with the Dragonslayer Mentor Spirit.
try
{
XmlDocument objXmlMentorDocument = new XmlDocument();
objXmlMentorDocument = XmlManager.Instance.Load("mentors.xml");
XmlNode objXmlMentorBonus =
objXmlMentorDocument.SelectSingleNode("/chummer/mentors/mentor/choices/choice[name = \"" +
objImprovement.Notes +
"\"]");
XmlNodeList objXmlPowerList = objXmlMentorBonus["bonus"].SelectNodes("specificpower");
foreach (XmlNode objXmlSpecificPower in objXmlPowerList)
{
// Get the Power information
XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument = XmlManager.Instance.Load("powers.xml");
string strPowerName = objXmlSpecificPower["name"].InnerText;
// Find the power (if it still exists)
foreach (Power objPower in _objCharacter.Powers)
{
if (objPower.Name == strPowerName)
{
// Disable the free property and remove any free levels.
//.........这里部分代码省略.........
示例8: CreateImprovement
/// <summary>
/// Create a new Improvement and add it to the Character.
/// </summary>
/// <param name="strImprovedName">Speicific name of the Improved object - typically the name of an CharacterAttribute being improved.</param>
/// <param name="objImprovementSource">Type of object that grants this Improvement.</param>
/// <param name="strSourceName">Name of the item that grants this Improvement.</param>
/// <param name="objImprovementType">Type of object the Improvement applies to.</param>
/// <param name="strUnique">Name of the pool this Improvement should be added to - only the single higest value in the pool will be applied to the character.</param>
/// <param name="intValue">Set a Value for the Improvement.</param>
/// <param name="intRating">Set a Rating for the Improvement - typically used for Adept Powers.</param>
/// <param name="intMinimum">Improve the Minimum for an CharacterAttribute by the given amount.</param>
/// <param name="intMaximum">Improve the Maximum for an CharacterAttribute by the given amount.</param>
/// <param name="intAugmented">Improve the Augmented value for an CharacterAttribute by the given amount.</param>
/// <param name="intAugmentedMaximum">Improve the Augmented Maximum value for an CharacterAttribute by the given amount.</param>
/// <param name="strExclude">A list of child items that should not receive the Improvement's benefit (typically for Skill Groups).</param>
/// <param name="blnAddToRating">Whether or not the bonus applies to a Skill's Rating instead of the dice pool in general.</param>
public void CreateImprovement(string strImprovedName, Improvement.ImprovementSource objImprovementSource,
string strSourceName, Improvement.ImprovementType objImprovementType, string strUnique,
int intValue = 0, int intRating = 1, int intMinimum = 0, int intMaximum = 0, int intAugmented = 0,
int intAugmentedMaximum = 0, string strExclude = "", bool blnAddToRating = false)
{
Log.Enter("CreateImprovement");
Log.Info(
"strImprovedName = " + strImprovedName);
Log.Info(
"objImprovementSource = " + objImprovementSource.ToString());
Log.Info(
"strSourceName = " + strSourceName);
Log.Info(
"objImprovementType = " + objImprovementType.ToString());
Log.Info( "strUnique = " + strUnique);
Log.Info(
"intValue = " + intValue.ToString());
Log.Info(
"intRating = " + intRating.ToString());
Log.Info(
"intMinimum = " + intMinimum.ToString());
Log.Info(
"intMaximum = " + intMaximum.ToString());
Log.Info(
"intAugmented = " + intAugmented.ToString());
Log.Info(
"intAugmentedMaximum = " + intAugmentedMaximum.ToString());
Log.Info( "strExclude = " + strExclude);
Log.Info(
"blnAddToRating = " + blnAddToRating.ToString());
// Record the improvement.
Improvement objImprovement = new Improvement();
objImprovement.ImprovedName = strImprovedName;
objImprovement.ImproveSource = objImprovementSource;
objImprovement.SourceName = strSourceName;
objImprovement.ImproveType = objImprovementType;
objImprovement.UniqueName = strUnique;
objImprovement.Value = intValue;
objImprovement.Rating = intRating;
objImprovement.Minimum = intMinimum;
objImprovement.Maximum = intMaximum;
objImprovement.Augmented = intAugmented;
objImprovement.AugmentedMaximum = intAugmentedMaximum;
objImprovement.Exclude = strExclude;
objImprovement.AddToRating = blnAddToRating;
// Do not attempt to add the Improvements if the Character is null (as a result of Cyberware being added to a VehicleMod).
if (_objCharacter != null)
{
// Add the Improvement to the list.
_objCharacter.Improvements.Add(objImprovement);
// Add the Improvement to the Transaction List.
_lstTransaction.Add(objImprovement);
}
Log.Exit("CreateImprovement");
}
示例9: chkImprovementActive_CheckedChanged
private void chkImprovementActive_CheckedChanged(object sender, EventArgs e)
{
if (_blnSkipRefresh)
return;
try
{
if (treImprovements.SelectedNode.Level > 0)
{
Improvement objImprovement = new Improvement();
foreach (Improvement objCharacterImprovement in _objCharacter.Improvements)
{
if (objCharacterImprovement.SourceName == treImprovements.SelectedNode.Tag.ToString())
{
objImprovement = objCharacterImprovement;
break;
}
}
objImprovement.Enabled = chkImprovementActive.Checked;
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
}
catch
{
}
}
示例10: tsImprovementNotes_Click
private void tsImprovementNotes_Click(object sender, EventArgs e)
{
try
{
if (treImprovements.SelectedNode.Level > 0)
{
Improvement objImprovement = new Improvement();
foreach (Improvement objCharacterImprovement in _objCharacter.Improvements)
{
if (objCharacterImprovement.SourceName == treImprovements.SelectedNode.Tag.ToString())
{
objImprovement = objCharacterImprovement;
break;
}
}
frmNotes frmItemNotes = new frmNotes();
frmItemNotes.Notes = objImprovement.Notes;
string strOldValue = objImprovement.Notes;
frmItemNotes.ShowDialog(this);
if (frmItemNotes.DialogResult == DialogResult.OK)
{
objImprovement.Notes = frmItemNotes.Notes;
if (objImprovement.Notes != strOldValue)
{
_blnIsDirty = true;
UpdateWindowTitle();
}
}
if (objImprovement.Notes != string.Empty)
{
if (objImprovement.Enabled)
treImprovements.SelectedNode.ForeColor = Color.SaddleBrown;
else
treImprovements.SelectedNode.ForeColor = Color.SandyBrown;
}
else
{
if (objImprovement.Enabled)
treImprovements.SelectedNode.ForeColor = SystemColors.WindowText;
else
treImprovements.SelectedNode.ForeColor = SystemColors.GrayText;
}
treImprovements.SelectedNode.ToolTipText = objImprovement.Notes;
}
}
catch
{
}
}
示例11: treImprovements_DoubleClick
private void treImprovements_DoubleClick(object sender, EventArgs e)
{
try
{
if (treImprovements.SelectedNode.Level > 0)
{
Improvement objImprovement = new Improvement();
foreach (Improvement objCharacterImprovement in _objCharacter.Improvements)
{
if (objCharacterImprovement.SourceName == treImprovements.SelectedNode.Tag.ToString())
{
objImprovement = objCharacterImprovement;
break;
}
}
// Edit the selected Improvement.
frmCreateImprovement frmPickImprovement = new frmCreateImprovement(_objCharacter);
frmPickImprovement.EditImprovementObject = objImprovement;
frmPickImprovement.ShowDialog(this);
if (frmPickImprovement.DialogResult != DialogResult.Cancel)
{
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
}
}
catch
{
}
}
示例12: treImprovements_AfterSelect
private void treImprovements_AfterSelect(object sender, TreeViewEventArgs e)
{
lblImprovementType.Text = "";
lblImprovementValue.Text = "";
if (treImprovements.SelectedNode.Level == 0)
{
cmdImprovementsEnableAll.Visible = true;
cmdImprovementsDisableAll.Visible = true;
}
else
{
cmdImprovementsEnableAll.Visible = false;
cmdImprovementsDisableAll.Visible = false;
}
_blnSkipRefresh = true;
try
{
if (treImprovements.SelectedNode.Level == 0)
{
lblImprovementType.Text = "";
lblImprovementValue.Text = "";
chkImprovementActive.Checked = false;
}
else
{
Improvement objImprovement = new Improvement();
foreach (Improvement objCharacterImprovement in _objCharacter.Improvements)
{
if (objCharacterImprovement.SourceName == treImprovements.SelectedNode.Tag.ToString())
{
objImprovement = objCharacterImprovement;
break;
}
}
// Get the human-readable name of the Improvement from the Improvements file.
XmlDocument objXmlDocument = XmlManager.Instance.Load("improvements.xml");
XmlNode objNode = objXmlDocument.SelectSingleNode("/chummer/improvements/improvement[id = \"" + objImprovement.CustomId + "\"]");
string strName = objNode["name"].InnerText;
if (objNode["translate"] != null)
strName = objNode["translate"].InnerText;
// Build a string that contains the value(s) of the Improvement.
string strValue = "";
if (objImprovement.Value != 0)
strValue += LanguageManager.Instance.GetString("Label_CreateImprovementValue") + " " + objImprovement.Value.ToString() + ", ";
if (objImprovement.Minimum != 0)
strValue += LanguageManager.Instance.GetString("Label_CreateImprovementMinimum") + " " + objImprovement.Minimum.ToString() + ", ";
if (objImprovement.Maximum != 0)
strValue += LanguageManager.Instance.GetString("Label_CreateImprovementMaximum") + " " + objImprovement.Maximum.ToString() + ", ";
if (objImprovement.Augmented != 0)
strValue += LanguageManager.Instance.GetString("Label_CreateImprovementAugmented") + " " + objImprovement.Augmented.ToString() + ", ";
// Remove the trailing comma.
if (strValue != "")
strValue = strValue.Substring(0, strValue.Length - 2);
lblImprovementType.Text = strName;
lblImprovementValue.Text = strValue;
chkImprovementActive.Checked = objImprovement.Enabled;
}
}
catch
{
}
_blnSkipRefresh = false;
}
示例13: RefreshImprovements
/// <summary>
/// Refresh the list of Improvements.
/// </summary>
private void RefreshImprovements()
{
treImprovements.Nodes.Clear();
TreeNode objRoot = new TreeNode();
objRoot.Tag = null;
objRoot.Text = LanguageManager.Instance.GetString("Node_SelectedImprovements");
objRoot.Tag = "";
treImprovements.Nodes.Add(objRoot);
// Populate the Locations.
foreach (string strGroup in _objCharacter.ImprovementGroups)
{
TreeNode objGroup = new TreeNode();
objGroup.Tag = strGroup;
try
{
Guid.Parse(strGroup);
objGroup.Text = _objFunctions.GetObjectName(strGroup);
objGroup.Tag = strGroup;
}
catch
{
objGroup.Text = strGroup;
objGroup.Tag = strGroup;
}
objGroup.ContextMenuStrip = cmsImprovementLocation;
treImprovements.Nodes.Add(objGroup);
}
List<ListItem> lstImprovements = new List<ListItem>();
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveSource == Improvement.ImprovementSource.Custom || objImprovement.CustomGroup != string.Empty)
{
string strName = "000000";
strName = strName.Substring(0, 6 - objImprovement.SortOrder.ToString().Length) + objImprovement.SortOrder.ToString();
ListItem objItem = new ListItem();
objItem.Value = objImprovement.SourceName;
objItem.Name = strName;
lstImprovements.Add(objItem);
}
}
// Populate the Improvements TreeView.
int i = -1;
foreach (ListItem objItem in lstImprovements)
{
i++;
Improvement objImprovement = new Improvement();
foreach (Improvement objCharacterImprovement in _objCharacter.Improvements)
{
if (objCharacterImprovement.SourceName == objItem.Value)
{
objImprovement = objCharacterImprovement;
break;
}
}
TreeNode nodImprovement = new TreeNode();
nodImprovement.Tag = objImprovement.SourceName;
nodImprovement.Text = objImprovement.CustomName;
if (objImprovement.Notes != string.Empty)
{
if (objImprovement.Enabled)
nodImprovement.ForeColor = Color.SaddleBrown;
else
nodImprovement.ForeColor = Color.SandyBrown;
}
else
{
if (objImprovement.Enabled)
nodImprovement.ForeColor = SystemColors.WindowText;
else
nodImprovement.ForeColor = SystemColors.GrayText;
}
nodImprovement.ToolTipText = objImprovement.Notes;
nodImprovement.ContextMenuStrip = cmsImprovement;
TreeNode objParent = new TreeNode();
if (objImprovement.CustomGroup == "")
objParent = treImprovements.Nodes[0];
else
{
foreach (TreeNode objFind in treImprovements.Nodes)
{
if (objFind.Tag.ToString() == objImprovement.CustomGroup)
{
objParent = objFind;
break;
}
}
}
objParent.Nodes.Add(nodImprovement);
objParent.Expand();
}
//.........这里部分代码省略.........
示例14: AddCyberwareSuite
private void AddCyberwareSuite(Improvement.ImprovementSource objSource)
{
frmSelectCyberwareSuite frmPickCyberwareSuite = new frmSelectCyberwareSuite(objSource, _objCharacter);
frmPickCyberwareSuite.ShowDialog(this);
if (frmPickCyberwareSuite.DialogResult == DialogResult.Cancel)
return;
int intCost = frmPickCyberwareSuite.TotalCost;
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_ExpensePurchaseCyberwareSuite") + " " + frmPickCyberwareSuite.SelectedSuite, ExpenseType.Nuyen, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Nuyen -= intCost;
}
string strType = "";
int intParentNode = 0;
if (objSource == Improvement.ImprovementSource.Cyberware)
{
strType = "cyberware";
intParentNode = 0;
}
else
{
strType = "bioware";
intParentNode = 1;
}
XmlDocument objXmlDocument = XmlManager.Instance.Load(strType + ".xml");
XmlNode objXmlSuite = objXmlDocument.SelectSingleNode("/chummer/suites/suite[name = \"" + frmPickCyberwareSuite.SelectedSuite + "\"]");
Cyberware objTemp = new Cyberware(_objCharacter);
Grade objGrade = new Grade();
objGrade = objTemp.ConvertToCyberwareGrade(objXmlSuite["grade"].InnerText, objSource);
// Run through each of the items in the Suite and add them to the character.
foreach (XmlNode objXmlItem in objXmlSuite.SelectNodes(strType + "s/" + strType))
{
XmlNode objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/" + strType + "s/" + strType + "[name = \"" + objXmlItem["name"].InnerText + "\"]");
TreeNode objNode = new TreeNode();
int intRating = 0;
if (objXmlItem["rating"] != null)
intRating = Convert.ToInt32(objXmlItem["rating"].InnerText);
objNode = CreateSuiteCyberware(objXmlItem, objXmlCyberware, objGrade, intRating, true, objSource, strType, null);
objNode.Expand();
treCyberware.Nodes[intParentNode].Nodes.Add(objNode);
treCyberware.Nodes[intParentNode].Expand();
}
_blnIsDirty = true;
UpdateWindowTitle();
UpdateCharacterInfo();
}
示例15: PickCyberware
/// <summary>
/// Open the Select Cyberware window and handle adding to the Tree and Character.
/// </summary>
private bool PickCyberware(Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Cyberware)
{
// Determine the lowest whole number for the character's current Essence.
decimal decStartingESS = Math.Floor(_objCharacter.Essence);
Cyberware objSelectedCyberware = new Cyberware(_objCharacter);
int intNode = 0;
if (objSource == Improvement.ImprovementSource.Bioware)
intNode = 1;
// Attempt to locate the selected piece of Cyberware.
try
{
if (treCyberware.SelectedNode.Level > 0)
objSelectedCyberware = _objFunctions.FindCyberware(treCyberware.SelectedNode.Tag.ToString(), _objCharacter.Cyberware);
}
catch
{
}
frmSelectCyberware frmPickCyberware = new frmSelectCyberware(_objCharacter, true);
double dblMultiplier = 1;
// Apply the character's Cyberware Essence cost multiplier if applicable.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.CyberwareEssCost) != 0 && objSource == Improvement.ImprovementSource.Cyberware)
{
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.CyberwareEssCost && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.CharacterESSMultiplier = dblMultiplier;
}
// Apply the character's Bioware Essence cost multiplier if applicable.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.BiowareEssCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.BiowareEssCost && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.CharacterESSMultiplier = dblMultiplier;
}
// Apply the character's Basic Bioware Essence cost multiplier if applicable.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.BasicBiowareEssCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
double dblBasicMultiplier = 1;
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.BasicBiowareEssCost && objImprovement.Enabled)
dblBasicMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.BasicBiowareESSMultiplier = dblBasicMultiplier;
}
// Genetech Cost multiplier.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.GenetechCostMultiplier) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
dblMultiplier = 1;
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.GenetechCostMultiplier && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.GenetechCostMultiplier = dblMultiplier;
}
// Transgenics Cost multiplier.
if (_objImprovementManager.ValueOf(Improvement.ImprovementType.TransgenicsBiowareCost) != 0 && objSource == Improvement.ImprovementSource.Bioware)
{
dblMultiplier = 1;
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.ImproveType == Improvement.ImprovementType.TransgenicsBiowareCost && objImprovement.Enabled)
dblMultiplier -= (1 - (Convert.ToDouble(objImprovement.Value, GlobalOptions.Instance.CultureInfo) / 100));
}
frmPickCyberware.TransgenicsBiowareCostMultiplier = dblMultiplier;
}
try
{
if (treCyberware.SelectedNode.Level > 0)
{
frmPickCyberware.SetGrade = lblCyberwareGrade.Text;
frmPickCyberware.LockGrade();
// If the Cyberware has a Capacity with no brackets (meaning it grants Capacity), show only Subsystems (those that conume Capacity).
if (!objSelectedCyberware.Capacity.Contains('['))
{
frmPickCyberware.ShowOnlySubsystems = true;
frmPickCyberware.Subsystems = objSelectedCyberware.Subsytems;
frmPickCyberware.MaximumCapacity = objSelectedCyberware.CapacityRemaining;
// Do not allow the user to add a new piece of Cyberware if its Capacity has been reached.
if (_objOptions.EnforceCapacity && objSelectedCyberware.CapacityRemaining < 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
//.........这里部分代码省略.........