public UpdateTowersAndWallsAvailableScrap(TowersAggregate towers, WallsAggregate walls, ScrapWalletAggregate scrapWallet) { scrapWallet.Events .OfType <ScrapWalletEvent, ScrapWalletEvent.AvailableScrapChanged>() .Subscribe(changed => { towers.UpdateAvailableScrap(changed.CurrentAmount); walls.UpdateAvailableScrap(changed.CurrentAmount); }); }
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); }
public DecreaseScrapWhenWallRepaired(WallsAggregate walls, ScrapWalletAggregate scrapWallet, RepairCosts repairCosts) { walls.Events .OfType <WallsEvent, WallsEvent.WallRepaired>() .Subscribe(_ => scrapWallet.Decrease(repairCosts.Wall)); }
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); }
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); }