Ejemplo n.º 1
0
        public bool BuyTradeGood(TradeGood tradeGood, int quantity)
        {
            if (Player.Ship != null && Player.Ship.RemoveCargo(tradeGood.Name, quantity))
            {
                Player.AddCredits(tradeGood.PriceSell * quantity);

                tradeGood.Quantity += quantity;

                return true;
            }

            return false;
        }
Ejemplo n.º 2
0
        private List<TradeGood> CreateTradeGoods()
        {
            List<TradeGood> result = new List<TradeGood>();

            TradeGood ore = new TradeGood(Cargo.CargoType.Ore, 10, 10, 5);
            result.Add(ore);
            TradeGood electronics = new TradeGood(Cargo.CargoType.Electronics, 20, 30, 15);
            result.Add(electronics);
            TradeGood foodstuff = new TradeGood(Cargo.CargoType.Foodstuff, 20, 20, 10);
            result.Add(foodstuff);
            TradeGood medicalSupplies = new TradeGood(Cargo.CargoType.MedicalSupplies, 20, 30, 15);
            result.Add(medicalSupplies);

            return result;
        }
Ejemplo n.º 3
0
        public bool SellTradeGood(TradeGood tradeGood, int quantity)
        {
            if (tradeGood.Quantity > 0
                && Player.Ship != null && Player.Credits - (tradeGood.PriceBuy * quantity) >= 0
                && Player.Ship.AddCargo(new Cargo(tradeGood.Type, quantity)))
            {
                if (tradeGood.Quantity >= quantity)
                    Player.RemoveCredits(tradeGood.PriceBuy * quantity);
                else
                    Player.RemoveCredits(tradeGood.PriceBuy * tradeGood.Quantity);

                if (tradeGood.Quantity > 1)
                    tradeGood.Quantity -= quantity;
                else
                    tradeGood.Quantity = 0;

                return true;
            }

            return false;
        }