public Engine(IRenderer renderer, IUserKeyboardInput userInput, IAim aim, GameInitializator gameInitializator) { this.Renderer = renderer; this.UserInput = userInput; this.Aim = aim; this.GameInitializator = gameInitializator; random = new Random(); this.gameObjects = new HashSet<GameObject>(); this.farm = new Farm(); this.farmManager = new FarmManager(); this.market = new Market(); this.presentFactory = new PresentFactory(); }
public void BuyProducts(IBuyable product, int quantity, Market market) { int cost = market.CalculateCost(product, quantity); var currency = this.GetFromInventoryByType(FarmFoodType.Raspberry); if (currency != null && this.Inventory[currency] >= cost) { this.Inventory[currency] -= cost; } else { throw new InsufficientAmmountException(currency.ToString()); } this.AddToInventory(product); }
public void Initialize(FarmManager farmManager, Market market, PresentFactory presentFactory, ICollection<GameObject> farmObjects) { this.FillGameObjectCollection(farmObjects); this.FillMarketIngredients(market); this.FillInventory(farmManager); }
private void FillMarketIngredients(Market market) { foreach (var ingredient in this.marketIngredients) { market.AddProduct(ingredient); } }
public void SellProducts(ISellable product, int quantity, Market market) { int income = market.CalculateCost(product, quantity); var currency = this.GetFromInventoryByType(FarmFoodType.Raspberry); this.RemoveFromInventory(product); this.AddMultipleToInventory(currency, income); }
public void SetInitialGameObjects() { this.farmManager = new FarmManager(); this.market = Market.Instance; var ingredientFactory = EasterFarm.Models.MarketPlace.MarketFactory.Get(Category.Ingredient); this.FillMarketCategory(ingredientFactory, IngredientType.Basket); this.presentFactory = new PresentFactory(); }