public UpdateTowersAndWallsAvailableScrap(TowersAggregate towers, WallsAggregate walls, ScrapWalletAggregate scrapWallet)
 {
     scrapWallet.Events
     .OfType <ScrapWalletEvent, ScrapWalletEvent.AvailableScrapChanged>()
     .Subscribe(changed =>
     {
         towers.UpdateAvailableScrap(changed.CurrentAmount);
         walls.UpdateAvailableScrap(changed.CurrentAmount);
     });
 }
Example #2
0
    private void InitilizeWalls(MapEvent.Initialized initialized, WallsAggregate walls)
    {
        var mapCoords = Enumerable.Range(0, initialized.MapCells.GetLength(0)).SelectMany(x => Enumerable.Range(0, initialized.MapCells.GetLength(1)).Select(y => new MapCoordinate(x, y)));

        var initialWalls = mapCoords
                           .Where(coord => initialized.MapCells[coord.X, coord.Y] is WallCell)
                           .Select(coord => new WallParameters(coord))
                           .ToArray();

        walls.Initialize(initialWalls);
    }
Example #3
0
 public DecreaseScrapWhenWallRepaired(WallsAggregate walls, ScrapWalletAggregate scrapWallet, RepairCosts repairCosts)
 {
     walls.Events
     .OfType <WallsEvent, WallsEvent.WallRepaired>()
     .Subscribe(_ => scrapWallet.Decrease(repairCosts.Wall));
 }
Example #4
0
 public InitializeWallsWhenMapInitialized(MapAggregate map, WallsAggregate walls)
 {
     map.Events
     .OfType <MapEvent, MapEvent.Initialized>()
     .Subscribe(initialized => InitilizeWalls(initialized, walls));
 }
 public RepairWallsWhenMapCellClicked(MapAggregate map, WallsAggregate walls)
 {
     map.Events
     .OfType <MapEvent, MapEvent.MapCellClicked>()
     .Subscribe(clicked => RepairWalls(clicked, walls));
 }
 private void RepairWalls(MapEvent.MapCellClicked clicked, WallsAggregate walls)
 {
     walls.Repair(clicked.Coordinate);
 }
Example #7
0
 public NotifyPathAggregateWhenCellsAreOccupied(MapAggregate map, TowersAggregate tower, WallsAggregate wall,
                                                [NotNull] PathFinderAggregate pathFinder)
 {
     _pathFinder = pathFinder ?? throw new ArgumentNullException(nameof(pathFinder));
     map.Events.OfType <MapEvent, MapEvent.Initialized>().Subscribe(HandleMapInitialized);
     tower.Events.OfType <TowersEvent, TowersEvent.TowerRepaired>().Subscribe(HandleTowerRepaired);
     wall.Events.OfType <WallsEvent, WallsEvent.WallRepaired>().Subscribe(HandleWallRepaired);
 }