示例#1
0
    /// <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);
    }
示例#2
0
    /// <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);
    }
示例#3
0
	// 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;
	}
示例#4
0
    public int Transfer(ResourceType resource, int quantity, CargoHold other)
    {
        int transferred = other.Add(resource, quantity);

        Dump(resource, transferred);

        return(transferred);
    }
示例#5
0
        public static void OpenCargoHold(CargoHold hold)
        {
            HoldUI page = _instance.OpenScreen("Hold Screen") as HoldUI;

            page.Show(hold);

            GameState.SetGlobalPause(page.name);
        }
示例#6
0
 public void Transfer(CargoHold other)
 {
     foreach (ResourceType type in Enum.GetValues(typeof(ResourceType)))
     {
         if (type != ResourceType.None)
         {
             Transfer(type, GetCargo(type).Count, other);
         }
     }
 }
示例#7
0
        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();
        }
示例#8
0
        public void Show(CargoHold hold)
        {
            _hold = hold;

            UpdateDisplay();
        }