Example #1
0
    // ========= PUBLIC METHODS =========

    // Attempts a continuation save and warns player if it isn't successful - returns true if successful, false otherwise
    public bool ContinuationSave()
    {
        if (!persistenceController.SaveGame(null))
        {
            warningType = SaveLoadType.CONTINUATION_SAVE;
            OpenWarningDialogue();
            return(false);
        }
        else
        {
            // Prepare a string for player prefs describing the continuation status for the current player
            string    gameStatus;
            ScoreMode scoreMode;

            if (CurrentGameStatus == GameStatus.PLAYING)
            {
                gameStatus = "Game in progress (Current score: ";
                scoreMode  = ScoreMode.INTERIM;
            }
            else
            {
                gameStatus = "Game ended (Final score: ";
                scoreMode  = ScoreMode.FINAL;
            }

            int[] score = scoreController.CalculateScore(scoreMode);
            PlayerPrefs.SetString("Player" + PlayerPrefs.GetInt("CurrentPlayer") + "Status", gameStatus + score[0] + " of a possible " + score[1] + " in " + Turns + " turn" + (Turns != 1 ? "s)" : ")"));
            return(true);
        }
    }
Example #2
0
 public void SaveAndExitGame()
 {
     PersistenceController.SaveGame();
     #if UNITY_EDITOR
     UnityEditor.EditorApplication.isPlaying = false;
     #else
     Application.Quit();
     #endif
 }