Exemple #1
0
 private static void AddShopUnits(int amount, IShopPanelView shopPanel,
                                  IUnitPool <IShopUnitModel> unitPool, IShopFactory shopFactory,
                                  IRandomUnitGenerator unitGenerator)
 {
     amount.Times(() => unitPool.AddUnit(shopFactory.Create(unitGenerator.GetRandomUnitId(), shopPanel.UnitParent)));
     // create unit controller with preparation unit factory
 }
Exemple #2
0
        public ShopPanelController(IShopPanelView view, IShopConfig config, IShopFactory factory,
                                   IUnitPool <IShopUnitModel> shopPool, IRandomUnitGenerator unitGenerator, IEventBus eventBus, IDisposer disposer)
        {
            _eventBus = eventBus;
            view.CloseButton.OnClickAsObservable()
            .Merge(view.BackgroundButton.OnClickAsObservable())
            .SubscribeBlind(() => ClosePanel(view))
            .AddToDisposer(disposer);

            // open panel on event
            eventBus.OnEvent <OpenShopCommand>().SubscribeBlind(view.Open).AddToDisposer(disposer);

            // only spawn items once shop is first opened
            AddShopUnits(config.ShopEntryAmount, view, shopPool, factory, unitGenerator);
        }
Exemple #3
0
 private void ClosePanel(IShopPanelView view)
 {
     view.Close();
     _eventBus.Publish(new CloseShopEvent());
 }