private void Info(int id) { ShipSpec spec = Consts.ShipSpecs[id]; picShip.Image = spec.Image; lblName.Text = spec.Name; lblSize.Text = Strings.Sizes[(int)spec.Size]; lblBays.Text = Functions.FormatNumber(spec.CargoBays); lblRange.Text = Functions.Multiples(spec.FuelTanks, Strings.DistanceUnit); lblHull.Text = Functions.FormatNumber(spec.HullStrength); lblWeapon.Text = Functions.FormatNumber(spec.WeaponSlots); lblShield.Text = Functions.FormatNumber(spec.ShieldSlots); lblGadget.Text = Functions.FormatNumber(spec.GadgetSlots); lblCrew.Text = Functions.FormatNumber(spec.CrewQuarters); }
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; } }
public bool TradeShip(ShipSpec specToBuy, int netPrice, IWin32Window owner) { return(TradeShip(specToBuy, netPrice, specToBuy.Name, owner)); }
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])) { 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]) { 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); }
private void GenerateOpponentShip(OpponentType oppType) { Commander cmdr = Game.CurrentGame.Commander; PoliticalSystem polSys = Game.CurrentGame.WarpSystem.PoliticalSystem; if (oppType == OpponentType.Mantis) { SetValues(ShipType.Mantis); } else { ShipType oppShipType; int tries = 1; switch (oppType) { case OpponentType.Pirate: // Pirates become better when you get richer tries = 1 + cmdr.Worth / 100000; tries = Math.Max(1, tries + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); break; case OpponentType.Police: // The police will try to hunt you down with better ships if you are // a villain, and they will try even harder when you are considered to // be a psychopath (or are transporting Jonathan Wild) if (cmdr.PoliceRecordScore < Consts.PoliceRecordScorePsychopath || cmdr.Ship.WildOnBoard) { tries = 5; } else if (cmdr.PoliceRecordScore < Consts.PoliceRecordScoreVillain) { tries = 3; } else { tries = 1; } tries = Math.Max(1, tries + (int)Game.CurrentGame.Difficulty - (int)Difficulty.Normal); break; } if (oppType == OpponentType.Trader) { oppShipType = ShipType.Flea; } else { oppShipType = ShipType.Gnat; } int total = 0; for (int i = 0; i < Consts.MaxShip; i++) { ShipSpec spec = Consts.ShipSpecs[i]; if (polSys.ShipTypeLikely(spec.Type, oppType)) { total += spec.Occurrence; } } for (int i = 0; i < tries; i++) { int x = Functions.GetRandom(total); int sum = -1; int j = -1; do { j++; if (polSys.ShipTypeLikely(Consts.ShipSpecs[j].Type, oppType)) { if (sum > 0) { sum += Consts.ShipSpecs[j].Occurrence; } else { sum = Consts.ShipSpecs[j].Occurrence; } } } while (sum < x && j < Consts.MaxShip); if (j > (int)oppShipType) { oppShipType = Consts.ShipSpecs[j].Type; } } SetValues(oppShipType); } }