Ejemplo n.º 1
0
        private void ExecuteOpenSavegame(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            var savegame = parameter as SavegameModel;

            if (savegame == null)
            {
                throw new ArgumentException("parameter");
            }

            SavegameFile.ReadAsync(savegame.Path, Progress)
            .ContinueWith(t =>
            {
                var file = t.Result;
                var savegameDataModel = new SavegameDataModel
                {
                    Version1      = file.TypeCode1,
                    Version2      = file.TypeCode2,
                    Version3      = file.TypeCode3,
                    VariableNames = new ObservableCollection <string>(file.VariableNames),
                    Variables     = new ObservableCollection <VariableModel>(file.Variables.Select(ToVariableModel))
                };
                SelectedSavegame = new SavegameModel
                {
                    Name = savegame.Name,
                    Path = savegame.Path,
                    Data = savegameDataModel
                };
            });
        }
Ejemplo n.º 2
0
        public SavegameModel CreateNewSavegame()
        {
            var mineSavegame = new MineSavegame {
                NumberCorridor = 3
            };
            var corridorSavegame = new CorridorSavegame {
                Level = 1
            };
            var savegameModel = new SavegameModel {
                CorridorSavegame = corridorSavegame, MineSavegame = mineSavegame
            };

            return(savegameModel);
        }
Ejemplo n.º 3
0
        public SavegameSaver(SavegameModel savegame,
                             [Inject(Id = "SavePath")] string savePath,
                             [Inject(Id = "SaveInterval")] TimeSpan saveInterval)
        {
            if (savegame == null)
            {
                throw new ArgumentNullException("savegame");
            }
            if (savePath == null)
            {
                throw new ArgumentNullException("savePath");
            }

            _savegame     = savegame;
            _savePath     = savePath;
            _saveInterval = saveInterval;
        }