Beispiel #1
0
    public SaveableScene prepareNextScene(string sceneName, List <IRestorableGameObject> transferToNextScene, bool loadScene = true)
    {
        SaveableScene result = getScene(sceneName);

        FirstTimeSceneLoaded = !loadScene;
        ///check if the scene is loaded already
        if (result == null)
        {
            ///if the scene was not loaded, check if it is even existing as a file in the game folder
            if (sceneExists(sceneName))
            {
                ///if the scene exists in a file load it
                result = GameDataController.LoadSaveable <SaveableScene>(FolderSystem.getSceneSavePath(GameName, sceneName));
                /////create new Scene list. Since its marked as "NonSerialized" its null after loading
                //AllScenes = new List<SaveableScene>();
                addScene(result);
            }
            else
            {
                ///if the scene doesnt exist in file, create a new scene
                result = addNewScene(sceneName);
                ///since the scene was not existing already, "KeepExistingObjects"
                ///is set to true, as the scene objects
                ///should not be deleted when first entering a scene
                FirstTimeSceneLoaded = true;
            }
        }
        CurrentScene = result;
        CurrentScene.initiateLoadedScene();

        CurrentScene.TransferedObjectTree = transferToNextScene;
        return(result);
    }
Beispiel #2
0
    public void loadGame(GamePersistence gameDataController)
    {
        SaveableGame.GameDataController = gameDataController;

        SaveableScene loadedScene = GameDataController.LoadSaveable <SaveableScene>
                                        (FolderSystem.getSceneSavePath(GameName,
                                                                       CurrentSceneName));

        ///reset scene list so no changes made before loading are interfering
        AllScenes = new List <SaveableScene>();

        addScene(loadedScene);
        CurrentScene = loadedScene;
        CurrentScene.initiateLoadedScene();

        ///load new scene
        SceneManager.LoadScene(CurrentSceneName);
    }
Beispiel #3
0
    private void SaveGameAndScenesToFile(string saveName)
    {
        FolderSystem.createNewSaveSlotDirectory(saveName);

        ///save game
        Save(FolderSystem.getGameSavePath(currentGame.GameName), currentGame);

        ///create or overwrite all changed scenes
        foreach (SaveableScene s in currentGame.AllScenes)
        {
            ///if the scene exists, but was not changed since the last save, it doesnt need to be saved again
            if (s.DirtyData)
            {
                Save(FolderSystem.getSceneSavePath(currentGame, s.SceneName), s);
                s.DirtyData = false;
            }
        }
    }