示例#1
0
        private void tsWeaponSell_Click(object sender, EventArgs e)
        {
            // Delete the selected Weapon.
            try
            {
                if (treWeapons.SelectedNode.Level == 1)
                {
                    Weapon objWeapon = new Weapon(_objCharacter);
                    // Locate the Weapon that is selected in the tree.
                    foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
                    {
                        if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                        {
                            objWeapon = objCharacterWeapon;
                            break;
                        }
                    }

                    // Cyberweapons cannot be removed through here and must be done by removing the piece of Cyberware.
                    if (objWeapon.Cyberware)
                    {
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveCyberweapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveCyberweapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (objWeapon.Category == "Gear")
                    {
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveGearWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveGearWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (objWeapon.Category.StartsWith("Quality"))
                    {
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveQualityWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveQualityWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

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

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objWeapon.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objCharacter.Weapons.Remove(objWeapon);
                    treWeapons.SelectedNode.Remove();
                }
                else if (treWeapons.SelectedNode.Level > 1)
                {
                    Weapon objWeapon = new Weapon(_objCharacter);
                    // Locate the Weapon that is selected in the tree.
                    foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
                    {
                        if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Parent.Tag.ToString())
                        {
                            objWeapon = objCharacterWeapon;
                            break;
                        }
                    }

                    WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
                    // Locate the Accessory that is selected in the tree.
                    foreach (WeaponAccessory objCharacterAccessory in objWeapon.WeaponAccessories)
                    {
                        if (objCharacterAccessory.InternalId == treWeapons.SelectedNode.Tag.ToString())
                        {
                            objAccessory = objCharacterAccessory;
                            break;
                        }
                    }

                    if (objAccessory.Name != "")
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Record the Weapon's original cost.
                        int intOriginal = objWeapon.TotalCost;

                        objWeapon.WeaponAccessories.Remove(objAccessory);
                        treWeapons.SelectedNode.Remove();

                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objWeapon.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeaponAccessory") + " " + objAccessory.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }

                    WeaponMod objMod = new WeaponMod(_objCharacter);
                    // Locate the Mod that is selected in the tree.
                    foreach (WeaponMod objCharacterMod in objWeapon.WeaponMods)
                    {
                        if (objCharacterMod.InternalId == treWeapons.SelectedNode.Tag.ToString())
                        {
                            objMod = objCharacterMod;
                            break;
                        }
                    }

                    if (objMod.Name != "")
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Record the Weapon's original cost.
                        int intOriginal = objWeapon.TotalCost;

                        objWeapon.WeaponMods.Remove(objMod);
                        treWeapons.SelectedNode.Remove();

                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objWeapon.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeaponMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }
                    else
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Find the selected Gear.
                        Gear objGear = _objFunctions.FindWeaponGear(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, out objAccessory);
                        _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                        if (objGear.Parent == null)
                            objAccessory.Gear.Remove(objGear);
                        else
                            objGear.Parent.Children.Remove(objGear);
                        treWeapons.SelectedNode.Remove();

                        int intAmount = Convert.ToInt32(Convert.ToDouble(objGear.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeaponGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }
                }
                UpdateCharacterInfo();
                RefreshSelectedWeapon();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
示例#2
0
        private void tsVehicleSell_Click(object sender, EventArgs e)
        {
            // Delete the selected Vehicle.
            try
            {
                if (treVehicles.SelectedNode.Level == 1)
                {
                    Vehicle objVehicle = new Vehicle(_objCharacter);
                    // Locate the Vehicle that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objVehicle = objCharacterVehicle;
                            break;
                        }
                    }

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

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

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicle") + " " + objVehicle.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objCharacter.Vehicles.Remove(objVehicle);
                    treVehicles.SelectedNode.Remove();
                }
                else if (treVehicles.SelectedNode.Level == 2)
                {
                    // Locate the VehicleMod that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (VehicleMod objMod in objCharacterVehicle.Mods)
                        {
                            if (objMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                            {
                                // Do not allow VehicleMods that come with a Vehicle to be removed.
                                if (objMod.IncludedInVehicle)
                                {
                                    MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveVehicleMod"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveVehicleMod"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                                else
                                {
                                    frmSellItem frmSell = new frmSellItem();
                                    frmSell.ShowDialog(this);

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

                                    // Record the original value of the Vehicle.
                                    int intOriginal = objCharacterVehicle.TotalCost;

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

                                    objCharacterVehicle.Mods.Remove(objMod);
                                    treVehicles.SelectedNode.Remove();

                                    // Create the Expense Log Entry for the sale.
                                    int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                    _objCharacter.ExpenseEntries.Add(objExpense);
                                    _objCharacter.Nuyen += intAmount;
                                }
                                break;
                            }
                        }
                    }

                    // 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())
                            {
                                frmSellItem frmSell = new frmSellItem();
                                frmSell.ShowDialog(this);

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

                                // Record the original value of the vehicle.
                                int intOriginal = objCharacterVehicle.TotalCost;

                                // Remove the Gear Weapon created by the Gear if applicable.
                                if (objGear.WeaponID != Guid.Empty.ToString())
                                {
                                    // Remove the Weapon from the TreeView.
                                    foreach (TreeNode objWeaponNode in treVehicles.SelectedNode.Parent.Nodes)
                                    {
                                        if (objWeaponNode.Tag.ToString() == objGear.WeaponID)
                                        {
                                            treVehicles.SelectedNode.Parent.Nodes.Remove(objWeaponNode);
                                            break;
                                        }
                                    }

                                    // Remove the Weapon from the Vehicle.
                                    Weapon objRemoveWeapon = new Weapon(_objCharacter);
                                    foreach (Weapon objWeapon in objCharacterVehicle.Weapons)
                                    {
                                        if (objWeapon.InternalId == objGear.WeaponID)
                                            objRemoveWeapon = objWeapon;
                                    }
                                    objCharacterVehicle.Weapons.Remove(objRemoveWeapon);
                                }

                                objCharacterVehicle.Gear.Remove(objGear);
                                treVehicles.SelectedNode.Remove();

                                // Create the Expense Log Entry for the sale.
                                int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                _objCharacter.ExpenseEntries.Add(objExpense);
                                _objCharacter.Nuyen += intAmount;

                                break;
                            }
                        }
                    }

                    // Locate the Weapon that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (Weapon objWeapon in objCharacterVehicle.Weapons)
                        {
                            if (objWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                            {
                                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveGearWeaponVehicle"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveGearWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                break;
                            }
                        }
                    }
                }
                else if (treVehicles.SelectedNode.Level == 3)
                {
                    // Locate the selected VehicleWeapon that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (VehicleMod objMod in objCharacterVehicle.Mods)
                        {
                            foreach (Weapon objWeapon in objMod.Weapons)
                            {
                                if (objWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    frmSellItem frmSell = new frmSellItem();
                                    frmSell.ShowDialog(this);

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

                                    // Record the original value of the Vehicle.
                                    int intOriginal = objCharacterVehicle.TotalCost;

                                    objMod.Weapons.Remove(objWeapon);
                                    treVehicles.SelectedNode.Remove();

                                    // Create the Expense Log Entry for the sale.
                                    int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                    _objCharacter.ExpenseEntries.Add(objExpense);
                                    _objCharacter.Nuyen += intAmount;

                                    break;
                                }
                            }
                        }
                    }

                    // Locate the selected Sensor Plugin.
                    // Locate the Sensor that is selected in the tree.
                    Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                    Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
                    if (objGear != null)
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Record the original value of the Vehicle.
                        int intOriginal = objFoundVehicle.TotalCost;

                        objGear.Parent.Children.Remove(objGear);
                        treVehicles.SelectedNode.Remove();

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objFoundVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }

                    // Locate the selected Cyberware.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (VehicleMod objMod in objCharacterVehicle.Mods)
                        {
                            foreach (Cyberware objCyberware in objMod.Cyberware)
                            {
                                if (objCyberware.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    frmSellItem frmSell = new frmSellItem();
                                    frmSell.ShowDialog(this);

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

                                    // Record the original value of the Vehicle.
                                    int intOriginal = objCharacterVehicle.TotalCost;

                                    objMod.Cyberware.Remove(objCyberware);
                                    treVehicles.SelectedNode.Remove();

                                    // Create the Expense Log Entry for the sale.
                                    int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleCyberware") + " " + objCyberware.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                    _objCharacter.ExpenseEntries.Add(objExpense);
                                    _objCharacter.Nuyen += intAmount;

                                    break;
                                }
                            }
                        }
                    }
                }
                else if (treVehicles.SelectedNode.Level == 4)
                {
                    // Locate the selected WeaponAccessory or VehicleWeaponMod that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (VehicleMod objMod in objCharacterVehicle.Mods)
                        {
                            foreach (Weapon objWeapon in objMod.Weapons)
                            {
                                foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
                                {
                                    if (objAccessory.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                    {
                                        frmSellItem frmSell = new frmSellItem();
                                        frmSell.ShowDialog(this);

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

                                        // Record the original value of the Vehicle.
                                        int intOriginal = objCharacterVehicle.TotalCost;

                                        objWeapon.WeaponAccessories.Remove(objAccessory);
                                        treVehicles.SelectedNode.Remove();

                                        // Create the Expense Log Entry for the sale.
                                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleWeaponAccessory") + " " + objAccessory.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                        _objCharacter.ExpenseEntries.Add(objExpense);
                                        _objCharacter.Nuyen += intAmount;

                                        break;
                                    }
                                }
                                foreach (WeaponMod objWeaponMod in objWeapon.WeaponMods)
                                {
                                    if (objWeaponMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                    {
                                        frmSellItem frmSell = new frmSellItem();
                                        frmSell.ShowDialog(this);

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

                                        // Record tthe original value of the Vehicle.
                                        int intOriginal = objCharacterVehicle.TotalCost;

                                        objWeapon.WeaponMods.Remove(objWeaponMod);
                                        treVehicles.SelectedNode.Remove();

                                        // Create the Expense Log Entry for the sale.
                                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleWeaponMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                        _objCharacter.ExpenseEntries.Add(objExpense);
                                        _objCharacter.Nuyen += intAmount;

                                        break;
                                    }
                                }
                                if (objWeapon.UnderbarrelWeapons.Count > 0)
                                {
                                    foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons)
                                    {
                                        if (objUnderbarrelWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                        {
                                            frmSellItem frmSell = new frmSellItem();
                                            frmSell.ShowDialog(this);

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

                                            // Record the original value of the Vehicle.
                                            int intOriginal = objCharacterVehicle.TotalCost;

                                            objWeapon.UnderbarrelWeapons.Remove(objUnderbarrelWeapon);
                                            treVehicles.SelectedNode.Remove();

                                            // Create the Expense Log Entry for the sale.
                                            int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                            ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                            objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleWeapon") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                            _objCharacter.ExpenseEntries.Add(objExpense);
                                            _objCharacter.Nuyen += intAmount;

                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Locate the selected Sensor Plugin.
                    // Locate the Sensor that is selected in the tree.
                    Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                    Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
                    if (objGear != null)
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Record the original value of the Vehicle.
                        int intOriginal = objFoundVehicle.TotalCost;

                        objGear.Parent.Children.Remove(objGear);
                        treVehicles.SelectedNode.Remove();
                        _objFunctions.DeleteVehicleGear(objGear, treVehicles, objFoundVehicle);

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objFoundVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }
                }
                else if (treVehicles.SelectedNode.Level == 5)
                {
                    // Locate the selected WeaponAccessory or VehicleWeaponMod that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (VehicleMod objMod in objCharacterVehicle.Mods)
                        {
                            foreach (Weapon objWeapon in objMod.Weapons)
                            {
                                if (objWeapon.UnderbarrelWeapons.Count > 0)
                                {
                                    foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons)
                                    {
                                        foreach (WeaponAccessory objAccessory in objUnderbarrelWeapon.WeaponAccessories)
                                        {
                                            if (objAccessory.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                            {
                                                frmSellItem frmSell = new frmSellItem();
                                                frmSell.ShowDialog(this);

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

                                                // Record the original value of the Vehicle.
                                                int intOriginal = objCharacterVehicle.TotalCost;

                                                objUnderbarrelWeapon.WeaponAccessories.Remove(objAccessory);
                                                treVehicles.SelectedNode.Remove();

                                                // Create the Expense Log Entry for the sale.
                                                int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                                ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                                objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleWeaponAccessory") + " " + objAccessory.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                                _objCharacter.ExpenseEntries.Add(objExpense);
                                                _objCharacter.Nuyen += intAmount;

                                                break;
                                            }
                                        }
                                        foreach (WeaponMod objWeaponMod in objUnderbarrelWeapon.WeaponMods)
                                        {
                                            if (objWeaponMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                            {
                                                frmSellItem frmSell = new frmSellItem();
                                                frmSell.ShowDialog(this);

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

                                                // Record tthe original value of the Vehicle.
                                                int intOriginal = objCharacterVehicle.TotalCost;

                                                objUnderbarrelWeapon.WeaponMods.Remove(objWeaponMod);
                                                treVehicles.SelectedNode.Remove();

                                                // Create the Expense Log Entry for the sale.
                                                int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                                ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                                objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleWeaponMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                                _objCharacter.ExpenseEntries.Add(objExpense);
                                                _objCharacter.Nuyen += intAmount;

                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Locate the selected Sensor Plugin.
                    // Locate the Sensor that is selected in the tree.
                    Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                    Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
                    if (objGear != null)
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Record the original value of the Vehicle.
                        int intOriginal = objFoundVehicle.TotalCost;

                        objGear.Parent.Children.Remove(objGear);
                        treVehicles.SelectedNode.Remove();
                        _objFunctions.DeleteVehicleGear(objGear, treVehicles, objFoundVehicle);

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objFoundVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }
                }
                else if (treVehicles.SelectedNode.Level > 5)
                {
                    // Locate the selected Sensor Plugin.
                    // Locate the Sensor that is selected in the tree.
                    Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                    Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
                    if (objGear != null)
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Record the original value of the Vehicle.
                        int intOriginal = objFoundVehicle.TotalCost;

                        objGear.Parent.Children.Remove(objGear);
                        treVehicles.SelectedNode.Remove();
                        _objFunctions.DeleteVehicleGear(objGear, treVehicles, objFoundVehicle);

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objFoundVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }
                }
                UpdateCharacterInfo();
                RefreshSelectedVehicle();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
示例#3
0
        private void tsArmorSell_Click(object sender, EventArgs e)
        {
            // Delete the selected piece of Armor.
            try
            {
                if (treArmor.SelectedNode.Level == 1)
                {
                    // Locate the piece of Armor that is selected in the tree.
                    Armor objArmor = _objFunctions.FindArmor(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

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

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objArmor.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmor") + " " + objArmor.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    // Remove any Improvements created by the Armor and its children.
                    foreach (ArmorMod objMod in objArmor.ArmorMods)
                    {
                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.WeaponID != Guid.Empty.ToString())
                        {
                            // Remove the Weapon from the TreeView.
                            TreeNode objRemoveNode = new TreeNode();
                            foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                            {
                                if (objWeaponNode.Tag.ToString() == objMod.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
                                if (objWeapon.InternalId == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                    }
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId);

                    _objCharacter.Armor.Remove(objArmor);
                    treArmor.SelectedNode.Remove();
                }
                else if (treArmor.SelectedNode.Level == 2)
                {
                    // Locate the ArmorMod that is selected in the tree.
                    bool blnIsMod = false;
                    ArmorMod objMod = _objFunctions.FindArmorMod(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                    if (objMod != null)
                        blnIsMod = true;

                    if (blnIsMod)
                    {
                        // Record the cost of the Armor with the ArmorMod.
                        int intOriginal = objMod.Parent.TotalCost;

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.WeaponID != Guid.Empty.ToString())
                        {
                            // Remove the Weapon from the TreeView.
                            TreeNode objRemoveNode = new TreeNode();
                            foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                            {
                                if (objWeaponNode.Tag.ToString() == objMod.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
                                if (objWeapon.InternalId == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        // Remove any Improvements created by the ArmorMod.
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);

                        objMod.Parent.ArmorMods.Remove(objMod);
                        treArmor.SelectedNode.Remove();

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objMod.Parent.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmorMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }
                    else
                    {
                        Armor objArmor = new Armor(_objCharacter);
                        Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objArmor);

                        // Record the cost of the Armor with the ArmorMod.
                        int intOriginal = objArmor.TotalCost;

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Remove any Improvements created by the Gear.
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);

                        objArmor.Gear.Remove(objGear);
                        treArmor.SelectedNode.Remove();

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objArmor.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmorGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;

                        _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                    }
                }
                else if (treArmor.SelectedNode.Level > 2)
                {
                    Armor objArmor = new Armor(_objCharacter);
                    Gear objGear = new Gear(_objCharacter);
                    Gear objParent = new Gear(_objCharacter);
                    objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objArmor);
                    objParent = objGear.Parent;

                    // Record the cost of the Armor with the ArmorMod.
                    int intOriginal = objArmor.TotalCost;

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

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

                    // Remove any Improvements created by the Gear.
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);

                    objParent.Children.Remove(objGear);
                    treArmor.SelectedNode.Remove();

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objArmor.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmorGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                }
                UpdateCharacterInfo();
                RefreshSelectedArmor();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
示例#4
0
        private void tsCyberwareSell_Click(object sender, EventArgs e)
        {
            try
            {
                if (treCyberware.SelectedNode.Level > 0)
                {
                    bool blnFound = false;
                    Cyberware objCyberware = new Cyberware(_objCharacter);
                    Cyberware objParent = new Cyberware(_objCharacter);
                    // Locate the piece of Cyberware that is selected in the tree.
                    foreach (Cyberware objCharacterCyberware in _objCharacter.Cyberware)
                    {
                        if (objCharacterCyberware.InternalId == treCyberware.SelectedNode.Tag.ToString())
                        {
                            objCyberware = objCharacterCyberware;
                            blnFound = true;
                            break;
                        }
                        foreach (Cyberware objChildCyberware in objCharacterCyberware.Children)
                        {
                            if (objChildCyberware.InternalId == treCyberware.SelectedNode.Tag.ToString())
                            {
                                objCyberware = objChildCyberware;
                                objParent = objCharacterCyberware;
                                blnFound = true;
                                break;
                            }
                        }
                    }

                    if (blnFound)
                    {
                        if (objCyberware.Capacity == "[*]" && treCyberware.SelectedNode.Level == 2)
                        {
                            MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveCyberware"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(objCyberware.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        string strEntry = "";
                        if (objCyberware.SourceType == Improvement.ImprovementSource.Cyberware)
                            strEntry = LanguageManager.Instance.GetString("String_ExpenseSoldCyberware");
                        else
                            strEntry = LanguageManager.Instance.GetString("String_ExpenseSoldBioware");
                        objExpense.Create(intAmount, strEntry + " " + objCyberware.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;

                        // Run through the Cyberware's child elements and remove any Improvements and Cyberweapons.
                        foreach (Cyberware objChildCyberware in objCyberware.Children)
                        {
                            _objImprovementManager.RemoveImprovements(objCyberware.SourceType, objChildCyberware.InternalId);
                            if (objChildCyberware.WeaponID != Guid.Empty.ToString())
                            {
                                // Remove the Weapon from the TreeView.
                                TreeNode objRemoveNode = new TreeNode();
                                foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                                {
                                    if (objWeaponNode.Tag.ToString() == objChildCyberware.WeaponID)
                                        objRemoveNode = objWeaponNode;
                                }
                                treWeapons.Nodes.Remove(objRemoveNode);

                                // Remove the Weapon from the Character.
                                Weapon objRemoveWeapon = new Weapon(_objCharacter);
                                foreach (Weapon objWeapon in _objCharacter.Weapons)
                                {
                                    if (objWeapon.InternalId == objChildCyberware.WeaponID)
                                        objRemoveWeapon = objWeapon;
                                }
                                _objCharacter.Weapons.Remove(objRemoveWeapon);
                            }
                        }
                        // Remove the Children.
                        objCyberware.Children.Clear();

                        // Remove the Cyberweapon created by the Cyberware if applicable.
                        if (objCyberware.WeaponID != Guid.Empty.ToString())
                        {
                            // Remove the Weapon from the TreeView.
                            TreeNode objRemoveNode = new TreeNode();
                            foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
                            {
                                if (objWeaponNode.Tag.ToString() == objCyberware.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
                                if (objWeapon.InternalId == objCyberware.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        // Remove any Improvements created by the piece of Cyberware.
                        _objImprovementManager.RemoveImprovements(objCyberware.SourceType, objCyberware.InternalId);
                        _objCharacter.Cyberware.Remove(objCyberware);

                        // Remove the item from the TreeView.
                        treCyberware.Nodes.Remove(treCyberware.SelectedNode);

                        // If the Parent is populated, remove the item from its Parent.
                        objParent.Children.Remove(objCyberware);
                    }
                    else
                    {
                        // Locate the selected piece of Gear.
                        Gear objGear = _objFunctions.FindCyberwareGear(treCyberware.SelectedNode.Tag.ToString(), _objCharacter.Cyberware, out objCyberware);

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

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

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(objGear.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        string strEntry = LanguageManager.Instance.GetString("String_ExpenseSoldCyberwareGear");
                        objExpense.Create(intAmount, strEntry + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;

                        if (objGear.Parent == null)
                            objCyberware.Gear.Remove(objGear);
                        else
                            objGear.Parent.Children.Remove(objGear);

                        _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);
                        treCyberware.SelectedNode.Remove();
                    }

                    _blnIsDirty = true;
                    UpdateWindowTitle();
                }
                RefreshSelectedCyberware();
            }
            catch
            {
            }

            UpdateCharacterInfo();
        }
示例#5
0
        private void sellItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Delete the selected Gear.
            try
            {
                if (treGear.SelectedNode.Level > 0)
                {
                    Gear objGear = new Gear(_objCharacter);
                    Gear objParent = new Gear(_objCharacter);
                    // Locate the piece of Gear that is selected in the tree.
                    foreach (Gear objCharacterGear in _objCharacter.Gear)
                    {
                        if (objCharacterGear.InternalId == treGear.SelectedNode.Tag.ToString())
                        {
                            objGear = objCharacterGear;
                            break;
                        }
                        foreach (Gear objChildGear in objCharacterGear.Children)
                        {
                            if (objChildGear.InternalId == treGear.SelectedNode.Tag.ToString())
                            {
                                objGear = objChildGear;
                                objParent = objCharacterGear;
                                break;
                            }
                        }
                    }

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

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

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objGear.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);

                    _objCharacter.Gear.Remove(objGear);
                    treGear.SelectedNode.Remove();

                    // If the Parent is populated, remove the item from its Parent.
                    objParent.Children.Remove(objGear);
                }
                _objController.PopulateFocusList(treFoci);
                UpdateCharacterInfo();
                RefreshSelectedGear();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }