示例#1
0
        public ShipTemplate(ShipSpec spec, string name)
        {
            _name = name;
            _size = spec.Size;
            _imageIndex = spec.ImageIndex;
            _cargoBays = spec.CargoBays;
            _weaponSlots = spec.WeaponSlots;
            _shieldSlots = spec.ShieldSlots;
            _gadgetSlots = spec.GadgetSlots;
            _crewQuarters = spec.CrewQuarters;
            _fuelTanks = spec.FuelTanks;
            _hullStrength = spec.HullStrength;

            if (ImageIndex == Consts.ShipImgUseDefault)
                _images = Game.CurrentGame.ParentWindow.CustomShipImages;
        }
示例#2
0
        public bool TradeShip(ShipSpec specToBuy, int netPrice, string newShipName, IWin32Window owner)
        {
            bool traded = false;

            if (netPrice > 0 && Debt > 0)
                FormAlert.Alert(AlertType.DebtNoBuy, owner);
            else if (netPrice > CashToSpend)
                FormAlert.Alert(AlertType.ShipBuyIf, owner);
            else if (specToBuy.CrewQuarters < Ship.SpecialCrew.Length)
            {
                string passengers = Ship.SpecialCrew[1].Name;
                if (Ship.SpecialCrew.Length > 2)
                    passengers += " and " + Ship.SpecialCrew[2].Name;

                FormAlert.Alert(AlertType.ShipBuyPassengerQuarters, owner, passengers);
            }
            else if (specToBuy.CrewQuarters < Ship.CrewCount)
                FormAlert.Alert(AlertType.ShipBuyCrewQuarters, owner);
            else if (Ship.ReactorOnBoard)
                FormAlert.Alert(AlertType.ShipBuyReactor, owner);
            else
            {
                Equipment[] special = new Equipment[]
                {
                    Consts.Weapons[(int)WeaponType.MorgansLaser],
                    Consts.Weapons[(int)WeaponType.QuantumDistruptor],
                    Consts.Shields[(int)ShieldType.Lightning],
                    Consts.Gadgets[(int)GadgetType.FuelCompactor],
                    Consts.Gadgets[(int)GadgetType.HiddenCargoBays]
                };
                bool[] add = new bool[special.Length];
                bool addPod = false;
                int extraCost = 0;

                for (int i = 0; i < special.Length; i++)
                {
                    if (!Ship.HasEquipment(special[i])) continue;
                    if (specToBuy.Slots(special[i].EquipmentType) == 0)
                        FormAlert.Alert(AlertType.ShipBuyNoSlots, owner, newShipName, special[i].Name,
                            Strings.EquipmentTypes[(int)special[i].EquipmentType]);
                    else
                    {
                        extraCost += special[i].TransferPrice;
                        add[i] = true;
                    }
                }

                if (Ship.EscapePod)
                {
                    addPod = true;
                    extraCost += Consts.PodTransferCost;
                }

                if (netPrice + extraCost > CashToSpend)
                    FormAlert.Alert(AlertType.ShipBuyIfTransfer, owner);

                extraCost = 0;

                for (int i = 0; i < special.Length; i++)
                {
                    if (!add[i]) continue;
                    if (netPrice + extraCost + special[i].TransferPrice > CashToSpend)
                        FormAlert.Alert(AlertType.ShipBuyNoTransfer, owner, special[i].Name);
                    else if (FormAlert.Alert(AlertType.ShipBuyTransfer, owner, special[i].Name, special[i].Name.ToLower(),
                        Functions.FormatNumber(special[i].TransferPrice)) == DialogResult.Yes)
                        extraCost += special[i].TransferPrice;
                    else
                        add[i] = false;
                }

                if (addPod)
                {
                    if (netPrice + extraCost + Consts.PodTransferCost > CashToSpend)
                        FormAlert.Alert(AlertType.ShipBuyNoTransfer, owner, Strings.ShipInfoEscapePod);
                    else if (FormAlert.Alert(AlertType.ShipBuyTransfer, owner, Strings.ShipInfoEscapePod,
                        Strings.ShipInfoEscapePod.ToLower(), Functions.FormatNumber(Consts.PodTransferCost)) == DialogResult.Yes)
                        extraCost += Consts.PodTransferCost;
                    else
                        addPod = false;
                }

                if (FormAlert.Alert(AlertType.ShipBuyConfirm, owner, Ship.Name, newShipName,
                    (add[0] || add[1] || add[2] || addPod ? Strings.ShipBuyTransfer : "")) == DialogResult.Yes)
                {
                    CrewMember[] oldCrew = Ship.Crew;

                    Ship = new Ship(specToBuy.Type);
                    Cash -= (netPrice + extraCost);

                    for (int i = 0; i < Math.Min(oldCrew.Length, Ship.Crew.Length); i++)
                        Ship.Crew[i] = oldCrew[i];

                    for (int i = 0; i < special.Length; i++)
                    {
                        if (add[i])
                            Ship.AddEquipment(special[i]);
                    }

                    if (addPod)
                        Ship.EscapePod = true;
                    else if (Insurance)
                    {
                        Insurance = false;
                        NoClaim = 0;
                    }

                    traded = true;
                }
            }

            return traded;
        }
示例#3
0
 public bool TradeShip(ShipSpec specToBuy, int netPrice, IWin32Window owner)
 {
     return TradeShip(specToBuy, netPrice, specToBuy.Name, owner);
 }