public void SetCargo(Cargoes type, int amount) { var info = CargoManager.GetCargo(type); nameLabel.text = info.name; countLabel.text = amount.ToString(); illegalIcon.SetActive(!info.legal); }
public void CleanCargo() { var query = from o in Operations select o.CargoId; IEnumerable <int> cargoIds = query.Distinct(); List <Cargo> cargoList = Cargoes.Where(c => !cargoIds.Any(element => c.Id == element)).ToList(); Cargoes.RemoveRange(cargoList); }
/// <summary> /// Returns the count of a particular cargo in the hold /// </summary> /// <param name="id">The cargo to count</param> public int GetItemCount(Cargoes id) { if (_hold.ContainsKey(id)) { return(_hold[id]); } else { return(0); } }
/// <summary> /// Returns the amount of a cargo the settlement wants to buy /// </summary> /// <param name="id">The id of the cargo</param> /// <returns>The quatity of cargo to buy</returns> public int GetWantQuantity(Cargoes id) { Ware ware = GetBuyWare(id); if (ware == null) { return(0); } return(ware.count); }
private Ware GetBuyWare(Cargoes id) { foreach (var ware in _wants) { if (ware.id == id) { return(ware); } } return(null); }
private Ware GetSellWare(Cargoes id) { foreach (var ware in _sells) { if (ware.id == id) { return(ware); } } return(null); }
public int GetPrice(Cargoes id, int count = 1) { if (GetSellWare(id) != null) { return(GetSellPrice(id, count)); } else if (GetBuyWare(id) != null) { return(GetBuyPrice(id, count)); } return(0); }
/// <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 void Remove(Cargoes id, int amount) { if (_hold.ContainsKey(id)) { _hold[id] -= amount; if (_hold[id] < 0) { _hold[id] = 0; } RecalculateCargoHold(); } }
/// <summary> /// Modify the quantity of a ware being bought /// </summary> /// <param name="id">The id of the ware</param> /// <param name="amount">The amount to change, positive or negative</param> public void ModifyBuyingWare(Cargoes id, int amount) { Ware ware = GetBuyWare(id); if (ware != null) { ware.count += amount; if (ware.count < 0) { ware.count = 0; } } }
public bool Add(Cargoes id, int amount) { if (_currentHold + amount > _capacity) { return(false); } if (_hold.ContainsKey(id)) { _hold[id] += amount; } else { _hold.Add(id, amount); } RecalculateCargoHold(); return(true); }
/// <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); }
/// <summary> /// Process buying cargo from a merchant /// </summary> /// <param name="ship">The ship doing the buying</param> /// <param name="warehouse">The merchant doing the selling</param> /// <param name="assets">The player's wealth</param> /// <param name="id">The cargo to buy</param> /// <param name="count">The amount to buy</param> /// <returns>Successfulness</returns> public static bool ProcessBuy(CargoHold ship, Warehouse warehouse, PlayerAssets assets, Cargoes id, int count) { int price = warehouse.GetSellPrice(id, count); if (assets.cash < price) { return(false); } if (warehouse.GetWareQuantity(id) == 0) { return(false); } if (ship.availableSpace < count) { return(false); } assets.ModifyCash(-price); ship.Add(id, count); warehouse.ModifySellingWare(id, -count); warehouse.ModifyCash(price); return(true); }
public static CargoList.CargoEntry GetCargo(Cargoes id) { return(_instance._cargos[id]); }
public void DumpCargo(Cargoes cargo) { _hold.Remove(cargo, 1); UpdateDisplay(); }