Esempio n. 1
0
    public ProgressData LoadProgress(string nameData)
    {
        BinaryFormatter bf = new BinaryFormatter();

        try
        {
            FileStream           file     = File.Open(Application.persistentDataPath + "/" + nameData + ".dat", FileMode.Open);
            ProgressSerializable progress = new ProgressSerializable();
            progress = (ProgressSerializable)bf.Deserialize(file);
            ProgressData progressData = new ProgressData();
            progressData.enemysDead       = progress.enemysDead;
            progressData.tutorialComplete = progress.tutorialComplete;
            progressData.animHeart1       = progress.animHeart1;
            progressData.posiCam          = progress.posiCam;
            progressData.positionCam      = progress.positionCam;
            progressData.wayLesteP1       = progress.wayLesteP1;
            progressData.wayLesteP2       = progress.wayLesteP2;
            progressData.wayLesteP3       = progress.wayLesteP3;
            progressData.wayLesteP4       = progress.wayLesteP4;
            progressData.wayLesteP5       = progress.wayLesteP5;
            progressData.wayLestePilar    = progress.wayLestePilar;
            Vector3 vector = new Vector3(progress.lesteSavePositon[0], progress.lesteSavePositon[1], progress.lesteSavePositon[2]);
            progressData.lesteSavePositon = vector;
            file.Close();
            Debug.Log(nameData + " Encontrado");
            return(progressData);
        }
        catch (System.Exception)
        {
            ProgressData progressData = new ProgressData();
            SaveProgress(progressData, nameData);
            return(progressData);
        }
    }
Esempio n. 2
0
    public void SaveProgress(ProgressData progress, string nameData)
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream      file;

        try
        {
            file = File.Open(Application.persistentDataPath + "/" + nameData + ".dat", FileMode.Open);
        }
        catch (System.Exception)
        {
            file = File.Open(Application.persistentDataPath + "/" + nameData + ".dat", FileMode.Create);
        }
        ProgressSerializable serializable = new ProgressSerializable();

        serializable.enemysDead       = progress.enemysDead;
        serializable.tutorialComplete = progress.tutorialComplete;
        serializable.animHeart1       = progress.animHeart1;
        serializable.posiCam          = progress.posiCam;
        serializable.positionCam      = progress.positionCam;
        serializable.wayLesteP1       = progress.wayLesteP1;
        serializable.wayLesteP2       = progress.wayLesteP2;
        serializable.wayLesteP3       = progress.wayLesteP3;
        serializable.wayLesteP4       = progress.wayLesteP4;
        serializable.wayLesteP5       = progress.wayLesteP5;
        serializable.wayLestePilar    = progress.wayLestePilar;
        Vector3 vector3 = progress.lesteSavePositon;

        serializable.lesteSavePositon[0] = vector3.x;
        serializable.lesteSavePositon[1] = vector3.y;
        serializable.lesteSavePositon[2] = vector3.z;
        bf.Serialize(file, serializable);
        file.Close();
        Debug.Log(nameData + " Salvo");
    }