Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
0
        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";
        }
Ejemplo n.º 3
0
    public void SetCargo(Cargoes type, int amount)
    {
        var info = CargoManager.GetCargo(type);

        nameLabel.text  = info.name;
        countLabel.text = amount.ToString();
        illegalIcon.SetActive(!info.legal);
    }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
    /// <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);
    }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
    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);
    }
Ejemplo n.º 8
0
    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));
    }
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
0
    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);
    }
Ejemplo n.º 11
0
    /// <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);
    }