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
 }
        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>();
        }
Exemple #3
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 #4
0
 public DespawnUnitCommand(DespawnUnitData data,
                           ICommandFactory commandFactory,
                           IMutableUnitRegistry unitRegistry,
                           IGridUnitManager gridUnitManager,
                           IUnitDataIndexResolver indexResolver,
                           IUnitPool unitPool,
                           ILogger logger)
 {
     _data            = data;
     _commandFactory  = commandFactory;
     _unitRegistry    = unitRegistry;
     _gridUnitManager = gridUnitManager;
     _indexResolver   = indexResolver;
     _unitPool        = unitPool;
     _logger          = logger;
 }
Exemple #5
0
 public SpawnUnitCommand(SpawnUnitData data,
                         ICommandFactory commandFactory,
                         IUnitSpawnSettings unitSpawnSettings,
                         IMutableUnitRegistry unitRegistry,
                         IGridUnitManager gridUnitManager,
                         IUnitPool unitPool,
                         ILogger logger)
 {
     _data              = data;
     _commandFactory    = commandFactory;
     _unitSpawnSettings = unitSpawnSettings;
     _unitRegistry      = unitRegistry;
     _gridUnitManager   = gridUnitManager;
     _unitPool          = unitPool;
     _logger            = logger;
 }