public void LoadSaveGame_FileNotFound_ReturnsFileNotFoundErrorText(
            [Frozen] IMainModel model,
            [Frozen] IBackupService backupService,
            [Frozen] IRemoveWaggonsService removeWaggonsService,
            [Frozen] IMoveObjectsService moveObjectsService,
            [Frozen] IMoveTracksService moveTracksService,
            [Frozen] IMoveWaggonsService moveWaggonsService,
            string filePath
            )
        {
            //Arrange

            var mockedFileSystem = new MockFileSystem();

            model.FileName.Returns(filePath);
            var sut = new SavegameService(model, backupService, removeWaggonsService, moveObjectsService, moveTracksService, moveWaggonsService, mockedFileSystem);

            //Act
            var result = sut.LoadSavegame();

            result.Should().Be($"Error: File {filePath} not Found.");
            model.FileContent.Should().BeEmpty();

            backupService.ReceivedCalls().Should().BeEmpty();
            removeWaggonsService.ReceivedCalls().Should().BeEmpty();
        }
예제 #2
0
        public SettingsModel(SavegameService savegameService)
        {
            var settings = savegameService.Settings;

            IsMusicMuted   = settings.IsMusicMuted;
            IsEffectsMuted = settings.IsEffectsMuted;
        }
        public void LoadSaveGame_FileCanBeReadWithoutError_ReturnsEmptyString(
            [Frozen] IMainModel model,
            [Frozen] IBackupService backupService,
            [Frozen] IRemoveWaggonsService removeWaggonsService,
            [Frozen] IMoveObjectsService moveObjectsService,
            [Frozen] IMoveTracksService moveTracksService,
            [Frozen] IMoveWaggonsService moveWaggonsService,
            string fileContent,
            string filePath
            )
        {
            //Arrange

            var mockedFileSystem  = new MockFileSystem();
            var mockedFileContent = new MockFileData(fileContent);

            mockedFileSystem.AddFile(filePath, mockedFileContent);
            model.FileName.Returns(filePath);
            var sut = new SavegameService(model, backupService, removeWaggonsService, moveObjectsService, moveTracksService, moveWaggonsService, mockedFileSystem);

            //Act
            var result = sut.LoadSavegame();

            result.Should().BeEmpty();
            model.FileContent.Should().Be(fileContent);

            backupService.ReceivedCalls().Should().BeEmpty();
            removeWaggonsService.ReceivedCalls().Should().BeEmpty();
        }
예제 #4
0
        public ProfileModel(SavegameService savegameService)
        {
            var profile = savegameService.Profile;

            Currency     = profile.Currency;
            BestDistance = profile.BestDistance;
            RoundsPlayed = profile.RoundsPlayed;
        }
예제 #5
0
        public static async Task <IEnumerable <StructuresViewModel> > ReadStructures(string mapName, string filename)
        {
            GameObjectContainer gameObjectContainer = filename != null ? await SavegameService.GetGameObjectsForFile(filename) : await SavegameService.GetGameObjects(mapName);

            return(extractStructures(gameObjectContainer, MapData.For(mapName))
                   .OrderBy(s => s.Key)
                   .Select(structureLine =>
                           new StructuresViewModel(structureLine.Key.Item1, structureLine.Key.Item2, structureLine.Count(), structureLine.Key.Item3, structureLine.ToList())));
        }
예제 #6
0
        public UpgradesModel(SavegameService savegameService)
        {
            var upgrades = savegameService.Upgrades;

            MaxVelocityLevel = upgrades.MaxVelocityLevel;
            KickForceLevel   = upgrades.KickForceLevel;
            ShootForceLevel  = upgrades.ShootForceLevel;
            ShootCountLevel  = upgrades.ShootCountLevel;
        }
예제 #7
0
        public PlayerModel(SavegameService savegameService)
        {
            var upgrades = savegameService.Upgrades;

            KickForce    = UpgradeTree.KickForcePath.ValueAt(upgrades.KickForceLevel.Value);
            ShootForce   = UpgradeTree.ShootForcePath.ValueAt(upgrades.ShootForceLevel.Value);
            Shots        = UpgradeTree.ShootCountPath.ValueAt(upgrades.ShootCountLevel.Value);
            MaxVelocityX = UpgradeTree.MaxVelocityPath.ValueAt(upgrades.MaxVelocityLevel.Value);
            MaxVelocityY = UpgradeTree.MaxVelocityPath.ValueAt(upgrades.MaxVelocityLevel.Value);
        }
        public ShopConfirmResetController(ShopConfirmResetView view, ShopModel shopModel, SavegameService savegameService, SceneTransitionService sceneTransitionService)
            : base(view)
        {
            _view = view;
            _view.Initialize();

            _shopModel              = shopModel;
            _savegameService        = savegameService;
            _sceneTransitionService = sceneTransitionService;

            _shopModel.OpenConfirmReset
            .Subscribe(_ => Open())
            .AddTo(Disposer);

            _view.OnResetConfirmClicked
            .Subscribe(_ => OnResetConfirmed())
            .AddTo(Disposer);
        }
예제 #9
0
        public TutorialController(TutorialView view, TitleModel model, SceneTransitionService sceneTransitionService, SavegameService savegameService)
            : base(view)
        {
            _view = view;
            _view.Initialize();

            _sceneTransitionService = sceneTransitionService;
            _savegameService        = savegameService;

            _view.OnNextClickedOnLastSlide
            .Subscribe(_ => OnNextClickedOnLastSlide())
            .AddTo(Disposer);

            _model = model;
            _model.OpenTutorial
            .Subscribe(_ => Open())
            .AddTo(Disposer);
        }
예제 #10
0
        public static async Task <IEnumerable <StructureViewModel> > ReadStructuresFlat(string mapName, string filename)
        {
            GameObjectContainer gameObjectContainer = filename != null ? await SavegameService.GetGameObjectsForFile(filename) : await SavegameService.GetGameObjects(mapName, true);

            MapData mapData = MapData.For(mapName);

            return(gameObjectContainer
                   .Where(o => !o.IsCreature() && !o.IsDeathItemCache() && o.IsTamed() && (o.HasAnyProperty("OwningPlayerID") || o.HasAnyProperty("OwnerName")))
                   .Select(gameObject => {
                double lat = 0, lon = 0;
                if (gameObject.Location != null)
                {
                    lon = gameObject.Location.X / mapData.LonDiv + mapData.LonShift;
                    lat = gameObject.Location.Y / mapData.LatDiv + mapData.LatShift;
                }

                bool hidden = gameObject.GetPropertyValue <bool>("IsHidden");
                return new StructureViewModel((float)Math.Round(lat, 2), (float)Math.Round(lon, 2), hidden, gameObject);
            }));
        }
예제 #11
0
        public static async Task <List <GameObject> > ReadTames(string mapName, string filename)
        {
            GameObjectContainer gameObjectContainer = filename != null ? await SavegameService.GetGameObjectsForFile(filename) : await SavegameService.GetGameObjects(mapName);

            return(extractTames(gameObjectContainer).ToList());
        }
예제 #12
0
        public TitleModel(SavegameService savegameService)
        {
            var profile = savegameService.Profile;

            IsFirstStart = profile.IsFirstStart;
        }