/// <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); }
/// <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); }
// Use this for initialization void Awake () { _instance = this; //new WindField(); _cargoManager = new CargoManager(); _timeManager = new TimeManager(); _cargo = new CargoHold(); _assets = new PlayerAssets(); _settlements = FindObjectsOfType<Settlement>(); var ais = FindObjectsOfType<AIController>(); var list = new List<Ship>(); foreach (var ai in ais) { list.Add(ai.GetComponent<Ship>()); } _ais = list.ToArray(); _playerStartPos = _playerShip.transform.position; _playerStartRot = _playerShip.transform.rotation; _cameraStartPos = Camera.main.transform.position; _cameraStartRot = Camera.main.transform.rotation; }
public int Transfer(ResourceType resource, int quantity, CargoHold other) { int transferred = other.Add(resource, quantity); Dump(resource, transferred); return(transferred); }
public static void OpenCargoHold(CargoHold hold) { HoldUI page = _instance.OpenScreen("Hold Screen") as HoldUI; page.Show(hold); GameState.SetGlobalPause(page.name); }
public void Transfer(CargoHold other) { foreach (ResourceType type in Enum.GetValues(typeof(ResourceType))) { if (type != ResourceType.None) { Transfer(type, GetCargo(type).Count, other); } } }
public void Show(CargoHold ship, Warehouse warehouse, PlayerAssets assets) { base.Show(); if (_listItemPrefab == null) { _listItemPrefab = Resources.Load("UI/Purchase Item"); } _ship = ship; _warehouse = warehouse; _settlementName.text = warehouse.settlement.name; UpdateMoneyCount(); UpdateHoldCount(); ShowSellScreen(); }
public void Show(CargoHold hold) { _hold = hold; UpdateDisplay(); }