public Savegame(List<String[]> gamevariables, List<Item> inventory, Maps map) { Name = ""; Playerpos = new Vector2(0, 0); CurrentRoom = map.name; Inventory = new List<String>(); foreach (Item item in inventory) { Inventory.Add(item.Name); } MapSaves = new List<MapSave>(); MapSaves.Add(new MapSave(map.name, map.introplayed, map.getObjects())); GVName = new List<String>(); GVValue = new List<String>(); GVName.Clear(); GVValue.Clear(); foreach (String[] str in gamevariables) { GVName.Add(str[0]); GVValue.Add(str[1]); } }
public void PrepareSave(String name, List<String[]> gamevariables, List<Item> inventory, Vector2 playerpos, Maps map) { Name = name; Playerpos = playerpos; CurrentRoom = map.name; Inventory.Clear(); foreach (Item item in inventory) { Inventory.Add(item.Name); } bool alreadyexists = false; MapSave oldSave = null; // Check if the object is has already been saved foreach (MapSave save in MapSaves) { if (save.name == map.name) { alreadyexists = true; oldSave = save; } } // if it has, remove the old one: if (alreadyexists) { MapSaves.Remove(oldSave); } // Put current map in the list MapSaves.Add(new MapSave(map.name, map.introplayed, map.getObjects())); GVName.Clear(); GVValue.Clear(); foreach (String[] str in gamevariables) { GVName.Add(str[0]); GVValue.Add(str[1]); } }