/// <summary> /// Process selling cargo to a merchant /// </summary> /// <param name="ship">The ship doing the selling</param> /// <param name="warehouse">The merchant doing the buying</param> /// <param name="assets">The player's wealth</param> /// <param name="id">The cargo to sell</param> /// <param name="count">The amount to sell</param> /// <returns>Successfulness</returns> public static bool ProcessSell(CargoHold ship, Warehouse warehouse, PlayerAssets assets, Cargoes id, int count) { int price = warehouse.GetBuyPrice(id, count); if (warehouse.cash < price) { return(false); } if (warehouse.GetWantQuantity(id) == 0) { return(false); } if (ship.GetItemCount(id) < count) { return(false); } ship.Remove(id, count); warehouse.ModifyBuyingWare(id, -count); assets.ModifyCash(price); warehouse.ModifyCash(-price); if (!CargoManager.GetCargo(id).legal) { assets.ModifyReputation(price); } return(true); }
public void RefreshDisplay() { var cargo = CargoManager.GetCargo(_ware.id); _nameLabel.text = cargo.name; _countLabel.text = "x" + _ware.count; _priceLabel.text = _warehouse.GetPrice(_ware.id, 1) + "G"; }
public void SetCargo(Cargoes type, int amount) { var info = CargoManager.GetCargo(type); nameLabel.text = info.name; countLabel.text = amount.ToString(); illegalIcon.SetActive(!info.legal); }
private void UpdateSelectedItem() { if (_selectedItem < _itemList.Count) { PurchaseItem item = _itemList[_selectedItem]; CargoList.CargoEntry cargo = CargoManager.GetCargo(item.ware.id); _selectedWareNameLabel.text = cargo.name; _sellerHoldLabel.text = item.ware.count.ToString(); _playerHoldLabel.text = _ship.GetItemCount(cargo.cargo).ToString(); } }
/// <summary> /// Returns if the hold is completely legal /// </summary> /// <returns>Whether the conents of the hold is fully legal</returns> public bool IsLegal() { foreach (var item in _hold) { if (item.Value > 0 && !CargoManager.GetCargo(item.Key).legal) { return(false); } } return(true); }
/// <summary> /// Returns the price the warehouse buys a cargo for /// </summary> /// <param name="id">Id of the cargo to buy</param> /// <param name="count">Optional cargo count</param> /// <returns>The buying price</returns> public int GetBuyPrice(Cargoes id, int count = 1) { Ware ware = GetBuyWare(id); if (ware == null) { return(0); } int basePrice = Mathf.RoundToInt(ware.priceMod * CargoManager.GetCargo(id).price); return(basePrice * count); }
public int GetIllegalCargoValue() { var cargos = _target.cargoHold.GetIllegalCargo(); int totalFine = 0; foreach (var item in cargos) { var desc = CargoManager.GetCargo(item.Key); totalFine += desc.price * item.Value; } return(totalFine); }
public int GetHidingCount() { float count = 0; foreach (var item in _hold) { var cargo = CargoManager.GetCargo(item.Key); if (cargo.legal) { count += item.Value / cargo.hideRatio; } } return(Mathf.RoundToInt(count)); }
public int GetIllegalCount() { int count = 0; foreach (var item in _hold) { var cargo = CargoManager.GetCargo(item.Key); if (!cargo.legal) { count += item.Value; } } return(count); }
public Dictionary <Cargoes, int> GetIllegalCargo() { var list = new Dictionary <Cargoes, int>(); foreach (var item in _hold) { var cargo = CargoManager.GetCargo(item.Key); if (!cargo.legal) { list.Add(item.Key, item.Value); } } return(list); }
/// <summary> /// Hiding factor is a number representing how well any illegal cargo is hidden /// </summary> /// <returns></returns> public int GetHidingFactor() { float totalIllegal = 0; float totalHideVolume = 0; int factor = 0; foreach (var item in _hold) { var cargo = CargoManager.GetCargo(item.Key); if (cargo.legal) { totalHideVolume += item.Value / cargo.hideRatio; } else { totalIllegal += item.Value; } } factor = Mathf.RoundToInt((totalHideVolume / totalIllegal) * 75); return(factor); }