public PreparationUnitModel(int id,
                                    [Inject(Id = PlayArea.Bench)] IPlayArea benchModel,
                                    [Inject(Id = PlayArea.Board)] IPlayArea boardModel,
                                    IBoardPreparationUnitPool boardPool, IBenchPreparationUnitPool benchPool)
        {
            Id          = id;
            _benchModel = benchModel;
            _boardModel = boardModel;
            _boardPool  = boardPool;
            _benchPool  = benchPool;

            IsOnBoard = false;
            _position = new ReactiveProperty <Vector2Int>();
        }
        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);
        }
Beispiel #3
0
 public BenchModel(IBenchPreparationUnitPool benchUnitPool)
 {
     _benchUnitPool = benchUnitPool;
 }