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


C# Lifestyle.Create方法代码示例

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


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

示例1: mnuSpecialCyberzombie_Click

        private void mnuSpecialCyberzombie_Click(object sender, EventArgs e)
        {
            bool blnEssence = true;
            bool blnCyberware = false;
            string strMessage = LanguageManager.Instance.GetString("Message_CyberzombieRequirements");

            // Make sure the character has an Essence lower than 0.
            if (_objCharacter.Essence >= 0)
            {
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsEssence");
                blnEssence = false;
            }

            // Make sure the character has an Invoked Memory Stimulator.
            foreach (Cyberware objCyberware in _objCharacter.Cyberware)
            {
                if (objCyberware.Name == "Invoked Memory Stimulator")
                    blnCyberware = true;
            }

            if (!blnCyberware)
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsStimulator");

            if (!blnEssence || !blnCyberware)
            {
                MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_CyberzombieRequirements"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberzombieConfirm"), LanguageManager.Instance.GetString("MessageTitle_CyberzombieConfirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                return;

            // Get the player to roll Dice to make a WIL Test and record the result.
            frmDiceHits frmWILHits = new frmDiceHits();
            frmWILHits.Text = LanguageManager.Instance.GetString("String_CyberzombieWILText");
            frmWILHits.Description = LanguageManager.Instance.GetString("String_CyberzombieWILDescription");
            int intDice = _objCharacter.WIL.TotalValue;
            int intThreshold = 3 + (Convert.ToInt32(_objCharacter.EssencePenalty - Convert.ToInt32(_objCharacter.EssenceMaximum)));
            frmWILHits.Dice = intDice;
            frmWILHits.ShowDialog(this);

            if (frmWILHits.DialogResult != DialogResult.OK)
                return;

            int intWILResult = frmWILHits.Result;

            // The character gains 10 + ((Threshold - Hits) * 10)BP worth of Negative Qualities.
            int intResult = 10;
            if (intWILResult < intThreshold)
            {
                intResult = (intThreshold - intWILResult) * 10;
            }
            _objImprovementManager.CreateImprovement("", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Qualities", Improvement.ImprovementType.FreeNegativeQualities, "", intResult * -1);

            // Convert the character.
            // Characters lose access to Resonance.
            _objCharacter.RESEnabled = false;

            // Gain MAG that is permanently set to 1.
            _objCharacter.MAGEnabled = true;
            _objCharacter.MAG.MetatypeMinimum = 1;
            _objCharacter.MAG.MetatypeMaximum = 1;
            _objCharacter.MAG.Value = 1;

            // Add the Cyberzombie Lifestyle if it is not already taken.
            bool blnHasLifestyle = false;
            foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
            {
                if (objLifestyle.Name == "Cyberzombie Lifestyle Addition")
                    blnHasLifestyle = true;
            }
            if (!blnHasLifestyle)
            {
                XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");
                XmlNode objXmlLifestyle = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"Cyberzombie Lifestyle Addition\"]");

                TreeNode objLifestyleNode = new TreeNode();
                Lifestyle objLifestyle = new Lifestyle(_objCharacter);
                objLifestyle.Create(objXmlLifestyle, objLifestyleNode);
                _objCharacter.Lifestyles.Add(objLifestyle);

                treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
                treLifestyles.Nodes[0].Expand();
            }

            // Change the MetatypeCategory to Cyberzombie.
            _objCharacter.MetatypeCategory = "Cyberzombie";

            // Gain access to Critter Powers.
            _objCharacter.CritterEnabled = true;

            // Gain the Dual Natured Critter Power if it does not yet exist.
            bool blnHasPower = false;
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                if (objPower.Name == "Dual Natured")
                    blnHasPower = true;
            }
            if (!blnHasPower)
            {
//.........这里部分代码省略.........
开发者ID:cormanater,项目名称:chummer5a,代码行数:101,代码来源:frmCreate.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: ValidateCharacter


//.........这里部分代码省略.........
                            // Check Underbarrel Weapons.
                            if (objWeapon.Weapons.Count > 0)
                            {
                                foreach (Weapon objUnderbarrelWeapon in objWeapon.Weapons)
                                {
                                    if (objUnderbarrelWeapon.SlotsRemaining < 0)
                                    {
                                        blnOverCapacity = true;
                                        intCapacityOver++;
                                    }
                                }
                            }
                        }
                    }
                }

                if (blnOverCapacity)
                {
                    blnValid = false;
                    strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CapacityReachedValidate").Replace("{0}", intCapacityOver.ToString());
                }
            }

            if (!_objCharacter.IgnoreRules)
            {
                if (!blnValid)
                    MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_Invalid"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
                blnValid = true;

            if (blnValid)
            {
                if (_objOptions.CreateBackupOnCareer && chkCharacterCreated.Checked)
                {
                    // Create a pre-Career Mode backup of the character.
                    // Make sure the backup directory exists.
                    if (!Directory.Exists(Path.Combine(GlobalOptions.ApplicationPath(), "saves", "backup")))
                        Directory.CreateDirectory(Path.Combine(GlobalOptions.ApplicationPath(), "saves", "backup"));

                    string strFileName = _objCharacter.FileName;
                    string[] strParts = strFileName.Split(Path.DirectorySeparatorChar);
                    string strNewName = strParts[strParts.Length - 1].Replace(".chum", " (" + LanguageManager.Instance.GetString("Title_CreateMode") + ").chum");
                    if (strNewName == string.Empty)
                    {
                        strNewName = _objCharacter.Alias;
                        if (strNewName == string.Empty)
                            strNewName = _objCharacter.Name;
                        if (strNewName == string.Empty)
                            strNewName = Guid.NewGuid().ToString().Substring(0, 13).Replace("-", string.Empty);
                        strNewName += " (" + LanguageManager.Instance.GetString("Title_CreateMode") + ").chum";
                    }

                    strNewName = Path.Combine(GlobalOptions.ApplicationPath(), "saves", "backup", strNewName);

                    _objCharacter.FileName = strNewName;
                    _objCharacter.Save();
                    _objCharacter.FileName = strFileName;
                }

                // See if the character has any Karma remaining.
                if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
                {
                    if (intBuildPoints > _objOptions.KarmaCarryover)
                    {
                        if (MessageBox.Show(LanguageManager.Instance.GetString("Message_ExtraKarma").Replace("{0}", intBuildPoints.ToString()).Replace("{1}", _objOptions.KarmaCarryover.ToString()), LanguageManager.Instance.GetString("MessageTitle_ExtraKarma"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
开发者ID:janhelke,项目名称:chummer2,代码行数:67,代码来源:frmCreate.cs

示例4: ValidateCharacter


//.........这里部分代码省略.........
                                    if (objUnderbarrelWeapon.SlotsRemaining < 0)
                                    {
                                        blnOverCapacity = true;
                                        lstOverCapacity.Add(objUnderbarrelWeapon.Name);
                                        intCapacityOver++;
                                    }
                                }
                            }
                        }
                    }
                }

                if (blnOverCapacity)
                {
                    blnValid = false;
                    strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CapacityReachedValidate").Replace("{0}", intCapacityOver.ToString());
                    foreach (string strItem in lstOverCapacity)
                    {
                        strMessage += "\n\t- " + strItem;
                    }
                }
            }

            if (!_objCharacter.IgnoreRules)
            {
                if (!blnValid)
                    MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_Invalid"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
                blnValid = true;

            if (blnValid)
            {
                if (_objOptions.CreateBackupOnCareer && chkCharacterCreated.Checked)
                {
                    // Create a pre-Career Mode backup of the character.
                    // Make sure the backup directory exists.
                    if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "saves", "backup")))
                        Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "saves", "backup"));

                    string strFileName = _objCharacter.FileName;
                    string[] strParts = strFileName.Split(Path.DirectorySeparatorChar);
                    string strNewName = strParts[strParts.Length - 1].Replace(".chum5", " (" + LanguageManager.Instance.GetString("Title_CreateMode") + ").chum5");
                    if (strNewName == string.Empty)
                    {
                        strNewName = _objCharacter.Alias;
                        if (strNewName == string.Empty)
                            strNewName = _objCharacter.Name;
                        if (strNewName == string.Empty)
                            strNewName = Guid.NewGuid().ToString().Substring(0, 13).Replace("-", string.Empty);
                        strNewName += " (" + LanguageManager.Instance.GetString("Title_CreateMode") + ").chum5";
                    }

                    strNewName = Path.Combine(Environment.CurrentDirectory, "saves", "backup", strNewName);

                    _objCharacter.FileName = strNewName;
                    _objCharacter.Save();
                    _objCharacter.FileName = strFileName;
                }

                // See if the character has any Karma remaining.
                if (intBuildPoints > _objOptions.KarmaCarryover)
                {
                    if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
                    {
                        if (MessageBox.Show(LanguageManager.Instance.GetString("Message_NoExtraKarma").Replace("{0}", intBuildPoints.ToString()), LanguageManager.Instance.GetString("MessageTitle_ExtraKarma"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
开发者ID:cormanater,项目名称:chummer5a,代码行数:67,代码来源:frmCreate.cs

示例5: mnuSpecialCyberzombie_Click

        private void mnuSpecialCyberzombie_Click(object sender, EventArgs e)
        {
            bool blnEssence = true;
            bool blnCyberware = false;
            string strMessage = LanguageManager.Instance.GetString("Message_CyberzombieRequirements");

            // Make sure the character has an Essence lower than 0.
            if (_objCharacter.Essence >= 0)
            {
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsEssence");
                blnEssence = false;
            }

            // Make sure the character has an Invoked Memory Stimulator.
            foreach (Cyberware objCyberware in _objCharacter.Cyberware)
            {
                if (objCyberware.Name == "Invoked Memory Stimulator")
                    blnCyberware = true;
            }

            if (!blnCyberware)
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsStimulator");

            if (!blnEssence || !blnCyberware)
            {
                MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_CyberzombieRequirements"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberzombieConfirm"), LanguageManager.Instance.GetString("MessageTitle_CyberzombieConfirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                return;

            // Convert the character.
            // Characters lose access to Resonance.
            _objCharacter.RESEnabled = false;

            // Gain MAG that is permanently set to 1.
            _objCharacter.MAGEnabled = true;
            _objCharacter.MAG.MetatypeMinimum = 1;
            _objCharacter.MAG.MetatypeMaximum = 1;
            _objCharacter.MAG.Value = 1;

            // Add the Cyberzombie Lifestyle if it is not already taken.
            bool blnHasLifestyle = false;
            foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
            {
                if (objLifestyle.Name == "Cyberzombie Lifestyle Addition")
                    blnHasLifestyle = true;
            }
            if (!blnHasLifestyle)
            {
                XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");
                XmlNode objXmlLifestyle = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"Cyberzombie Lifestyle Addition\"]");

                TreeNode objLifestyleNode = new TreeNode();
                Lifestyle objLifestyle = new Lifestyle(_objCharacter);
                objLifestyle.Create(objXmlLifestyle, objLifestyleNode);
                _objCharacter.Lifestyles.Add(objLifestyle);

                treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
                treLifestyles.Nodes[0].Expand();
            }

            // Change the MetatypeCategory to Cyberzombie.
            _objCharacter.MetatypeCategory = "Cyberzombie";

            // Gain access to Critter Powers.
            _objCharacter.CritterEnabled = true;

            // Gain the Dual Natured Critter Power if it does not yet exist.
            bool blnHasPower = false;
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                if (objPower.Name == "Dual Natured")
                    blnHasPower = true;
            }
            if (!blnHasPower)
            {
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
                XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"Dual Natured\"]");

                TreeNode objNode = new TreeNode();
                CritterPower objCritterPower = new CritterPower(_objCharacter);
                objCritterPower.Create(objXmlPowerNode, _objCharacter, objNode);
                _objCharacter.CritterPowers.Add(objCritterPower);

                treCritterPowers.Nodes[0].Nodes.Add(objNode);
                treCritterPowers.Nodes[0].Expand();
            }

            // Gain the Immunity (Normal Weapons) Critter Power if it does not yet exist.
            blnHasPower = false;
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                if (objPower.Name == "Immunity" && objPower.Extra == "Normal Weapons")
                    blnHasPower = true;
            }
            if (!blnHasPower)
            {
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs


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