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); }
public ShopUnitModel(int initialId, ICashModel cashModel, IBenchPreparationUnitPool benchPreparationUnitPool, IPreparationUnitFactory preparationUnitFactory, IShopConfig shopConfig, IDisposer disposer) { _id = new ReactiveProperty <int>(initialId); _hasBeenBought = new ReactiveProperty <bool>(false); Cost = _id.Select(shopConfig.GetCost) .ToReadOnlyReactiveProperty() .AddToDisposer(disposer); _cashModel = cashModel; _preparationUnitFactory = preparationUnitFactory; CanBeBought = benchPreparationUnitPool.IsBenchFull .CombineLatest(cashModel.CurrentCash, Cost, _hasBeenBought, (benchFull, cash, cost, purchased) => !benchFull && cash >= cost && !purchased) .ToReadOnlyReactiveProperty() .AddToDisposer(disposer); }
public ShopUnitPool(IShopConfig config) { _config = config; }
public RandomUnitGenerator(IShopConfig shopConfig) { _allShopUnits = shopConfig.AllShopUnits; }