Esempio n. 1
0
        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 GameInitializator()
        {
            this.ingredientFactory = MarketFactory.Get(Category.Ingredient);
            this.presentFactory = new PresentFactory();

            this.gameObjects = new List<GameObject>
            {
                new Raspberry(new MatrixCoords(10, 10)),
                new Blueberry(new MatrixCoords(20, 5)),
                new Raspberry(new MatrixCoords(20, 25)),
                new Hen(new MatrixCoords(1, 4)),
                new Hen(new MatrixCoords(9, 9)),
                new Lamb(new MatrixCoords(20, 20)),
                new Lamb(new MatrixCoords(5, 20)),
                new Rabbit(new MatrixCoords(12, 12)),
                new Rabbit(new MatrixCoords(2, 20)),
            };

            this.inventoryItems = new List<IStorable>
            {
                new Raspberry(),
                new Hen(),
                new Rabbit(),
                new Lamb(),
                new EasterEgg(ByproductColor.Blue),
                new EasterEgg(ByproductColor.Red),
                new TrophyEgg(ByproductColor.Blue),
                new TrophyEgg(ByproductColor.Red),
                new Milk(),
            };

            this.marketIngredients = new List<IBuyable>();
            this.FillIngredients();

            this.presents = new List<IStorable>();
            this.FillPresents();
        }
 public void Initialize(FarmManager farmManager, Market market, PresentFactory presentFactory, ICollection<GameObject> farmObjects)
 {
     this.FillGameObjectCollection(farmObjects);
     this.FillMarketIngredients(market);
     this.FillInventory(farmManager);
 }
        public void MakePresent(PresentType presentType, PresentFactory presentFactory)
        {
            foreach (var ingredient in RecipeConstants.Recipes[presentType])
            {
                var item = this.GetFromInventoryByType(ingredient.Key);
                if (item != null)
                {
                    this.SubtractFromInventoryItem(item, ingredient.Value);
                }
                else
                {
                    throw new InsufficientAmmountException(ingredient.Key.ToString());
                }
            }

            var present = presentFactory.Get(presentType);
            this.AddToInventory(present);
        }
        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();
        }