Пример #1
0
        private bool IsValidDropPos(Point tileDelta, IMapEditingService mapEditingService, bool createCopy)
        {
            // We now need to verify that, given the specified tile delta, the selected items will
            // not drop on any item or building that is not itself currently selected.

            foreach (var selectedItem in selectionService.SelectedItems)
            {
                for (int x = selectedItem.Bounds.X + tileDelta.X; x < selectedItem.Bounds.Right + tileDelta.X; x++)
                {
                    for (int y = selectedItem.Bounds.Y + tileDelta.Y; y < selectedItem.Bounds.Bottom + tileDelta.Y; y++)
                    {
                        // Deal with the case where this tile will drop on an item that is to be
                        // moved...
                        if (!createCopy && selectionService.SelectedItems.Any(i => i.Bounds.Contains(x, y)))
                        {
                            continue;
                        }

                        if (mapEditingService.IsOccupied(new Point(x, y)))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
        public ConstructInspectorViewModel(IDataGetRepository <IInspectable> currentInspectableGetRepository,
                                           IMapGetService mapGetService,
                                           IMapEditingService mapEditingService)
        {
            ConstructDataLiveData = new LiveData <ConstructData>();
            VisibilityLiveData    = new LiveData <bool>();

            _disposable = new CompositeDisposable
            {
                currentInspectableGetRepository.GetObservableStream()
                .SubscribeOn(NoobSchedulers.ThreadPool)
                .ObserveOn(NoobSchedulers.MainThread)
                .Subscribe(OnInspectableUpdate),

                mapGetService.GetObservableStream()
                .SubscribeOn(NoobSchedulers.ThreadPool)
                .ObserveOn(NoobSchedulers.MainThread)
                .Subscribe(OnNewMapCreated),

                mapEditingService.ModifiedEventStream
                .SubscribeOn(NoobSchedulers.ThreadPool)
                .ObserveOn(NoobSchedulers.MainThread)
                .Subscribe(_ => OnMapEdited())
            };
        }
Пример #3
0
 public DeleteItemStep(Item item, Point location, IMapEditingService service)
 {
     this.item = new Item();
     this.item.CopyFrom(item);
     this.location = location;
     this.service  = service;
 }
        public StrongholdInspectorViewModel(IDataGetRepository <IInspectable> currentInspectableGetRepository,
                                            IMapGetService mapGetService,
                                            ILevelEditingService levelEditingService,
                                            IInGameMessageService inGameMessageService,
                                            IMapEditingService mapEditingService)
        {
            _levelEditingService   = levelEditingService;
            _inGameMessageService  = inGameMessageService;
            StrongholdDataLiveData = new LiveData <StrongholdData>();
            VisibilityLiveData     = new LiveData <bool>();

            _disposable = new CompositeDisposable
            {
                currentInspectableGetRepository.GetObservableStream()
                .SubscribeOn(NoobSchedulers.ThreadPool)
                .ObserveOn(NoobSchedulers.MainThread)
                .Subscribe(OnInspectableUpdate),

                mapGetService.GetObservableStream()
                .SubscribeOn(NoobSchedulers.ThreadPool)
                .ObserveOn(NoobSchedulers.MainThread)
                .Subscribe(OnNewMapCreated),

                mapEditingService.ModifiedEventStream
                .SubscribeOn(NoobSchedulers.ThreadPool)
                .ObserveOn(NoobSchedulers.MainThread)
                .Subscribe(_ => OnMapModified())
            };
        }
Пример #5
0
 public MapToolContext(Rectangle viewRect, int tileSize, Point viewCentre, IMapViewport viewport,
                       IMapEditingService mapEditingService)
     : base(viewRect, tileSize, viewCentre)
 {
     this.MapEditingService = mapEditingService;
     Viewport = viewport;
 }
Пример #6
0
 public SetUpStrongholdInMapCommand(IMapEditingService mapEditingService,
                                    IMapGetService mapGetService,
                                    Coordinate coordinate)
 {
     _mapEditingService = mapEditingService;
     _mapGetService     = mapGetService;
     _coordinate        = coordinate;
 }
Пример #7
0
 public static IObservable<Unit> DestructStrongholdInMap(Coordinate coordinate,
                                                         IMapEditingService mapEditingService,
                                                         IMapGetService mapGetService)
 {
     return mapGetService.GetMostRecent()
         .SelectMany(
             m => mapEditingService.DestructStronghold(m, coordinate)
         );
 }
 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;
 }
Пример #9
0
 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;
 }