Ejemplo n.º 1
0
 void DeleteAllSaves()
 {
     for (int i = 0; i < SaveGame.MaxSaveSlots; i++)
     {
         SaveGame.DeleteSave(i, user);
     }
 }
Ejemplo n.º 2
0
 void DestroyProgress()
 {
     if (!available)
     {
         return;
     }
     SaveGame.DeleteSave();
     SceneManager.LoadScene(0);
 }
Ejemplo n.º 3
0
        void DeleteAllSaves()
        {
            var user = SaveGame.CurrentUser;

            for (int i = 0; i < SaveGame.MaxSaveSlots; i++)
            {
                SaveGame.DeleteSave(i, user);
            }
        }
Ejemplo n.º 4
0
    /// <summary>
    ///  This methods saves the game
    /// </summary>
    public void SaveGame()
    {
        if (_DEBUG)
        {
            Debug.Log("Saving");
        }
        // assign in-game data to save data object; like health, weapons etc
        GameData toBeSaved    = this.runningGame;
        Helper   load         = new Helper();
        int      currentScene = load.FindSceneLoaderInScene().GetCurrentScene();

        //Stores Relevant Game Data
        toBeSaved.playerHealth = load.FindPlayerHealthInScene().GetCurrentHealth();
        toBeSaved.timeOfDay    = load.GetDayControllerInScene().GetDayCycle().ToString();

        toBeSaved.WriteToSave(this.FindPlayerPositionFromTag("Player"), currentScene);

        // save ingame high score
        if (toBeSaved.keepHighScore)
        {
            GameData hsData = new GameData();
            // checking for largest score is done when creating new game
            hsData.highscore = toBeSaved.highscore;
            SaveGame highScoreSave = new SaveGame(hsData);
            highScoreSave.SaveToFile(SaveType.Highscore);
        }
        else
        {
            SaveGame highScoreDeleter = new SaveGame();
            highScoreDeleter.DeleteSave(SaveType.Highscore);
        }

        SaveGame defaultSave = new SaveGame(toBeSaved);

        if (!(defaultSave.SaveToFile(SaveType.Json)))
        {
            if (_DEBUG)
            {
                Debug.Log("Saved game went wrong");
            }
        }
        else
        {
            Helper    pauseMenu = new Helper();
            PauseMenu menu      = pauseMenu.FindPauseMenuInScene();
            menu.DisplaySuccessfulSave(true);
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// This function resets the game data, and also deletes the save json
    /// file if present. It will retain high score value if set in GameData
    /// value
    /// </summary>
    public void ResetGame()
    {
        // needed to load hs from file, because gamedata has 0 score if
        // the player just started the game
        SaveGame hsImporter = new SaveGame();
        GameData hsData     = hsImporter.LoadFromFile(SaveType.Highscore);

        if (this.runningGame.keepHighScore)
        {
            // import new highscore if higher than older saved hs
            if (this.runningGame.highscore < hsData.highscore)
            {
                this.runningGame.highscore = hsData.highscore;
            }

            // store the highscore value
            SaveGame saveHighScore = new SaveGame(hsData);
            hsData.keepHighScore = true; //must be true to reimport
            saveHighScore.SaveToFile(SaveType.Highscore);
        }
        else
        {
            hsData.keepHighScore = false;
            SaveGame deleteHs = new SaveGame();
            deleteHs.DeleteSave(SaveType.Highscore);
        }

        // Overwrite and reset data
        this._enemyObjects   = new List <NPC>();
        this._scenePlayerPos = new Dictionary <int, Vector3>();
        this.runningGame     = new GameData();
        ResetPlayerHasVisited();
        SaveGame deleteSave = new SaveGame();

        if (deleteSave.SaveExists(SaveType.Json))
        {
            deleteSave.DeleteSave(SaveType.Json);
        }

        // reimport hs state and hs value from hs save
        if (hsData.keepHighScore)
        {
            this.runningGame.keepHighScore = hsData.keepHighScore;
            this.runningGame.highscore     = hsData.highscore;
        }
    }
Ejemplo n.º 6
0
 public void GoStart()
 {
     SaveGame.DeleteSave();
     StartToMain = false;
     SceneManager.LoadScene(0);
 }