コード例 #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
ファイル: GameState.cs プロジェクト: jdpdev/awful-rum-runner
	// 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
ファイル: UIMain.cs プロジェクト: jdpdev/awful-rum-runner
        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
ファイル: HoldUI.cs プロジェクト: jdpdev/awful-rum-runner
        public void Show(CargoHold hold)
        {
            _hold = hold;

            UpdateDisplay();
        }