当前位置: 首页>>代码示例>>C#>>正文


C# Cyberware.Create方法代码示例

本文整理汇总了C#中Cyberware.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Cyberware.Create方法的具体用法?C# Cyberware.Create怎么用?C# Cyberware.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cyberware的用法示例。


在下文中一共展示了Cyberware.Create方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAllBiowareTest

        public void CreateAllBiowareTest()
        {
            // Create a new Human character.
            Character objCharacter = new Character();
            objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));

            TreeNode objNode = new TreeNode();
            List<Weapon> lstWeapons = new List<Weapon>();
            List<TreeNode> lstTreeNodes = new List<TreeNode>();

            GradeList objGradeList = new GradeList();
            objGradeList.LoadList(Improvement.ImprovementSource.Bioware);

            XmlDocument objXmlDocument = XmlManager.Instance.Load("bioware.xml");
            foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/biowares/bioware"))
            {
                Cyberware objCyberware = new Cyberware(objCharacter);
                objCyberware.Create(objXmlNode, objCharacter, objGradeList.GetGrade("Standard"), Improvement.ImprovementSource.Bioware, 1, objNode, lstWeapons, lstTreeNodes);
            }
        }
开发者ID:janhelke,项目名称:chummer2,代码行数:20,代码来源:EquipmentTests.cs

示例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;
//.........这里部分代码省略.........
开发者ID:cormanater,项目名称:chummer5a,代码行数:101,代码来源:frmCreate.cs

示例3: CreateSuiteCyberware

        /// <summary>
        /// Create Cyberware from a Cyberware Suite.
        /// </summary>
        /// <param name="objXmlNode">XmlNode for the Cyberware to add.</param>
        /// <param name="objGrade">CyberwareGrade to add the item as.</param>
        /// <param name="intRating">Rating of the Cyberware.</param>
        /// <param name="blnAddToCharacter">Whether or not the Cyberware should be added directly to the character.</param>
        /// <param name="objParent">Parent Cyberware if the item is not being added directly to the character.</param>
        private TreeNode CreateSuiteCyberware(XmlNode objXmlItem, XmlNode objXmlNode, Grade objGrade, int intRating, bool blnAddToCharacter, Improvement.ImprovementSource objSource, string strType, Cyberware objParent = null)
        {
            // Create the Cyberware object.
            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            TreeNode objNode = new TreeNode();
            Cyberware objCyberware = new Cyberware(_objCharacter);
            string strForced = "";

            if (objXmlItem["name"].Attributes["select"] != null)
                strForced = objXmlItem["name"].Attributes["select"].InnerText;

            objCyberware.Create(objXmlNode, _objCharacter, objGrade, objSource, intRating, objNode, objWeapons, objWeaponNodes, true, true, strForced);
            objCyberware.Suite = true;

            foreach (Weapon objWeapon in objWeapons)
                _objCharacter.Weapons.Add(objWeapon);

            foreach (TreeNode objWeaponNode in objWeaponNodes)
            {
                treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                treWeapons.Nodes[0].Expand();
            }

            if (blnAddToCharacter)
                _objCharacter.Cyberware.Add(objCyberware);
            else
                objParent.Children.Add(objCyberware);

            foreach (XmlNode objXmlChild in objXmlItem.SelectNodes(strType + "s/" + strType))
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load(strType + ".xml");
                XmlNode objXmlChildCyberware = objXmlDocument.SelectSingleNode("/chummer/" + strType + "s/" + strType + "[name = \"" + objXmlChild["name"].InnerText + "\"]");
                TreeNode objChildNode = new TreeNode();
                int intChildRating = 0;

                if (objXmlChild["rating"] != null)
                    intChildRating = Convert.ToInt32(objXmlChild["rating"].InnerText);

                objChildNode = CreateSuiteCyberware(objXmlChild, objXmlChildCyberware, objGrade, intChildRating, false, objSource, strType, objCyberware);
                objNode.Nodes.Add(objChildNode);
                objNode.Expand();
            }

            return objNode;
        }
开发者ID:cormanater,项目名称:chummer5a,代码行数:54,代码来源:frmCreate.cs

示例4: PickCyberware


//.........这里部分代码省略.........
            catch
            {
            }

            if (objSource == Improvement.ImprovementSource.Bioware)
                frmPickCyberware.WindowMode = frmSelectCyberware.Mode.Bioware;

            frmPickCyberware.AllowModularPlugins = objSelectedCyberware.AllowModularPlugins;

            frmPickCyberware.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickCyberware.DialogResult == DialogResult.Cancel)
                return false;

            // Open the Cyberware XML file and locate the selected piece.
            XmlDocument objXmlDocument = new XmlDocument();
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlDocument = XmlManager.Instance.Load("bioware.xml");
            else
                objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            XmlNode objXmlCyberware;
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/biowares/bioware[name = \"" + frmPickCyberware.SelectedCyberware + "\"]");
            else
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + frmPickCyberware.SelectedCyberware + "\"]");

            // Create the Cyberware object.
            Cyberware objCyberware = new Cyberware(_objCharacter);
            List<Weapon> objWeapons = new List<Weapon>();
            TreeNode objNode = new TreeNode();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            objCyberware.Create(objXmlCyberware, _objCharacter, frmPickCyberware.SelectedGrade, objSource, frmPickCyberware.SelectedRating, objNode, objWeapons, objWeaponNodes);
            if (objCyberware.InternalId == Guid.Empty.ToString())
                return false;

            // Force the item to be Transgenic if selected.
            if (frmPickCyberware.ForceTransgenic)
                objCyberware.Category = "Genetech: Transgenics";

            // Apply the ESS discount if applicable.
            if (_objOptions.AllowCyberwareESSDiscounts)
                objCyberware.ESSDiscount = frmPickCyberware.SelectedESSDiscount;

            if (frmPickCyberware.FreeCost)
                objCyberware.Cost = "0";

            try
            {
                if (treCyberware.SelectedNode.Level > 0)
                {
                    treCyberware.SelectedNode.Nodes.Add(objNode);
                    treCyberware.SelectedNode.Expand();
                    objSelectedCyberware.Children.Add(objCyberware);
                    objCyberware.Parent = objSelectedCyberware;
                }
                else
                {
                    treCyberware.Nodes[intNode].Nodes.Add(objNode);
                    treCyberware.Nodes[intNode].Expand();
                    _objCharacter.Cyberware.Add(objCyberware);
                }
            }
            catch
            {
开发者ID:cormanater,项目名称:chummer5a,代码行数:67,代码来源:frmCreate.cs

示例5: tsVehicleAddCyberware_Click

        private void tsVehicleAddCyberware_Click(object sender, EventArgs e)
        {
            Vehicle objVehicle = new Vehicle(_objCharacter);
            VehicleMod objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);

            if (objMod == null)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleCyberwarePlugin"), LanguageManager.Instance.GetString("MessageTitle_NoCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!objMod.AllowCyberware)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleCyberwarePlugin"), LanguageManager.Instance.GetString("MessageTitle_NoCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectCyberware frmPickCyberware = new frmSelectCyberware(_objCharacter);
            frmPickCyberware.SetGrade = "Standard";
            frmPickCyberware.LockGrade();
            frmPickCyberware.ShowOnlySubsystems = true;
            frmPickCyberware.Subsystems = objMod.Subsystems;
            frmPickCyberware.AllowModularPlugins = objMod.AllowModularPlugins;
            frmPickCyberware.ShowDialog(this);

            if (frmPickCyberware.DialogResult == DialogResult.Cancel)
                return;

            // Open the Cyberware XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            XmlNode objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + frmPickCyberware.SelectedCyberware + "\"]");

            // Create the Cyberware object.
            Cyberware objCyberware = new Cyberware(_objCharacter);
            List<Weapon> objWeapons = new List<Weapon>();
            TreeNode objNode = new TreeNode();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            objCyberware.Create(objXmlCyberware, _objCharacter, frmPickCyberware.SelectedGrade, Improvement.ImprovementSource.Cyberware, frmPickCyberware.SelectedRating, objNode, objWeapons, objWeaponNodes, false);
            if (objCyberware.InternalId == Guid.Empty.ToString())
                return;

            if (frmPickCyberware.FreeCost)
                objCyberware.Cost = "0";

            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();
            objMod.Cyberware.Add(objCyberware);

            foreach (Weapon objWeapon in objWeapons)
            {
                objWeapon.VehicleMounted = true;
                objVehicle.Weapons.Add(objWeapon);
            }

            // Create the Weapon Node if one exists.
            foreach (TreeNode objWeaponNode in objWeaponNodes)
            {
                objWeaponNode.ContextMenuStrip = cmsVehicleWeapon;
                treVehicles.SelectedNode.Parent.Nodes.Add(objWeaponNode);
                treVehicles.SelectedNode.Parent.Expand();
            }

            UpdateCharacterInfo();

            if (frmPickCyberware.AddAgain)
                tsVehicleAddCyberware_Click(sender, e);
        }
开发者ID:cormanater,项目名称:chummer5a,代码行数:68,代码来源:frmCreate.cs

示例6: tsVehicleAddCyberware_Click

        private void tsVehicleAddCyberware_Click(object sender, EventArgs e)
        {
            Vehicle objVehicle = new Vehicle(_objCharacter);
            VehicleMod objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);

            if (objMod == null)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleCyberwarePlugin"), LanguageManager.Instance.GetString("MessageTitle_NoCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!objMod.AllowCyberware)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleCyberwarePlugin"), LanguageManager.Instance.GetString("MessageTitle_NoCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectCyberware frmPickCyberware = new frmSelectCyberware(_objCharacter);
            frmPickCyberware.SetGrade = "Standard";
            frmPickCyberware.LockGrade();
            frmPickCyberware.ShowOnlySubsystems = true;
            frmPickCyberware.Subsystems = objMod.Subsystems;
            frmPickCyberware.AllowModularPlugins = objMod.AllowModularPlugins;
            frmPickCyberware.ShowDialog(this);

            if (frmPickCyberware.DialogResult == DialogResult.Cancel)
                return;

            // Open the Cyberware XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            XmlNode objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + frmPickCyberware.SelectedCyberware + "\"]");

            // Create the Cyberware object.
            Cyberware objCyberware = new Cyberware(_objCharacter);
            List<Weapon> objWeapons = new List<Weapon>();
            TreeNode objNode = new TreeNode();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            objCyberware.Create(objXmlCyberware, _objCharacter, frmPickCyberware.SelectedGrade, Improvement.ImprovementSource.Cyberware, frmPickCyberware.SelectedRating, objNode, objWeapons, objWeaponNodes, false);
            if (objCyberware.InternalId == Guid.Empty.ToString())
                return;

            if (frmPickCyberware.FreeCost)
                objCyberware.Cost = "0";

            int intCost = objCyberware.TotalCost;

            // Multiply the cost if applicable.
            if (objCyberware.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
                intCost *= _objOptions.RestrictedCostMultiplier;
            if (objCyberware.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
                intCost *= _objOptions.ForbiddenCostMultiplier;

            // Check the item's Cost and make sure the character can afford it.
            if (!frmPickCyberware.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    string strEntry = "";
                    strEntry = LanguageManager.Instance.GetString("String_ExpensePurchaseVehicleCyberware");
                    objExpense.Create(intCost * -1, strEntry + " " + objCyberware.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;

                    ExpenseUndo objUndo = new ExpenseUndo();
                    objUndo.CreateNuyen(NuyenExpenseType.AddVehicleModCyberware, objCyberware.InternalId);
                    objExpense.Undo = objUndo;
                }
            }

            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();
            objMod.Cyberware.Add(objCyberware);

            foreach (Weapon objWeapon in objWeapons)
            {
                objWeapon.VehicleMounted = true;
                objVehicle.Weapons.Add(objWeapon);
            }

            // Create the Weapon Node if one exists.
            foreach (TreeNode objWeaponNode in objWeaponNodes)
            {
                objWeaponNode.ContextMenuStrip = cmsVehicleWeapon;
                treVehicles.SelectedNode.Parent.Nodes.Add(objWeaponNode);
                treVehicles.SelectedNode.Parent.Expand();
            }

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs

示例7: PickCyberware


//.........这里部分代码省略.........
            catch
            {
            }

            if (objSource == Improvement.ImprovementSource.Bioware)
                frmPickCyberware.WindowMode = frmSelectCyberware.Mode.Bioware;

            frmPickCyberware.AllowModularPlugins = objSelectedCyberware.AllowModularPlugins;

            frmPickCyberware.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickCyberware.DialogResult == DialogResult.Cancel)
                return false;

            // Open the Cyberware XML file and locate the selected piece.
            XmlDocument objXmlDocument = new XmlDocument();
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlDocument = XmlManager.Instance.Load("bioware.xml");
            else
                objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            XmlNode objXmlCyberware;
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/biowares/bioware[name = \"" + frmPickCyberware.SelectedCyberware + "\"]");
            else
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + frmPickCyberware.SelectedCyberware + "\"]");

            // Create the Cyberware object.
            Cyberware objCyberware = new Cyberware(_objCharacter);
            List<Weapon> objWeapons = new List<Weapon>();
            TreeNode objNode = new TreeNode();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            objCyberware.Create(objXmlCyberware, _objCharacter, frmPickCyberware.SelectedGrade, objSource, frmPickCyberware.SelectedRating, objNode, objWeapons, objWeaponNodes);
            if (objCyberware.InternalId == Guid.Empty.ToString())
                return false;

            // Force the item to be Transgenic if selected.
            if (frmPickCyberware.ForceTransgenic)
                objCyberware.Category = "Genetech: Transgenics";

            // Apply the ESS discount if applicable.
            if (_objOptions.AllowCyberwareESSDiscounts)
                objCyberware.ESSDiscount = frmPickCyberware.SelectedESSDiscount;

            int intCost = objCyberware.TotalCost;

            // Multiply the cost if applicable.
            if (objCyberware.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
                intCost *= _objOptions.RestrictedCostMultiplier;
            if (objCyberware.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
                intCost *= _objOptions.ForbiddenCostMultiplier;

            // Check the item's Cost and make sure the character can afford it.
            if (!frmPickCyberware.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    // Remove any Improvements created by the Cyberware.
                    _objImprovementManager.RemoveImprovements(objCyberware.SourceType, objCyberware.InternalId);
                    return frmPickCyberware.AddAgain;
                }
                else
                {
                    // Create the Expense Log Entry.
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:67,代码来源:frmCareer.cs

示例8: ParseNode

        /// <summary>
        /// Parse an XmlNode and create the Cyberware for it and its children, adding them to the list of Cyberware in the suite.
        /// </summary>
        /// <param name="objXmlSuite">XmlNode to parse.</param>
        /// <param name="objGrade">Grade that the Cyberware should be created with.</param>
        /// <param name="objParent">Parent that child items should be assigned to.</param>
        private void ParseNode(XmlNode objXmlSuite, Grade objGrade, Cyberware objParent)
        {
            // Run through all of the items in the Suite list.
            foreach (XmlNode objXmlItem in objXmlSuite.SelectNodes(_strType + "s/" + _strType))
            {
                int intRating = 0;
                if (objXmlItem["rating"] != null)
                {
                    intRating = Convert.ToInt32(objXmlItem["rating"].InnerText);
                }

                // Retrieve the information for the current piece of Cyberware and add it to the ESS and Cost totals.
                XmlNode objXmlCyberware = _objXmlDocument.SelectSingleNode("/chummer/" + _strType + "s/" + _strType + "[name = \"" + objXmlItem["name"].InnerText + "\"]");

                TreeNode objTreeNode = new TreeNode();
                List<Weapon> lstWeapons = new List<Weapon>();
                List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                Cyberware objCyberware = new Cyberware(_objCharacter);
                objCyberware.Create(objXmlCyberware, _objCharacter, objGrade, _objSource, intRating, objTreeNode, lstWeapons, lstWeaponNodes, false, false);
                objCyberware.Suite = true;

                if (objParent == null)
                    _lstCyberware.Add(objCyberware);
                else
                    objParent.Children.Add(objCyberware);

                ParseNode(objXmlItem, objGrade, objCyberware);
            }
        }
开发者ID:kingcortez905,项目名称:chummer5,代码行数:35,代码来源:frmSelectCyberwareSuite.cs

示例9: IncreaseEssenceHole

        private void IncreaseEssenceHole(int centiessence)
        {
            //id of essence hole, get by id to avoid name confusions
            Guid essenceHoldID = Guid.Parse("b57eadaa-7c3b-4b80-8d79-cbbd922c1196");  //don't parse for every obj
            Cyberware objHole = _objCharacter.Cyberware.Find(x => x.SourceID == essenceHoldID);

            if (objHole == null)
            {
                XmlDocument xmlCyberware = XmlManager.Instance.Load("cyberware.xml");
                XmlNode xmlEssHole = xmlCyberware.SelectSingleNode("//id[.='b57eadaa-7c3b-4b80-8d79-cbbd922c1196']/..");
                objHole = new Cyberware(_objCharacter);
                TreeNode treNode = new TreeNode();

                objHole.Create(xmlEssHole, _objCharacter, GlobalOptions.CyberwareGrades.GetGrade("Standard"), Improvement.ImprovementSource.Cyberware, centiessence, treNode, new List<Weapon>(), new List<TreeNode>());
                treCyberware.Nodes.Add(treNode);
                _objCharacter.Cyberware.Add(objHole);
            }
            else
            {
                objHole.Rating += centiessence;
            }
        }
开发者ID:suvjunmd,项目名称:chummer5a,代码行数:22,代码来源:frmCareer.cs

示例10: TestCyberware

        private void TestCyberware(string strFile)
        {
            string strPrefix = "";
            Improvement.ImprovementSource objSource = new Improvement.ImprovementSource();
            if (strFile == "bioware.xml")
            {
                strPrefix = "bioware";
                objSource = Improvement.ImprovementSource.Bioware;
            }
            else
            {
                strPrefix = "cyberware";
                objSource = Improvement.ImprovementSource.Cyberware;
            }

            Character objCharacter = new Character();
            XmlDocument objXmlDocument = XmlManager.Instance.Load(strFile);
            pgbProgress.Minimum = 0;
            pgbProgress.Value = 0;
            pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/" + strPrefix + "s/" + strPrefix).Count;

            // Gear.
            foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/" + strPrefix + "s/" + strPrefix))
            {
                pgbProgress.Value++;
                Application.DoEvents();
                try
                {
                    TreeNode objTempNode = new TreeNode();
                    Cyberware objTemp = new Cyberware(objCharacter);
                    List<Weapon> lstWeapons = new List<Weapon>();
                    List<TreeNode> lstNodes = new List<TreeNode>();
                    objTemp.Create(objXmlGear, objCharacter, GlobalOptions.CyberwareGrades.GetGrade("Standard"), objSource, 1, objTempNode, lstWeapons, lstNodes);
                    try
                    {
                        int objValue = objTemp.TotalCost;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
                    }
                    try
                    {
                        string objValue = objTemp.TotalAvail;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n";
                    }
                    try
                    {
                        int objValue = objTemp.TotalAgility;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAgility\n";
                    }
                    try
                    {
                        int objValue = objTemp.TotalBody;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalBody\n";
                    }
                    try
                    {
                        int objValue = objTemp.TotalStrength;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalStrength\n";
                    }
                    try
                    {
                        string objValue = objTemp.CalculatedCapacity;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCapacity\n";
                    }
                    try
                    {
                        decimal objValue = objTemp.CalculatedESS;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedESS\n";
                    }
                }
                catch
                {
                    txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
                }
            }
        }
开发者ID:hollis21,项目名称:Chummer,代码行数:96,代码来源:frmTest.cs

示例11: PickCyberware


//.........这里部分代码省略.........
            catch
            {
            }

            if (objSource == Improvement.ImprovementSource.Bioware)
                frmPickCyberware.WindowMode = frmSelectCyberware.Mode.Bioware;

            frmPickCyberware.AllowModularPlugins = objSelectedCyberware.AllowModularPlugins;

            frmPickCyberware.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickCyberware.DialogResult == DialogResult.Cancel)
                return false;

            // Open the Cyberware XML file and locate the selected piece.
            XmlDocument objXmlDocument = new XmlDocument();
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlDocument = XmlManager.Instance.Load("bioware.xml");
            else
                objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            XmlNode objXmlCyberware;
            if (objSource == Improvement.ImprovementSource.Bioware)
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/biowares/bioware[id = \"" + frmPickCyberware.SelectedCyberware + "\"]");
            else
                objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/cyberwares/cyberware[id = \"" + frmPickCyberware.SelectedCyberware + "\"]");

            // Create the Cyberware object.
            Cyberware objCyberware = new Cyberware(_objCharacter);
            List<Weapon> objWeapons = new List<Weapon>();
            TreeNode objNode = new TreeNode();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            objCyberware.Create(objXmlCyberware, _objCharacter, frmPickCyberware.SelectedGrade, objSource, frmPickCyberware.SelectedRating, objNode, objWeapons, objWeaponNodes);
            if (objCyberware.InternalId == Guid.Empty.ToString())
                return false;

            // Force the item to be Transgenic if selected.
            if (frmPickCyberware.ForceTransgenic)
                objCyberware.Category = "Genetech: Transgenics";

            int intCost = objCyberware.TotalCost;

            // Check the item's Cost and make sure the character can afford it.
            if (!frmPickCyberware.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    // Remove any Improvements created by the Cyberware.
                    _objImprovementManager.RemoveImprovements(objCyberware.SourceType, objCyberware.InternalId);
                    return frmPickCyberware.AddAgain;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    string strEntry = "";
                    if (objCyberware.SourceType == Improvement.ImprovementSource.Cyberware)
                        strEntry = LanguageManager.Instance.GetString("String_ExpensePurchaseCyberware");
                    else
                        strEntry = LanguageManager.Instance.GetString("String_ExpensePurchaseBioware");
                    objExpense.Create(intCost * -1, strEntry + " " + objCyberware.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;
开发者ID:janhelke,项目名称:chummer2,代码行数:66,代码来源:frmCareer.cs

示例12: UpdateCyberwareInfo

        /// <summary>
        /// Update the Cyberware's information based on the Cyberware selected and current Rating.
        /// </summary>
        private void UpdateCyberwareInfo()
        {
            if (lstCyberware.Text != "" && cboGrade.SelectedValue != null)
            {
                Cyberware objCyberware = new Cyberware(_objCharacter);

                XmlNode objNode = _objXmlDocument.SelectSingleNode("/chummer/" + _strNode + "s/" + _strNode + "[id = \"" + lstCyberware.SelectedValue + "\"]");
                Grade objGrade = GlobalOptions.CyberwareGrades.GetGrade(cboGrade.SelectedValue.ToString());
                Improvement.ImprovementSource objImprovementSource;
                if (_objMode == Mode.Cyberware)
                    objImprovementSource = Improvement.ImprovementSource.Cyberware;
                else
                    objImprovementSource = Improvement.ImprovementSource.Bioware;
                TreeNode objTreeNode = new TreeNode();
                List<Weapon> lstWeapons = new List<Weapon>();
                List<TreeNode> lstTreeNodes = new List<TreeNode>();
                objCyberware.Create(objNode, _objCharacter, objGrade, objImprovementSource, Convert.ToInt32(nudRating.Value, GlobalOptions.Instance.CultureInfo), objTreeNode, lstWeapons, lstTreeNodes, false);

                // Avail.
                lblAvail.Text = objCyberware.TotalAvail;

                // Cost.
                int intItemCost = 0;
                if (objCyberware.Cost.StartsWith("Variable"))
                {
                    int intMin = 0;
                    int intMax = 0;
                    string strCost = objCyberware.Cost.Replace("Variable(", string.Empty).Replace(")", string.Empty);
                    if (strCost.Contains("-"))
                    {
                        string[] strValues = strCost.Split('-');
                        intMin = Convert.ToInt32(strValues[0]);
                        intMax = Convert.ToInt32(strValues[1]);
                    }
                    else
                        intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));

                    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
                {
                    if (chkFree.Checked)
                        intItemCost = 0;
                    else
                        intItemCost = objCyberware.TotalCost;

                    lblCost.Text = String.Format("{0:###,###,##0¥}", intItemCost);
                }

                lblTest.Text = _objCharacter.AvailTest(intItemCost, lblAvail.Text);

                // Essence.
                lblEssence.Text = objCyberware.CalculatedESS.ToString();

                // Capacity.
                lblCapacity.Text = objCyberware.CalculatedCapacity;
            }
        }
开发者ID:janhelke,项目名称:chummer2,代码行数:69,代码来源:frmSelectCyberware.cs


注:本文中的Cyberware.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。