// Loads the image number for all the objects in the new room from the previously saved (in the scripthandler in the TELEPORT command) Autosave file // Used when entering a previously entered room public void LoadObjStat() { //Find the path to all the saves string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Substring(6, path.Length - 6); // Getting rid of the file:\ it puts in front of the path with the above line string relPath = System.IO.Path.Combine(path + "\\savegames\\", "Autosave"); save = (Savegame)Savegame.Load(relPath, typeof(Savegame)); if (save == null) { save = new Savegame(proj.GetGlobalVariables(), player.InvList, map); Console.WriteLine("OH OH! Autosave could not be loaded!"); } //Load everything into all of the variables! foreach (MapSave mapy in save.MapSaves) { //THE MAP LAYER if (mapy.name == map.name) { map.introplayed = mapy.introplayed; //THE OBJECT LAYER foreach (Object obj in map.getObjects()) { foreach (ObjectSave objsv in mapy.objectsaves) { if (obj.name == objsv.name) { obj.imagenum = objsv.imagenum; obj.visible = objsv.visible; obj.walkable = objsv.walkable; //THE SCRIPT LAYER foreach (ScriptSave scrsv in objsv.scriptsaves) { foreach (Script scr in obj.scripts) { if (scrsv.name == scr.Name) { scr.Active = scrsv.active; } } } } } } } } }
public void LoadSave(String Filename, bool Startup = false) { //Find the path to all the saves string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Substring(6, path.Length - 6); // Getting rid of the file:\ it puts in front of the path with the above line string relPath = System.IO.Path.Combine(path + "\\savegames\\", Filename); save = (Savegame)Savegame.Load(relPath, typeof(Savegame)); if (save == null) { save = new Savegame(proj.GetGlobalVariables(), player.InvList, map); Console.WriteLine("OH OH! Save could not be loaded!"); } //Load all the stuff string relPath2 = System.IO.Path.Combine(path + "\\saves\\", save.CurrentRoom); LoadMap(relPath2, Startup); player.InvList.Clear(); foreach (String itemname in save.Inventory) { Item coolitem = items.FindItem(itemname); if (coolitem != null) player.InvList.Add(coolitem); } int counter = 0; foreach (String[] GV in GameVariables) { foreach (String VarName in save.GVName) { if (VarName == GV[0]) GV[1] = save.GVValue[counter]; } counter++; } // Load Player Position player.position = save.Playerpos; //Load everything into all of the variables! foreach (MapSave mapy in save.MapSaves) { //THE MAP LAYER if (mapy.name == map.name) { map.introplayed = mapy.introplayed; //THE OBJECT LAYER foreach (Object obj in map.getObjects()) { foreach (ObjectSave objsv in mapy.objectsaves) { if (obj.name == objsv.name) { obj.imagenum = objsv.imagenum; obj.visible = objsv.visible; obj.walkable = objsv.walkable; //THE SCRIPT LAYER foreach (ScriptSave scrsv in objsv.scriptsaves) { foreach (Script scr in obj.scripts) { if (scrsv.name == scr.Name) { scr.Active = scrsv.active; } } } } } } } } // If the map has a background song, play it now! if (map.backgroundmusic != null) { //sound.LoadMusic(map.backgroundmusic, Content); //It loads all the music at the beginning of the game anyway! sound.PlayMusic(map.backgroundmusic); } else sound.StopMusic(); }
private void InitializeContent() { map = new Maps(); if (FirstRoom != "") { string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Substring(6, path.Length - 6); // Getting rid of the file:\ it puts in front of the path with the above line string relPath = System.IO.Path.Combine(path + "\\saves\\", FirstRoom); LoadMap(relPath, true); } else { //Test-Walkmaps map.AddWalkRect(new Rectangle(174, 101, 271, 183)); map.AddWalkRect(new Rectangle(174, 258, 71, 149)); } player = new Player(); items = new Itemhandler(); GameVariables = new List<String[]>(); proj = new Project(Projectname, GameVariables, items.ReturnItemList()); save = new Savegame(proj.GetGlobalVariables(), player.InvList, map); LoadProjectfile(); Editor = new Form1(this); NewWalkMap = new Rectangle(0, 0, 0, 0); Snapshots = new List<Snapshot>(); }