• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# VehicleMod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VehicleMod的典型用法代码示例。如果您正苦于以下问题:C# VehicleMod类的具体用法?C# VehicleMod怎么用?C# VehicleMod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VehicleMod类属于命名空间,在下文中一共展示了VehicleMod类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: tsVehicleAddWeaponWeapon_Click

        private void tsVehicleAddWeaponWeapon_Click(object sender, EventArgs e)
        {
            VehicleMod objMod = new VehicleMod(_objCharacter);

            // Make sure that a Weapon Mount has been selected.
            try
            {
                // Attempt to locate the selected VehicleMod.
                Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);

                if (!objMod.Name.StartsWith("Weapon Mount") && !objMod.Name.StartsWith("Heavy Weapon Mount") && !objMod.Name.StartsWith("Mechanical Arm"))
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter);
            frmPickWeapon.ShowDialog();

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

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

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
            objWeapon.VehicleMounted = true;

            objMod.Weapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsVehicleWeapon;
            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();

            if (frmPickWeapon.AddAgain)
                tsVehicleAddWeaponWeapon_Click(sender, e);

            UpdateCharacterInfo();
        }
开发者ID:cormanater,项目名称:chummer5a,代码行数:50,代码来源:frmCreate.cs


示例2: cmdDeleteVehicle_Click

        private void cmdDeleteVehicle_Click(object sender, EventArgs e)
        {
            // Delete the selected Vehicle.
            try
            {
                if (treVehicles.SelectedNode.Level == 0)
                    return;
            }
            catch
            {
                return;
            }

            if (treVehicles.SelectedNode.Level != 2)
            {
                if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
                    return;
            }

            if (treVehicles.SelectedNode.Level == 1)
            {
                // Locate the Vehicle that is selected in the tree.
                Vehicle objVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);

                // Remove any Gear Improvements from the character (primarily those provided by an Emotitoy).
                foreach (Gear objGear in objVehicle.Gear)
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);

                _objCharacter.Vehicles.Remove(objVehicle);
                treVehicles.SelectedNode.Remove();
            }
            else if (treVehicles.SelectedNode.Level == 2)
            {
                bool blnFound = false;
                // Locate the VehicleMod that is selected in the tree.
                Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                VehicleMod objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
                if (objMod != null)
                {
                    blnFound = true;

                    if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
                        return;

                    // Check for Improved Sensor bonus.
                    if (objMod.Bonus != null)
                    {
                        if (objMod.Bonus["improvesensor"] != null)
                        {
                            ChangeVehicleSensor(objFoundVehicle, false);
                        }
                    }

                    // If this is the Obsolete Mod, the user must select a percentage. This will create an Expense that costs X% of the Vehicle's base cost to remove the special Obsolete Mod.
                    if (objMod.Name == "Obsolete" || (objMod.Name == "Obsolescent" && _objOptions.AllowObsolescentUpgrade))
                    {
                        frmSelectNumber frmModPercent = new frmSelectNumber();
                        frmModPercent.Minimum = 0;
                        frmModPercent.Maximum = 1000;
                        frmModPercent.Description = LanguageManager.Instance.GetString("String_Retrofit");
                        frmModPercent.ShowDialog(this);

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

                        int intPercentage = frmModPercent.SelectedValue;
                        int intVehicleCost = Convert.ToInt32(objFoundVehicle.Cost);

                        // Make sure the character has enough Nuyen for the expense.
                        int intCost = Convert.ToInt32(Convert.ToDouble(intVehicleCost, GlobalOptions.Instance.CultureInfo) * (Convert.ToDouble(intPercentage, GlobalOptions.Instance.CultureInfo) / 100.0), GlobalOptions.Instance.CultureInfo);
                        VehicleMod objRetrofit = new VehicleMod(_objCharacter);

                        XmlDocument objVehiclesDoc = XmlManager.Instance.Load("vehicles.xml");
                        XmlNode objXmlNode = objVehiclesDoc.SelectSingleNode("/chummer/mods/mod[name = \"Retrofit\"]");
                        TreeNode objTreeNode = new TreeNode();
                        objRetrofit.Create(objXmlNode, objTreeNode, 0);
                        objRetrofit.Cost = intCost.ToString();
                        objFoundVehicle.Mods.Add(objRetrofit);
                        treVehicles.SelectedNode.Parent.Nodes.Add(objTreeNode);
                    }

                    objFoundVehicle.Mods.Remove(objMod);
                    treVehicles.SelectedNode.Remove();
                }

                if (!blnFound)
                {
                    // Locate the Sensor or Ammunition that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (Gear objGear in objCharacterVehicle.Gear)
                        {
                            if (objGear.InternalId == treVehicles.SelectedNode.Tag.ToString())
                            {
                                if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
                                    return;

                                // Remove the Gear Weapon created by the Gear if applicable.
                                if (objGear.WeaponID != Guid.Empty.ToString())
                                {
//.........这里部分代码省略.........
开发者ID:cormanater,项目名称:chummer5a,代码行数:101,代码来源:frmCreate.cs


示例3: tsVehicleAddMod_Click

        private void tsVehicleAddMod_Click(object sender, EventArgs e)
        {
            // Make sure a parent items is selected, then open the Select Vehicle Mod window.
            try
            {
                if (treVehicles.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (treVehicles.SelectedNode.Level > 1)
                treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;

            Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);

            frmSelectVehicleMod frmPickVehicleMod = new frmSelectVehicleMod(_objCharacter);
            // Set the Vehicle properties for the window.
            frmPickVehicleMod.VehicleCost = Convert.ToInt32(objSelectedVehicle.Cost);
            frmPickVehicleMod.Body = objSelectedVehicle.TotalBody;
			frmPickVehicleMod.Seats = objSelectedVehicle.Seats;
			frmPickVehicleMod.Handling = objSelectedVehicle.Handling;
			frmPickVehicleMod.Speed = objSelectedVehicle.Speed;
            frmPickVehicleMod.Accel = objSelectedVehicle.Accel;
            frmPickVehicleMod.DeviceRating = objSelectedVehicle.DeviceRating;
            frmPickVehicleMod.HasModularElectronics = objSelectedVehicle.HasModularElectronics();

            frmPickVehicleMod.ShowDialog(this);

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

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

            XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + frmPickVehicleMod.SelectedMod + "\"]");

            TreeNode objNode = new TreeNode();
            VehicleMod objMod = new VehicleMod(_objCharacter);
            objMod.Create(objXmlMod, objNode, frmPickVehicleMod.SelectedRating);

            // Make sure that the Armor Rating does not exceed the maximum allowed by the Vehicle.
            if (objMod.Name.StartsWith("Armor"))
            {
                if (objMod.Rating > objSelectedVehicle.MaxArmor)
                {
                    objMod.Rating = objSelectedVehicle.MaxArmor;
                    objNode.Text = objMod.DisplayName;
                }
            }

            objSelectedVehicle.Mods.Add(objMod);

            objNode.ContextMenuStrip = cmsVehicle;
            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();
            RefreshSelectedVehicle();

            // Check for Improved Sensor bonus.
            if (objMod.Bonus != null)
            {
                if (objMod.Bonus["selecttext"] != null)
                {
                    frmSelectText frmPickText = new frmSelectText();
                    frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText").Replace("{0}", objMod.DisplayNameShort);
                    frmPickText.ShowDialog(this);
                    objMod.Extra = frmPickText.SelectedValue;
                    objNode.Text = objMod.DisplayName;
                }
                if (objMod.Bonus["improvesensor"] != null)
                {
                    ChangeVehicleSensor(objSelectedVehicle, true);
                }
            }

            _blnIsDirty = true;
            UpdateWindowTitle();

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


示例4: RefreshPasteStatus


//.........这里部分代码省略.........
                if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem)
                {
                    // Gear can only be pasted into Vehicles and Vehicle Gear.
                    try
                    {
                        foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                        {
                            if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                            {
                                blnPasteEnabled = true;
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        Vehicle objVehicle = new Vehicle(_objCharacter);
                        Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
                        if (objGear != null)
                            blnPasteEnabled = true;
                    }
                    catch
                    {
                    }
                }
                if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon)
                {
                    // Weapons can only be pasted into Vehicle Mods that allow them (Weapon Mounts and Mechanical Arms).
                    try
                    {
                        VehicleMod objMod = new VehicleMod(_objCharacter);
                        foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                        {
                            foreach (VehicleMod objVehicleMod in objVehicle.Mods)
                            {
                                if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
                                    {
                                        blnPasteEnabled = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                try
                {
                    foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                    {
                        if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            blnCopyEnabled = true;
                            break;
                        }
                    }
                }
                catch
开发者ID:cormanater,项目名称:chummer5a,代码行数:67,代码来源:frmCreate.cs


示例5: mnuEditPaste_Click


//.........这里部分代码省略.........
                    switch (objXmlNode["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(objXmlNode, true);
                            objGear = objCommlink;
                            break;
                        default:
                            Gear objNewGear = new Gear(_objCharacter);
                            objNewGear.Load(objXmlNode, true);
                            objGear = objNewGear;
                            break;
                    }

                    // Paste the Gear into a Vehicle.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objCharacterVehicle.Gear.Add(objGear);
                            TreeNode objNode = new TreeNode();
                            objNode.Text = objGear.DisplayName;
                            objNode.Tag = objGear.InternalId;
                            objNode.ContextMenuStrip = cmsVehicleGear;
                            objVehicle = objCharacterVehicle;

                            _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);

                            treVehicles.SelectedNode.Nodes.Add(objNode);
                            treVehicles.SelectedNode.Expand();
                        }
                    }

                    // Paste the Gear into a Vehicle's Gear.
                    Vehicle objTempVehicle = objVehicle;
                    Gear objVehicleGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
                    if (objVehicle == null)
                        objVehicle = objTempVehicle;
                    if (objVehicleGear != null)
                    {
                        objVehicleGear.Children.Add(objGear);
                        objGear.Parent = objVehicleGear;
                        TreeNode objNode = new TreeNode();
                        objNode.Text = objGear.DisplayName;
                        objNode.Tag = objGear.InternalId;
                        objNode.ContextMenuStrip = cmsVehicleGear;

                        _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);

                        treVehicles.SelectedNode.Nodes.Add(objNode);
                        treVehicles.SelectedNode.Expand();
                    }

                    UpdateCharacterInfo();
                    _blnIsDirty = true;
                    UpdateWindowTitle();
                    return;
                }

                // Paste Weapon.
                Weapon objWeapon = new Weapon(_objCharacter);
                objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                if (objXmlNode != null)
                {
                    objWeapon.Load(objXmlNode, true);
                    objWeapon.VehicleMounted = true;

                    try
                    {
                        // Weapons can only be added to Vehicle Mods that support them (Weapon Mounts and Mechanical Arms).
                        VehicleMod objMod = new VehicleMod(_objCharacter);
                        foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                        {
                            foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
                            {
                                if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
                                    {
                                        objVehicleMod.Weapons.Add(objWeapon);

                                        _objFunctions.CreateWeaponTreeNode(objWeapon, treVehicles.SelectedNode, cmsVehicleWeapon, cmsVehicleWeaponMod, cmsVehicleWeaponAccessory, null);

                                        UpdateCharacterInfo();
                                        _blnIsDirty = true;
                                        UpdateWindowTitle();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
开发者ID:cormanater,项目名称:chummer5a,代码行数:101,代码来源:frmCreate.cs


示例6: tsVehicleNotes_Click

        private void tsVehicleNotes_Click(object sender, EventArgs e)
        {
            Vehicle objVehicle = new Vehicle(_objCharacter);
            VehicleMod objMod = new VehicleMod(_objCharacter);
            bool blnFoundVehicle = false;
            bool blnFoundMod = false;
            try
            {
                foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                {
                    if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                    {
                        objVehicle = objCharacterVehicle;
                        blnFoundVehicle = true;
                        break;
                    }
                    foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
                    {
                        if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objMod = objVehicleMod;
                            blnFoundMod = true;
                            break;
                        }
                    }
                }

                if (blnFoundVehicle)
                {
                    frmNotes frmItemNotes = new frmNotes();
                    frmItemNotes.Notes = objVehicle.Notes;
                    string strOldValue = objVehicle.Notes;
                    frmItemNotes.ShowDialog(this);

                    if (frmItemNotes.DialogResult == DialogResult.OK)
                    {
                        objVehicle.Notes = frmItemNotes.Notes;
                        if (objVehicle.Notes != strOldValue)
                        {
                            _blnIsDirty = true;
                            UpdateWindowTitle();
                        }
                    }

                    if (objVehicle.Notes != string.Empty)
                        treVehicles.SelectedNode.ForeColor = Color.SaddleBrown;
                    else
                        treVehicles.SelectedNode.ForeColor = SystemColors.WindowText;
                    treVehicles.SelectedNode.ToolTipText = CommonFunctions.WordWrap(objVehicle.Notes, 100);
                }
                if (blnFoundMod)
                {
                    frmNotes frmItemNotes = new frmNotes();
                    frmItemNotes.Notes = objMod.Notes;
                    string strOldValue = objMod.Notes;
                    frmItemNotes.ShowDialog(this);

                    if (frmItemNotes.DialogResult == DialogResult.OK)
                    {
                        objMod.Notes = frmItemNotes.Notes;
                        if (objMod.Notes != strOldValue)
                        {
                            _blnIsDirty = true;
                            UpdateWindowTitle();
                        }
                    }

                    if (objMod.Notes != string.Empty)
                        treVehicles.SelectedNode.ForeColor = Color.SaddleBrown;
                    else
                    {
                        if (objMod.IncludedInVehicle)
                            treVehicles.SelectedNode.ForeColor = SystemColors.GrayText;
                        else
                            treVehicles.SelectedNode.ForeColor = SystemColors.WindowText;
                    }
                    treVehicles.SelectedNode.ToolTipText = CommonFunctions.WordWrap(objMod.Notes, 100);
                }
            }
            catch
            {
            }
        }
开发者ID:cormanater,项目名称:chummer5a,代码行数:83,代码来源:frmCreate.cs


示例7: AddPACKSKit


//.........这里部分代码省略.........
                int i = 0;

                foreach (XmlNode objXmlVehicle in objXmlKit.SelectNodes("vehicles/vehicle"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    Gear objDefaultSensor = new Gear(_objCharacter);

                    TreeNode objNode = new TreeNode();
                    Vehicle objVehicle = new Vehicle(_objCharacter);

                    XmlNode objXmlVehicleNode = objXmlVehicleDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + objXmlVehicle["name"].InnerText + "\"]");
                    objVehicle.Create(objXmlVehicleNode, objNode, cmsVehicle, cmsVehicleGear, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod, blnCreateChildren);
                    _objCharacter.Vehicles.Add(objVehicle);

                    // Grab the default Sensor that comes with the Vehicle.
                    foreach (Gear objSensorGear in objVehicle.Gear)
                    {
                        if (objSensorGear.Category == "Sensors" && objSensorGear.Cost == "0" && objSensorGear.Rating == 0)
                        {
                            objDefaultSensor = objSensorGear;
                            break;
                        }
                    }

                    // Add any Vehicle Mods.
                    if (objXmlVehicle["mods"] != null)
                    {
                        foreach (XmlNode objXmlMod in objXmlVehicle.SelectNodes("mods/mod"))
                        {
                            TreeNode objModNode = new TreeNode();
                            VehicleMod objMod = new VehicleMod(_objCharacter);

                            int intRating = 0;
                            if (objXmlMod["rating"] != null)
                                intRating = Convert.ToInt32(objXmlMod["rating"].InnerText);

                            XmlNode objXmlModNode = objXmlVehicleDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
                            objMod.Create(objXmlModNode, objModNode, intRating);
                            objVehicle.Mods.Add(objMod);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();
                        }
                    }

                    // Add any Vehicle Gear.
                    if (objXmlVehicle["gears"] != null)
                    {
                        XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");

                        foreach (XmlNode objXmlGear in objXmlVehicle.SelectNodes("gears/gear"))
                        {
                            List<Weapon> objWeapons = new List<Weapon>();
                            List<TreeNode> objWeaponNodes = new List<TreeNode>();
                            TreeNode objGearNode = new TreeNode();
                            Gear objGear = new Gear(_objCharacter);
                            int intQty = 1;

                            int intRating = 0;
                            if (objXmlGear["rating"] != null)
                                intRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
                            string strForceValue = "";
                            if (objXmlGear["name"].Attributes["select"] != null)
开发者ID:cormanater,项目名称:chummer5a,代码行数:67,代码来源:frmCreate.cs


示例8: cmdVehicleMoveToInventory_Click

        private void cmdVehicleMoveToInventory_Click(object sender, EventArgs e)
        {
            // Locate the selected Weapon.
            bool blnFound = false;
            Weapon objWeapon = new Weapon(_objCharacter);
            Vehicle objVehicle = new Vehicle(_objCharacter);
            VehicleMod objMod = new VehicleMod(_objCharacter);

            foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
            {
                foreach (Weapon objVehicleWeapon in objCharacterVehicle.Weapons)
                {
                    if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                    {
                        objWeapon = objVehicleWeapon;
                        objVehicle = objCharacterVehicle;
                        blnFound = true;
                        break;
                    }
                }
                foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
                {
                    foreach (Weapon objVehicleWeapon in objVehicleMod.Weapons)
                    {
                        if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objWeapon = objVehicleWeapon;
                            objVehicle = objCharacterVehicle;
                            objMod = objVehicleMod;
                            blnFound = true;
                            break;
                        }
                    }
                }
            }

            if (blnFound){
                // Move the Weapons from the Vehicle Mod (or Vehicle) to the character.
                if (objMod.InternalId != Guid.Empty.ToString())
                    objMod.Weapons.Remove(objWeapon);
                else
                    objVehicle.Weapons.Remove(objWeapon);

                _objCharacter.Weapons.Add(objWeapon);

                TreeNode objNode = new TreeNode();
                objNode = treVehicles.SelectedNode;

                treVehicles.SelectedNode.Remove();
                treWeapons.Nodes[0].Nodes.Add(objNode);
                objWeapon.VehicleMounted = false;
                objNode.Expand();
            }
            else
            {
                // Locate the selected Gear.
                Vehicle objSelectedVehicle = new Vehicle(_objCharacter);
                Gear objSelectedGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objSelectedVehicle);

                int intMove = 0;
                if (objSelectedGear.Quantity == 1)
                    intMove = 1;
                else
                {
                    frmSelectNumber frmPickNumber = new frmSelectNumber();
                    frmPickNumber.Minimum = 1;
                    frmPickNumber.Maximum = objSelectedGear.Quantity;
                    frmPickNumber.Description = LanguageManager.Instance.GetString("String_MoveGear");
                    frmPickNumber.ShowDialog(this);

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

                    intMove = frmPickNumber.SelectedValue;
                }

                // See if the character already has a matching piece of Gear.
                bool blnMatch = false;
                Gear objFoundGear = new Gear(_objCharacter);
                foreach (Gear objCharacterGear in _objCharacter.Gear)
                {
                    if (objCharacterGear.Name == objSelectedGear.Name && objCharacterGear.Category == objSelectedGear.Category && objCharacterGear.Rating == objSelectedGear.Rating && objCharacterGear.Extra == objSelectedGear.Extra && objCharacterGear.GearName == objSelectedGear.GearName && objCharacterGear.Notes == objSelectedGear.Notes)
                    {
                        blnMatch = true;
                        objFoundGear = objCharacterGear;
                        if (objCharacterGear.Children.Count == objSelectedGear.Children.Count)
                        {
                            for (int i = 0; i <= objCharacterGear.Children.Count - 1; i++)
                            {
                                if (objCharacterGear.Children[i].Name != objSelectedGear.Children[i].Name || objCharacterGear.Children[i].Extra != objSelectedGear.Children[i].Extra || objCharacterGear.Children[i].Rating != objSelectedGear.Children[i].Rating)
                                {
                                    blnMatch = false;
                                    break;
                                }
                            }
                        }
                        else
                            blnMatch = false;
                    }
                }
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs


示例9: cmdWeaponMoveToVehicle_Click

        private void cmdWeaponMoveToVehicle_Click(object sender, EventArgs e)
        {
            // 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;
                }
            }

            List<Vehicle> lstVehicles = new List<Vehicle>();
            foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
            {
                foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
                {
                    // Only add a Vehicle to the list if it has a Weapon Mount or Mechanical Arm.
                    if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
                    {
                        lstVehicles.Add(objCharacterVehicle);
                        break;
                    }
                }
            }

            // Cannot continue if there are no Vehicles with a Weapon Mount or Mechanical Arm.
            if (lstVehicles.Count == 0)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotMoveWeapons"), LanguageManager.Instance.GetString("MessageTitle_CannotMoveWeapons"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectItem frmPickItem = new frmSelectItem();
            frmPickItem.Vehicles = lstVehicles;
            frmPickItem.ShowDialog(this);

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

            // Locate the selected Vehicle.
            Vehicle objVehicle = new Vehicle(_objCharacter);
            foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
            {
                if (objCharacterVehicle.InternalId == frmPickItem.SelectedItem)
                {
                    objVehicle = objCharacterVehicle;
                    break;
                }
            }

            // Now display a list of the acceptable mounting points for the Weapon.
            List<VehicleMod> lstMods = new List<VehicleMod>();
            foreach (VehicleMod objVehicleMod in objVehicle.Mods)
            {
                if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm"))
                    lstMods.Add(objVehicleMod);
            }

            frmPickItem.VehicleMods = lstMods;
            frmPickItem.ShowDialog(this);

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

            // Locate the selected Vehicle Mod.
            VehicleMod objMod = new VehicleMod(_objCharacter);
            foreach (VehicleMod objCharacterMod in objVehicle.Mods)
            {
                if (objCharacterMod.InternalId == frmPickItem.SelectedItem)
                {
                    objMod = objCharacterMod;
                    break;
                }
            }

            // Remove the Weapon from the character and add it to the Vehicle Mod.
            _objCharacter.Weapons.Remove(objWeapon);
            objMod.Weapons.Add(objWeapon);
            objWeapon.VehicleMounted = true;
            objWeapon.Location = string.Empty;

            // Move the TreeNode to the Vehicle Mod.
            TreeNode objNode = new TreeNode();
            objNode = treWeapons.SelectedNode;
            treWeapons.SelectedNode.Remove();

            foreach (TreeNode objVehicleNode in treVehicles.Nodes[0].Nodes)
            {
                foreach (TreeNode objModNode in objVehicleNode.Nodes)
                {
                    if (objModNode.Tag.ToString() == objMod.InternalId)
                    {
                        objModNode.Nodes.Add(objNode);
                        objModNode.Expand();
                        objNode.Expand();
                        break;
                    }
                }
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs


示例10: tsVehicleAddWeaponWeapon_Click

        private void tsVehicleAddWeaponWeapon_Click(object sender, EventArgs e)
        {
            VehicleMod objMod = new VehicleMod(_objCharacter);

            // Make sure that a Weapon Mount has been selected.
            try
            {
                // Attempt to locate the selected VehicleMod.
                Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);

                if (!objMod.Name.StartsWith("Weapon Mount") && !objMod.Name.StartsWith("Heavy Weapon Mount") && !objMod.Name.StartsWith("Mechanical Arm"))
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter, true);
            frmPickWeapon.ShowDialog();

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

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

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
            objWeapon.VehicleMounted = true;

            int intCost = objWeapon.TotalCost;
            // Apply a markup if applicable.
            if (frmPickWeapon.Markup != 0)
            {
                double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(frmPickWeapon.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
                intCost = Convert.ToInt32(dblCost);
            }

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

            if (!frmPickWeapon.FreeCost)
            {
                // Check the item's Cost and make sure the character can afford it.
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (frmPickWeapon.AddAgain)
                        tsVehicleAddWeaponWeapon_Click(sender, e);

                    return;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseVehicleWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;

                    ExpenseUndo objUndo = new ExpenseUndo();
                    objUndo.CreateNuyen(NuyenExpenseType.AddVehicleWeapon, objWeapon.InternalId);
                    objExpense.Undo = objUndo;
                }
            }

            objMod.Weapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsVehicleWeapon;
            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();

            if (frmPickWeapon.AddAgain)
                tsVehicleAddWeaponWeapon_Click(sender, e);

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:93,代码来源:frmCareer.cs


示例11: tsVehicleAddMod_Click

        private void tsVehicleAddMod_Click(object sender, EventArgs e)
        {
            // Make sure a parent items is selected, then open the Select Vehicle Mod window.
            try
            {
                if (treVehicles.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (treVehicles.SelectedNode.Level > 1)
                treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;

            Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);

            frmSelectVehicleMod frmPickVehicleMod = new frmSelectVehicleMod(_objCharacter, true);
            // Set the Vehicle properties for the window.
            frmPickVehicleMod.VehicleCost = Convert.ToInt32(objSelectedVehicle.Cost);
            frmPickVehicleMod.Body = objSelectedVehicle.Body;
            frmPickVehicleMod.Speed = objSelectedVehicle.Speed;
            frmPickVehicleMod.Accel = objSelectedVehicle.Accel;
            frmPickVehicleMod.DeviceRating = objSelectedVehicle.DeviceRating;
            frmPickVehicleMod.HasModularElectronics = objSelectedVehicle.HasModularElectronics();

            frmPickVehicleMod.ShowDialog(this);

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

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

            XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + frmPickVehicleMod.SelectedMod + "\"]");

            TreeNode objNode = new TreeNode();
            VehicleMod objMod = new VehicleMod(_objCharacter);
            objMod.Create(objXmlMod, objNode, frmPickVehicleMod.SelectedRating);

            // Make sure that the Armor Rating does not exceed the maximum allowed by the Vehicle.
            if (objMod.Name.StartsWith("Armor"))
            {
                if (objMod.Rating > objSelectedVehicle.MaxArmor)
                {
                    objMod.Rating = objSelectedVehicle.MaxArmor;
                    objNode.Text = objMod.DisplayName;
                }
            }

            // Check the item's Cost and make sure the character can afford it.
            int intOriginalCost = objSelectedVehicle.TotalCost;
            objSelectedVehicle.Mods.Add(objMod);

            // Do not allow the user to add a new Vehicle Mod if the Vehicle's Capacity has been reached.
            if (_objOptions.EnforceCapacity && objSelectedVehicle.Slots < objSelectedVehicle.SlotsUsed)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CapacityReached"), LanguageManager.Instance.GetString("MessageTitle_CapacityReached"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                objSelectedVehicle.Mods.Remove(objMod);
                if (frmPickVehicleMod.AddAgain)
                    tsVehicleAddMod_Click(sender, e);
                return;
            }

            int intCost = objSelectedVehicle.TotalCost - intOriginalCost;
            // Apply a markup if applicable.
            if (frmPickVehicleMod.Markup != 0)
            {
                double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(frmPickVehicleMod.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
                intCost = Convert.ToInt32(dblCost);
            }

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

            if (!frmPickVehicleMod.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    objSelectedVehicle.Mods.Remove(objMod);
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (frmPickVehicleMod.AddAgain)
                        tsVehicleAddMod_Click(sender, e);

                    return;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs


示例12: TestVehicles

        private void TestVehicles()
        {
            Character objCharacter = new Character();
            XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
            pgbProgress.Minimum = 0;
            pgbProgress.Value = 0;
            pgbProgress.Maximum = o 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VehicleType类代码示例发布时间:2022-05-24
下一篇:
C# VehicleColour类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap