Пример #1
0
        public static void SaveGame()
        {
            var summary       = new UserData.SaveGameSummary(_gameData, _currentLevel.LevelName);
            var saveGameState = new UserData.SaveGame(summary);

            saveGameState.CurrentTime = _currentTime;
            saveGameState.Player      = _player;

            saveGameState.CurrentLevelId = _currentLevel.LevelId;
            foreach (KeyValuePair <Levels.LevelId, Levels.Level> level in _levels)
            {
                saveGameState.Levels[level.Key] = level.Value.GetSaveDetails();
            }

            saveGameState.Furnishings = Entities.Furnishings.Furnishing.GetSaveData();
            saveGameState.Monsters    = Entities.Monsters.Monster.GetSaveData();

            Quests.GameEventManager.SaveData(saveGameState);

            saveGameState.TopLevelRNG = _topLevelRNG.GetSaveData();
            saveGameState.CombatRNG   = _combatRNG.GetSaveData();
            saveGameState.LootRNG     = _lootRNG.GetSaveData();
            saveGameState.MiscRNG     = _miscRNG.GetSaveData();

            UserDataManager.SaveGame(saveGameState);
        }
Пример #2
0
        public static void LoadGame(UserData.SaveGame gameState)
        {
            _topLevelRNG = new RandomNumberGenerator(gameState.TopLevelRNG);
            _combatRNG   = new RandomNumberGenerator(gameState.CombatRNG);
            _lootRNG     = new RandomNumberGenerator(gameState.LootRNG);
            _miscRNG     = new RandomNumberGenerator(gameState.MiscRNG);

            _gameData    = gameState.Summary.GameData;
            _currentTime = gameState.CurrentTime;
            _player      = gameState.Player;
            Entities.Player.Player.SetPlayer(_player);

            Entities.Furnishings.Furnishing.LoadSaveData(gameState.Furnishings);
            Entities.Monsters.Monster.LoadSaveData(gameState.Monsters);

            foreach (KeyValuePair <Levels.LevelId, Levels.LevelSaveSummary> level in gameState.Levels)
            {
                _levels[level.Key] = new Levels.Level(level.Value);
            }

            _currentLevel = _levels[gameState.CurrentLevelId];

            Quests.GameEventManager.LoadData(gameState);
        }