Exemple #1
0
    public void InitSaveData()
    {
        playerComb = playerObj.GetComponent <PlayerCombatV1>();
        character  = playerObj.GetComponent <ICharacter>();


        if (File.Exists(Application.persistentDataPath + "/playerSavedata.test" /*Application.dataPath + "/savedata/HubData.test"*/))
        {
            hubSaveData = SaveSystem.Loadhubsavedata();
            character.GetInventory().SetCredits(hubSaveData.credits);
            Debug.Log("HubDataLoaded" + hubSaveData.credits);
        }
        else
        {
            hubSaveData = new HubSaveData(10);
            character.GetInventory().SetCredits(hubSaveData.credits);
        }

        if (File.Exists(Application.persistentDataPath + "/playerSavedata.test" /*Application.dataPath + "/savedata/autoSaveData.test"*/))
        {
            LoadAndSetPlayer(SaveSystem.LoadAutoSaveData());
        }
        else
        {
            CreateAutoSaveData();
        }

        playerComb.weapons[0] = character.GetActiveWeapon();
    }
Exemple #2
0
    public static void Savehubsavedata(HubSaveData data)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/playerSavedata.test";
        //string path2 = Application.dataPath + "/savedata/HubData.test"; //== This path is for testing. We should set a new path for an actual game
        FileStream stream = new FileStream(path, FileMode.Create);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemple #3
0
    public static HubSaveData Loadhubsavedata()
    {
        string path = Application.persistentDataPath + "/playerSavedata.test";

        //string path2 = Application.dataPath + "/savedata/HubData.test";
        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

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

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