public bool Load() { ss.Clear(); bool itemsExist = ss.Load(Files.ITEMS_FNAME); ss.Clear(); if (!itemsExist) { Debug.Log("Creating new Items file"); items = new List <ShopItem>(); items.Add(new ShopItem("Groen shirt", 2, false, false, 1)); items.Add(new ShopItem("Groene broek", 3, false, false, 2)); ss.Clear(); ss.Add(items); ss.Save(Files.ITEMS_FNAME); ss.Clear(); } ss.Clear(); ss.Load(Files.ITEMS_FNAME); items = ss.GetObject <List <ShopItem> >(); ss.Clear(); return(items == null); }
/// <summary> /// Saves the playthrough to a file /// </summary> public static void SavePlayThrough() { //Prevent saving more than just the playthrough saveSystem.Clear(); saveSystem.Add(currentPlayThrough); saveSystem.Save(Files.PLAYTHROUGH_FNAME); saveSystem.Clear(); }
// Use this for initialization void Start() { SaveSystem ss = new SaveSystem(); TestData td1 = new TestData(1, 1, "test", 0.5f); TestData td2 = new TestData(1, 2, "test2", 3.5f); TestData2 td3 = new TestData2(1, "test3", 0.2f); /* * TestData2 td4 = new TestData2(2, "Totaal Niet Aangekwatst", 0.1f); * TestData2 td5 = new TestData2(3, "Totaal Niet Aangekwatst", 0.1f); * TestData2 td6 = new TestData2(4, "Totaal Niet Aangekwatst", 0.1f); * TestData2 td7 = new TestData2(5, "Totaal Niet Aangekwatst", 0.1f);*/ ss.Add(td1); ss.Add(td2); ss.Add(td3); /* * ss.Add(td4); * ss.Add(td5); * ss.Add(td6); * ss.Add(td7);*/ ss.Save(); //Saves all objects in the savesystem to a binary object. ss.Clear(); //Clears the objects in the savesystem. ss.Load(); // TestData2 l1 = ss.GetObject <TestData2>(); l1.Test1 = 1337; l1.Test3 = "Replaced"; //l1 = new TestData2(1, "test", 4); ss.Replace(l1); TestData2 r1 = ss.GetObject <TestData2>(); List <TestData> l2 = ss.GetObjects <TestData>(); List <object> objects = ss.GetObjects(); ss.RemoveAll <TestData>(); List <object> objects2 = ss.GetObjects(); Debug.Log("Did it works?"); /* * SaveSystem saveSystem = new SaveSystem(); //Verkrijgen instantie van het save systeem. * saveSystem.Clear(); //Legen van de buffer in saveSystem. (Leegt dus alle objecten, ze bestaan nog wel in de file vanwege het opslaan.) * TestData td = new TestData(1, 1, "test", 0.5f); * saveSystem.Add(td); //Een object toevoegen. * saveSystem.Save("Jou file naam"); //Jou object wordt opgeslagen naar een file met de door jou gegeven naam. * saveSystem.Clear(); //SaveSystem wordt geleegd dus er zit niks meer in. * saveSystem.Load("Jou file naam"); //Nu wordt het bestand wat je hebt opgeslagen ingeladen mits je de juiste filename geeft. * TestData Loaded = saveSystem.GetObject<TestData>(); //Verkrijg het bestand wat je had opgeslagen. */ }
public bool Load() { ss.Clear(); bool statsExist = ss.Load(Files.STATS_FNAME); if (!statsExist) { Debug.Log("Creating new Stats file"); stats = new List <Stats>(); levelDifficulty = 1; stats.Add(new Stats() { amountOfPlaythroughs = 0, levelDifficulty = this.levelDifficulty, coins = 0 }); stats.Add(new Stats() { categoryName = "1", handle = 0, hide = 0, fight = 0 }); stats.Add(new Stats() { categoryName = "2", handle = 0, hide = 0, fight = 0 }); stats.Add(new Stats() { categoryName = "3", handle = 0, hide = 0, fight = 0 }); stats.Add(new Stats() { categoryName = "4", handle = 0, hide = 0, fight = 0 }); ss.Clear(); ss.Add(stats); ss.Save(Files.STATS_FNAME); ss.Clear(); } if (ss.Load(Files.STATS_FNAME)) { stats = ss.GetObject <List <Stats> >(); if (stats != null) { foreach (Stats s in stats) { if (s.categoryName == null) { levelDifficulty = s.levelDifficulty; coins = s.coins; amountOfPlaythroughs = s.amountOfPlaythroughs; lastFinishedPlaythrough = s.lastFinishedPlaythrough; } } return(true); } else { return(false); } } else { return(false); } }
public void Save() { Target.Save.Nickname = CurrentNickname; SaveSystem.Add(Target.Save); SaveSystem.Save(); }