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); }
void Update() { //Handle clicks if (Input.GetMouseButtonDown(0)) { Vector3 clickedPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); var xCoordinate = (int)Math.Round(clickedPosition.x); var yCoordinate = (int)Math.Round(clickedPosition.y); MapAggregate.ClickMapCell(xCoordinate, yCoordinate); } }
public RepairTowersWhenMapCellClicked(MapAggregate map, TowersAggregate Towers) { map.Events .OfType <MapEvent, MapEvent.MapCellClicked>() .Subscribe(clicked => RepairTowers(clicked, Towers)); }
public InitializeWallsWhenMapInitialized(MapAggregate map, WallsAggregate walls) { map.Events .OfType <MapEvent, MapEvent.Initialized>() .Subscribe(initialized => InitilizeWalls(initialized, walls)); }
public InitializeTowersWhenMapInitialized(MapAggregate map, TowersAggregate towers) { map.Events .OfType <MapEvent, MapEvent.Initialized>() .Subscribe(initialized => InitializeTowers(initialized, towers)); }
private void CreateLevel() { MapAggregate.Initialize(BOARD_SIZE, BOARD_SIZE); }
public RepairWallsWhenMapCellClicked(MapAggregate map, WallsAggregate walls) { map.Events .OfType <MapEvent, MapEvent.MapCellClicked>() .Subscribe(clicked => RepairWalls(clicked, walls)); }