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


C# Weapon.CalculatedAmmo方法代码示例

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


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

示例1: RefreshSelectedVehicle


//.........这里部分代码省略.........

							DisplayVehicleWeaponStats(false);
							DisplayVehicleCommlinkStats(true);
							
							if (_objCharacter.Metatype == "A.I.")
							{
								chkVehicleHomeNode.Visible = true;
								chkVehicleHomeNode.Checked = objCommlink.HomeNode;
							}
						}
                    }
                    else
                    {
                        // Look for the selected Vehicle Weapon.
                        Weapon objWeapon = new Weapon(_objCharacter);

                        foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                        {
                            objWeapon = _objFunctions.FindWeapon(treVehicles.SelectedNode.Tag.ToString(), objVehicle.Weapons);
                            if (objWeapon != null)
                                break;
                        }

                        nudVehicleRating.Enabled = false;
						
						DisplayVehicleWeaponStats(true);
						DisplayVehicleCommlinkStats(false);
						DisplayVehicleStats(false);

						lblVehicleWeaponName.Text = objWeapon.DisplayNameShort;
                        lblVehicleWeaponCategory.Text = objWeapon.DisplayCategory;
                        lblVehicleWeaponDamage.Text = objWeapon.CalculatedDamage();
                        lblVehicleWeaponAP.Text = objWeapon.TotalAP;
                        lblVehicleWeaponAmmo.Text = objWeapon.CalculatedAmmo();
                        lblVehicleWeaponMode.Text = objWeapon.CalculatedMode;

                        lblVehicleWeaponRangeShort.Text = objWeapon.RangeShort;
                        lblVehicleWeaponRangeMedium.Text = objWeapon.RangeMedium;
                        lblVehicleWeaponRangeLong.Text = objWeapon.RangeLong;
                        lblVehicleWeaponRangeExtreme.Text = objWeapon.RangeExtreme;

                        lblVehicleName.Text = objWeapon.DisplayNameShort;
                        lblVehicleCategory.Text = LanguageManager.Instance.GetString("String_VehicleWeapon");
                        lblVehicleAvail.Text = objWeapon.TotalAvail;
                        lblVehicleCost.Text = String.Format("{0:###,###,##0¥}", objWeapon.TotalCost);
						lblVehicleSlots.Text = "6 (" + objWeapon.SlotsRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
                        string strBook = _objOptions.LanguageBookShort(objWeapon.Source);
                        string strPage = objWeapon.Page;
                        lblVehicleSource.Text = strBook + " " + strPage;
                        _blnSkipRefresh = true;
                        chkVehicleBlackMarketDiscount.Checked = objWeapon.DiscountCost;
                        _blnSkipRefresh = false;
                        tipTooltip.SetToolTip(lblVehicleSource, _objOptions.LanguageBookLong(objWeapon.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objWeapon.Page);
                    }
                }
                if (blnVehicleMod)
                {
                    chkVehicleWeaponAccessoryInstalled.Enabled = true;
                    chkVehicleWeaponAccessoryInstalled.Checked = objMod.Installed;
                }
                else
                    chkVehicleWeaponAccessoryInstalled.Enabled = false;
                chkVehicleIncludedInWeapon.Checked = false;
            }
            else if (treVehicles.SelectedNode.Level == 3)
            {
开发者ID:cormanater,项目名称:chummer5a,代码行数:67,代码来源:frmCreate.cs

示例2: lstWeapon_SelectedIndexChanged

        private void lstWeapon_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstWeapon.Text == "")
                return;

            // Retireve the information for the selected Weapon.
            XmlNode objXmlWeapon = _objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + lstWeapon.SelectedValue + "\"]");

            Weapon objWeapon = new Weapon(_objCharacter);
            TreeNode objNode = new TreeNode();
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, null, null, null);

            lblWeaponReach.Text = objWeapon.TotalReach.ToString();
            lblWeaponDamage.Text = objWeapon.CalculatedDamage();
            lblWeaponAP.Text = objWeapon.TotalAP;
            lblWeaponMode.Text = objWeapon.CalculatedMode;
            lblWeaponRC.Text = objWeapon.TotalRC;
            lblWeaponAmmo.Text = objWeapon.CalculatedAmmo();
            lblWeaponAccuracy.Text = objWeapon.TotalAccuracy.ToString();
            lblWeaponAvail.Text = objWeapon.TotalAvail;

            int intItemCost = 0;
            double dblCost = 0;
            try
            {
                dblCost = Convert.ToDouble(objXmlWeapon["cost"].InnerText, GlobalOptions.Instance.CultureInfo);
            }
            catch { }
            dblCost *= 1 + (Convert.ToDouble(nudMarkup.Value, GlobalOptions.Instance.CultureInfo) / 100.0);
            lblWeaponCost.Text = String.Format("{0:###,###,##0¥}", dblCost);
            try
            {
                intItemCost = Convert.ToInt32(dblCost);
            }
            catch
            {
            }

            if (chkFreeItem.Checked)
            {
                lblWeaponCost.Text = String.Format("{0:###,###,##0¥}", 0);
                intItemCost = 0;
            }

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

            string strBook = _objCharacter.Options.LanguageBookShort(objXmlWeapon["source"].InnerText);
            string strPage = objXmlWeapon["page"].InnerText;
            if (objXmlWeapon["altpage"] != null)
                strPage = objXmlWeapon["altpage"].InnerText;
            lblSource.Text = strBook + " " + strPage;

            // Build a list of included Accessories and Modifications that come with the weapon.
            string strAccessories = "";
            XmlNodeList objXmlNodeList = objXmlWeapon.SelectNodes("accessories/accessory");
            foreach (XmlNode objXmlAccessory in objXmlNodeList)
            {
                XmlNode objXmlItem = _objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + objXmlAccessory.InnerText + "\"]");
                if (objXmlItem["translate"] != null)
                    strAccessories += objXmlItem["translate"].InnerText + "\n";
                else
                    strAccessories += objXmlItem["name"].InnerText + "\n";
            }
            objXmlNodeList = objXmlWeapon.SelectNodes("mods/mod");
            foreach (XmlNode objXmlMod in objXmlNodeList)
            {
                XmlNode objXmlItem = _objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod.InnerText + "\"]");
                if (objXmlItem["translate"] != null)
                    strAccessories += objXmlItem["translate"].InnerText + "\n";
                else
                    strAccessories += objXmlItem["name"].InnerText + "\n";
            }
            if (strAccessories == "")
                lblIncludedAccessories.Text = LanguageManager.Instance.GetString("String_None");
            else
                lblIncludedAccessories.Text = strAccessories;

            tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objXmlWeapon["source"].InnerText) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage);
        }
开发者ID:Nitsuj83,项目名称:chummer5a,代码行数:79,代码来源:frmSelectWeapon.cs

示例3: cmdReloadWeapon_Click

        private void cmdReloadWeapon_Click(object sender, EventArgs e)
        {
            List<Gear> lstAmmo = new List<Gear>();
            List<string> lstCount = new List<string>();
            bool blnExternalSource = false;

            Gear objExternalSource = new Gear(_objCharacter);
            objExternalSource.Name = "External Source";

            // Locate the selected Weapon.
            Weapon objWeapon = new Weapon(_objCharacter);
            foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
            {
                if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                {
                    objWeapon = objCharacterWeapon;
                    break;
                }
                if (objCharacterWeapon.UnderbarrelWeapons.Count > 0)
                {
                    foreach (Weapon objUnderbarrelWeapon in objCharacterWeapon.UnderbarrelWeapons)
                    {
                        if (objUnderbarrelWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                        {
                            objWeapon = objUnderbarrelWeapon;
                            break;
                        }
                    }
                }
            }

            // Determine which loading methods are available to the Weapon.
            if (objWeapon.CalculatedAmmo(true).Contains(" or ") || objWeapon.CalculatedAmmo(true).Contains("x") || objWeapon.CalculatedAmmo(true).Contains("Special") || objWeapon.CalculatedAmmo(true).Contains("+"))
            {
                string strWeaponAmmo = objWeapon.CalculatedAmmo(true).ToLower();
                if (strWeaponAmmo.Contains("external source"))
                    blnExternalSource = true;
                // Get rid of external source, special, or belt, and + energy.
                strWeaponAmmo = strWeaponAmmo.Replace("external source", "100");
                strWeaponAmmo = strWeaponAmmo.Replace("special", "100");
                strWeaponAmmo = strWeaponAmmo.Replace(" + energy", "");
                strWeaponAmmo = strWeaponAmmo.Replace(" or belt", " or 250(belt)");

                string[] strSplit = new string[] { " or " };
                string[] strAmmos = strWeaponAmmo.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);

                foreach (string strAmmo in strAmmos)
                {
                    string strThisAmmo = strAmmo;
                    if (strThisAmmo.StartsWith("2x") || strThisAmmo.StartsWith("3x") || strThisAmmo.StartsWith("4x"))
                        strThisAmmo = strThisAmmo.Substring(2, strThisAmmo.Length - 2);
                    if (strThisAmmo.EndsWith("x2") || strThisAmmo.EndsWith("x3") || strThisAmmo.EndsWith("x4"))
                        strThisAmmo = strThisAmmo.Substring(0, strThisAmmo.Length - 2);

                    if (strThisAmmo.Contains("("))
                        strThisAmmo = strThisAmmo.Substring(0, strThisAmmo.IndexOf("("));

                    lstCount.Add(strThisAmmo);
                }
            }
            else
            {
                // Nothing weird in the ammo string, so just use the number given.
                string strAmmo = objWeapon.CalculatedAmmo(true);
                if (strAmmo.Contains("("))
                    strAmmo = strAmmo.Substring(0, strAmmo.IndexOf("("));
                lstCount.Add(strAmmo);
            }

            // Find all of the Ammo for the current Weapon that the character is carrying.
            if (objWeapon.AmmoCategory != "Grenade Launchers" && objWeapon.AmmoCategory != "Missile Launchers" && objWeapon.AmmoCategory != "Mortar Launchers")
            {
                // This is a standard Weapon, so consume traditional Ammunition.
                foreach (Gear objAmmo in _objCharacter.Gear)
                {
                    if (objAmmo.Quantity > 0)
                    {
                        if (objAmmo.Category == "Ammunition" && objAmmo.Extra == objWeapon.AmmoCategory)
                            lstAmmo.Add(objAmmo);
                    }
                    foreach (Gear objChild in objAmmo.Children)
                    {
                        if (objChild.Quantity > 0)
                        {
                            if (objChild.Category == "Ammunition" && objChild.Extra == objWeapon.AmmoCategory)
                                lstAmmo.Add(objChild);
                        }
                    }
                }
            }
            else
            {
                if (objWeapon.AmmoCategory == "Grenade Launchers")
                {
                    // Grenade Launchers can only use Grenades.
                    foreach (Gear objAmmo in _objCharacter.Gear)
                    {
                        if (objAmmo.Quantity > 0)
                        {
                            if (objAmmo.Category == "Ammunition" && objAmmo.Name.StartsWith("Minigrenade:"))
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs

示例4: RefreshSelectedVehicle


//.........这里部分代码省略.........
                            lblVehicleDevice.Text = objCommlink.DeviceRating.ToString();
                            lblVehicleAttack.Text = objCommlink.Attack.ToString();
                            lblVehicleSleaze.Text = objCommlink.Sleaze.ToString();
                            lblVehicleDataProcessing.Text = objCommlink.DataProcessing.ToString();
                            lblVehicleFirewall.Text = objCommlink.Firewall.ToString();
                        }

                        if ((_objCharacter.Metatype.EndsWith("A.I.") || _objCharacter.MetatypeCategory == "Technocritters" || _objCharacter.MetatypeCategory == "Protosapients") && objGear.GetType() == typeof(Commlink))
                        {
                            chkVehicleHomeNode.Visible = true;
                            chkVehicleHomeNode.Checked = objGear.HomeNode;
                        }
                    }
                    else
                    {
                        // Look for the selected Vehicle Weapon.
                        Weapon objWeapon = new Weapon(_objCharacter);
                        Vehicle objCurrentVehicle = new Vehicle(_objCharacter);

                        foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                        {
                            objWeapon = _objFunctions.FindWeapon(treVehicles.SelectedNode.Tag.ToString(), objVehicle.Weapons);
                            if (objWeapon != null)
                            {
                                objCurrentVehicle = objVehicle;
                                break;
                            }
                        }

                        lblVehicleWeaponName.Text = objWeapon.DisplayNameShort;
                        lblVehicleWeaponCategory.Text = objWeapon.DisplayCategory;
                        lblVehicleWeaponDamage.Text = objWeapon.CalculatedDamage();
                        lblVehicleWeaponAP.Text = objWeapon.TotalAP;
                        lblVehicleWeaponAmmo.Text = objWeapon.CalculatedAmmo();
                        lblVehicleWeaponMode.Text = objWeapon.CalculatedMode;
                        if (objWeapon.WeaponType == "Ranged" || (objWeapon.WeaponType == "Melee" && objWeapon.Ammo != "0"))
                        {
                            cmdFireVehicleWeapon.Enabled = true;
                            cmdReloadVehicleWeapon.Enabled = true;
                            lblVehicleWeaponAmmoRemaining.Text = objWeapon.AmmoRemaining.ToString();

                            cmsVehicleAmmoSingleShot.Enabled = objWeapon.AllowMode("SS") || objWeapon.AllowMode("SA");
                            cmsVehicleAmmoShortBurst.Enabled = objWeapon.AllowMode("BF");
                            cmsVehicleAmmoLongBurst.Enabled = objWeapon.AllowMode("FA");
                            cmsVehicleAmmoFullBurst.Enabled = objWeapon.AllowMode("FA");
                            cmsVehicleAmmoSuppressiveFire.Enabled = objWeapon.AllowMode("FA");

                            // Melee Weapons with Ammo are considered to be Single Shot.
                            if (objWeapon.WeaponType == "Melee" && objWeapon.Ammo != "0")
                                cmsVehicleAmmoSingleShot.Enabled = true;

                            if (cmsVehicleAmmoFullBurst.Enabled)
                                cmsVehicleAmmoFullBurst.Text = LanguageManager.Instance.GetString("String_FullBurst").Replace("{0}", objWeapon.FullBurst.ToString());
                            if (cmsVehicleAmmoSuppressiveFire.Enabled)
                                cmsVehicleAmmoSuppressiveFire.Text = LanguageManager.Instance.GetString("String_SuppressiveFire").Replace("{0}", objWeapon.Suppressive.ToString());

                            List<ListItem> lstAmmo = new List<ListItem>();
                            int intCurrentSlot = objWeapon.ActiveAmmoSlot;
                            for (int i = 1; i <= objWeapon.AmmoSlots; i++)
                            {
                                Gear objVehicleGear = new Gear(_objCharacter);
                                ListItem objAmmo = new ListItem();
                                objWeapon.ActiveAmmoSlot = i;
                                objVehicleGear = _objFunctions.FindGear(objWeapon.AmmoLoaded, objCurrentVehicle.Gear);
                                objAmmo.Value = i.ToString();
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:66,代码来源:frmCareer.cs

示例5: RefreshSelectedWeapon


//.........这里部分代码省略.........
                int intUseSTR = 0;
                if (objWeapon.Cyberware)
                {
                    foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                    {
                        foreach (Cyberware objPlugin in objCyberware.Children)
                        {
                            if (objPlugin.WeaponID == objWeapon.InternalId)
                            {
                                intUseSTR = objCyberware.TotalStrength;
                                break;
                            }
                        }
                    }
                }

                // Show the Weapon Ranges.
                lblWeaponRangeShort.Text = objWeapon.RangeShort;
                lblWeaponRangeMedium.Text = objWeapon.RangeMedium;
                lblWeaponRangeLong.Text = objWeapon.RangeLong;
                lblWeaponRangeExtreme.Text = objWeapon.RangeExtreme;

                _blnSkipRefresh = false;

                lblWeaponAvail.Text = objWeapon.TotalAvail;
                lblWeaponCost.Text = String.Format("{0:###,###,##0¥}", objWeapon.TotalCost);
                lblWeaponConceal.Text = objWeapon.CalculatedConcealability();
                lblWeaponDamage.Text = objWeapon.CalculatedDamage(intUseSTR);
                lblWeaponAccuracy.Text = objWeapon.TotalAccuracy.ToString();
                lblWeaponRC.Text = objWeapon.TotalRC;
                lblWeaponAP.Text = objWeapon.TotalAP;
                lblWeaponReach.Text = objWeapon.TotalReach.ToString();
                lblWeaponMode.Text = objWeapon.CalculatedMode;
                lblWeaponAmmo.Text = objWeapon.CalculatedAmmo();
                lblWeaponSlots.Text = "6 (" + objWeapon.SlotsRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
                lblWeaponDicePool.Text = objWeapon.DicePool;
                tipTooltip.SetToolTip(lblWeaponDicePool, objWeapon.DicePoolTooltip);
                tipTooltip.SetToolTip(lblWeaponRC, objWeapon.RCToolTip);

                UpdateCharacterInfo();
            }
            else
            {
                // See if this is an Underbarrel Weapon.
                bool blnUnderbarrel = false;
                Weapon objWeapon = new Weapon(_objCharacter);
                foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
                {
                    if (objCharacterWeapon.UnderbarrelWeapons.Count > 0)
                    {
                        foreach (Weapon objUnderbarrelWeapon in objCharacterWeapon.UnderbarrelWeapons)
                        {
                            if (objUnderbarrelWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                            {
                                objWeapon = objUnderbarrelWeapon;
                                blnUnderbarrel = true;
                                break;
                            }
                        }
                    }
                }

                if (blnUnderbarrel)
                {
                    cmdFireWeapon.Enabled = true;
                    cmdReloadWeapon.Enabled = true;
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:67,代码来源:frmCareer.cs

示例6: TestWeapons

        private void TestWeapons()
        {
            Character objCharacter = new Character();
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
            pgbProgress.Minimum = 0;
            pgbProgress.Value = 0;
            pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/weapons/weapon").Count;
            pgbProgress.Maximum += objXmlDocument.SelectNodes("/chummer/accessories/accessory").Count;
            pgbProgress.Maximum += objXmlDocument.SelectNodes("/chummer/mods/mod").Count;

            // Weapons.
            foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/weapons/weapon"))
            {
                pgbProgress.Value++;
                Application.DoEvents();
                try
                {
                    TreeNode objTempNode = new TreeNode();
                    Weapon objTemp = new Weapon(objCharacter);
                    objTemp.Create(objXmlGear, objCharacter, objTempNode, null, null, null);
                    try
                    {
                        int objValue = objTemp.TotalCost;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n";
                    }
                    try
                    {
                        string objValue = objTemp.TotalAP;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAP\n";
                    }
                    try
                    {
                        string objValue = objTemp.TotalAvail;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n";
                    }
                    try
                    {
                        string objValue = objTemp.TotalRC;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalRC\n";
                    }
                    try
                    {
                        int objValue = objTemp.TotalReach;
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalReach\n";
                    }
                    try
                    {
                        string objValue = objTemp.CalculatedAmmo();
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedAmmo\n";
                    }
                    try
                    {
                        string objValue = objTemp.CalculatedConcealability();
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedConcealability\n";
                    }
                    try
                    {
                        string objValue = objTemp.CalculatedDamage();
                    }
                    catch
                    {
                        txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedDamage\n";
                    }
                }
                catch
                {
                    txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n";
                }
            }

            // Weapon Accessories.
            foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/accessories/accessory"))
            {
                pgbProgress.Value++;
                Application.DoEvents();
                try
                {
                    TreeNode objTempNode = new TreeNode();
                    WeaponAccessory objTemp = new WeaponAccessory(objCharacter);
//.........这里部分代码省略.........
开发者ID:hollis21,项目名称:Chummer,代码行数:101,代码来源:frmTest.cs


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