コード例 #1
0
    private void Start()
    {
        if (!instance)
        {
            instance = true;
        }
        else
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);
        playerScore = 0;
        //print(Application.persistentDataPath);
        if (SaveFiles.JsonFileExistsAtPersPath("PlayerScore"))//if there is a player score file already
        {
            playerScoreManager = SaveFiles.LoadObjectFromJSONFile <PlayerScoreManagerFile>("PlayerScore");
            topPlayerScore     = playerScoreManager.TopPlayerScore;//load the top score from it
        }
        else
        {
            playerScoreManager.TopPlayerScore = 0;
            topPlayerScore = 0;
            SaveFiles.SaveObjectAsJSONAtPersDataPath(playerScoreManager, "PlayerScore");//make a new player score file
        }

        scoreTxt.text = playerScoreManager.TopPlayerScore.ToString();//show it on the screen
    }
コード例 #2
0
 private void Start()
 {
     if (SaveFiles.JsonFileExistsAtPersPath(SaveFilesName.UnlockedBalls))//if there is a player score file already
     {
         unlockedBalls = SaveFiles.LoadObjectFromJSONFile <UnlockedBallsFile>(SaveFilesName.UnlockedBalls);
         UnLockBall(unlockedBalls);
     }
     else
     {
         SaveFiles.SaveObjectAsJSONAtPersDataPath(unlockedBalls, SaveFilesName.UnlockedBalls);//make a new player score file
     }
 }
コード例 #3
0
    public static float GetTopScore()
    {
        PlayerScoreManagerFile playerScoreManager = new PlayerScoreManagerFile();

        if (SaveFiles.JsonFileExistsAtPersPath("PlayerScore"))//if there is a player score file already
        {
            playerScoreManager = SaveFiles.LoadObjectFromJSONFile <PlayerScoreManagerFile>("PlayerScore");
            return(playerScoreManager.TopPlayerScore);//load the top score from it
        }
        else
        {
            playerScoreManager.TopPlayerScore = 0;
            SaveFiles.SaveObjectAsJSONAtPersDataPath(playerScoreManager, "PlayerScore");//make a new player score file
            return(0);
        }
    }