示例#1
0
    public static void SavePlayer(ScoringSystem player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.dat";

        FileStream stream = new FileStream(path, FileMode.Create);

        PLRData data = new PLRData(player);

        formatter.Serialize(stream, data);
        stream.Close();

        Debug.Log("Game Saved" + data);
    }
示例#2
0
    public void LoadPlayer()
    {
        PLRData data = SaveSystem.LoadPlayer();

        theGameScore        = data.score;
        numberOfAliensFound = data.aliensFound;
        currentScene        = data.activeScene;
        tutorialDialogDone  = data.tutorial;

        pointsCount.text = theGameScore.ToString();
        aliensCount.text = numberOfAliensFound.ToString();

        theScore       = theGameScore;
        numberOfAliens = numberOfAliensFound;

        Debug.Log("Loaded from " + theScore);
        Debug.Log("Loaded from " + numberOfAliens);

        SceneManager.LoadScene(currentScene);
    }
示例#3
0
    public static PLRData LoadPlayer()
    {
        string path = Application.persistentDataPath + "/player.dat";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            PLRData data = formatter.Deserialize(stream) as PLRData;
            stream.Close();

            Debug.Log("Game Loaded");

            return(data);
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return(null);
        }
    }