Beispiel #1
0
        //we cannot use replay subject here - it kills our test
        public MapGetService(IMapConfigRepository mapConfigRepository,
                             IBoardItemsGetRepository <Tile> tilesRepository,
                             IBoardItemsGetRepository <Unit> unitsRepository,
                             IBoardItemsGetRepository <Construct> constructsRepository,
                             IBoardItemsGetRepository <Stronghold> strongholdsRepository)
        {
            _mapSingle  = Observable.Throw <Map>(new InvalidOperationException($"Value is not set yet for {GetType().Name}"));
            _mapSubject = new ReplaySubject <Map>(1);

            var groupedItemsObservableStream = CreateGroupedItemsObservableStream(
                tilesRepository,
                unitsRepository,
                constructsRepository,
                strongholdsRepository
                );

            _disposable = mapConfigRepository.GetObservableStream()
                          .CombineLatest(
                groupedItemsObservableStream,
                (config, itemGroup) => (config, itemGroup.tiles, itemGroup.units, itemGroup.constructs, itemGroup.strongholds)
                )
                          .SubscribeOn(NoobSchedulers.ThreadPool)
                          .ObserveOn(NoobSchedulers.MainThread)
                          .Where(tuple => tuple.config != null)
                          .Subscribe(
                tuple =>
            {
                var(config, tiles, units, constructs, strongholds) = tuple;
                var map = new Map(tiles, units, constructs, strongholds, config);

                _mapSubject.OnNext(map);
                _mapSingle = Observable.Return(map);
            }
                );
        }
 public static IObservable <Unit> SetUpStrongholdInLevelData(Coordinate coordinate,
                                                             ILevelDataEditingService levelDataEditingService,
                                                             IMapConfigRepository mapConfigRepository,
                                                             ILevelDataRepository levelDataRepository) =>
 levelDataRepository.GetMostRecent()
 .Zip(mapConfigRepository.GetMostRecent(), (data, config) => (data, config))
 .SelectMany(tuple => levelDataEditingService.SetUpStronghold(tuple.data, tuple.config, coordinate));
        public GridOverlayViewModel(ICoordinateService coordinateService,
                                    IWorldConfigRepository loadedWorldConfigRepository,
                                    IMapConfigRepository mapConfigRepository,
                                    ITilesPositionService tilesPositionService,
                                    Transform centerTransform)
        {
            CoordinateVisibilityLiveData = new LiveData <bool>(true);
            GridVisibilityLiveData       = new LiveData <bool>(true);
            CellsCountLiveData           = new LiveData <int>();
            CellsPositionLiveData        = new LiveData <IReadOnlyList <Vector3> >();
            WorldConfigLiveData          = new LiveData <WorldConfig>();
            CoordinatesLiveData          = new LiveData <IReadOnlyList <Coordinate> >();

            _compositeDisposable = new CompositeDisposable
            {
                mapConfigRepository.GetObservableStream()
                .CombineLatest(
                    loadedWorldConfigRepository.GetObservableStream(),
                    tilesPositionService.GetObservableStream(centerTransform.position.y),
                    (mapConfig, worldConfig, positions) => (mapConfig, worldConfig, positions)
                    )
                .Subscribe(
                    tuple =>
                {
                    var(mapConfig, worldConfig, positions) = tuple;
                    var coordinates = coordinateService.GetFlattenCoordinates(mapConfig);

                    UpdateCellsCountsWhenNeeded(coordinates.Count);
                    UpdateCellsPositionWhenNeeded(positions);
                    UpdateWorldConfigWhenNeeded(worldConfig);
                    UpdateCoordinatesWhenNeeded(coordinates);
                }
                    )
            };
        }
 public DestructStrongholdInLevelCommand(ILevelDataEditingService levelDataEditingService,
                                         IMapEditingService mapEditingService,
                                         IMapConfigRepository mapConfigRepository,
                                         IMapGetService mapGetService,
                                         ILevelDataRepository levelDataRepository,
                                         Coordinate coordinate)
 {
     _levelDataEditingService = levelDataEditingService;
     _mapEditingService       = mapEditingService;
     _mapConfigRepository     = mapConfigRepository;
     _mapGetService           = mapGetService;
     _levelDataRepository     = levelDataRepository;
     _coordinate = coordinate;
 }
 public LevelEditingService(ILevelDataEditingService levelDataEditingService,
                            IMapEditingService mapEditingService,
                            IMapConfigRepository mapConfigRepository,
                            IMapGetService mapGetService,
                            ILevelDataRepository levelDataRepository,
                            ICommandExecutionService commandExecutionService)
 {
     _levelDataEditingService = levelDataEditingService;
     _mapEditingService       = mapEditingService;
     _mapConfigRepository     = mapConfigRepository;
     _mapGetService           = mapGetService;
     _levelDataRepository     = levelDataRepository;
     _commandExecutionService = commandExecutionService;
 }
Beispiel #6
0
        public TileSelectionViewModel(ICurrentHoveredTileHolderSetRepository hoveredTileHolderSetRepository,
                                      ICurrentSelectedTileHolderSetRepository currentSelectedTileHolderSetRepository,
                                      IDataSetRepository <IInspectable> currentInspectableSetRepository,
                                      IClosestTileHolderFromPositionService closestTileHolderFromPositionService,
                                      IMousePositionService mousePositionService,
                                      IMapConfigRepository loadedMapConfigRepository,
                                      IClickStatusService clickStatusService)
        {
            _hoveredTileHolderSetRepository       = hoveredTileHolderSetRepository;
            _currentInspectableSetRepository      = currentInspectableSetRepository;
            _closestTileHolderFromPositionService = closestTileHolderFromPositionService;
            _mousePositionService = mousePositionService;
            _clickStatusService   = clickStatusService;
            _currentSelectedTileHolderSetRepository = currentSelectedTileHolderSetRepository;

            _disposable = loadedMapConfigRepository.GetObservableStream()
                          .SubscribeOn(Scheduler.ThreadPool)
                          .ObserveOn(Scheduler.MainThread)
                          .Subscribe(UpdateHaveTilesOnScreen);
        }
 public TilesPositionService(IMapConfigRepository mapConfigRepository,
                             IWorldConfigRepository worldConfigRepository)
 {
     _mapConfigRepository   = mapConfigRepository;
     _worldConfigRepository = worldConfigRepository;
 }
Beispiel #8
0
 public TilesHolderService(IBoardItemHoldersFetchingService <TileHolder> tileHoldersFetchingService,
                           IMapConfigRepository loadedMapConfigRepository)
 {
     _tileHoldersFetchingService = tileHoldersFetchingService;
     _loadedMapConfigRepository  = loadedMapConfigRepository;
 }