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 ScriptHandler(Maps newmap, Player newplayer, Itemhandler newitems, Game1 newgame = null) { activescript = new Script("null"); map = newmap; player = newplayer; items = newitems; game = newgame; IFstack = new List<bool>(); }
public Snapshot(List<String[]> gamevariables, Maps map, List<Object> objects, List<Item> Inventory) { Mapname = map.name; // Global Variables GVName = new List<string>(); GVValue = new List<string>(); foreach (String[] var in gamevariables) { GVName.Add(var[0]); GVValue.Add(var[1]); } // Objects snapjects = new List<SnapObject>(); foreach (Object obj in objects) { SnapObject snapj = new SnapObject(); snapj.name = obj.name; snapj.imagenum = obj.imagenum; snapj.color = obj.color; snapj.rect = obj.rect; snapj.walkable = obj.walkable; snapj.visible = obj.visible; snapj.opacity = obj.opacity; // Verbs foreach (Script script in obj.scripts) { snapj.VBName.Add(script.Name); snapj.VBactive.Add(script.Active); } snapjects.Add(snapj); } // Inventory snapventory = new List<Item>(); foreach (Item item in Inventory) snapventory.Add(item); Timestamp = DateTime.Now; }
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]); } }
public void LoadMap(String Filename, bool Startup = false) { map = (Maps)Maps.Load(Filename, typeof(Maps)); if (map == null) { Console.WriteLine("Oh no, something went wrong with the map-file!"); map = new Maps(); } if (!Startup) map.LoadContent(this.Content); if (map.Objects.Count > 0) { foreach (Object obj in map.Objects) { obj.LoadContent(this.Content); if (obj.opacity > 1f) obj.opacity = 1f; if (obj.scripts.Count > 0) { foreach (Script script in obj.scripts) { if (script.Commands.Count > 0) { foreach (Command com in script.Commands) { com.gui = gui; } } } } } if (!Startup) { // 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(); } } //Make a new instance of the scripthandler with the freshly loaded map scripthandler = new ScriptHandler(map, player, items, this); if (!Startup) { //Also make a snapshot right awayy Snapshot newsnapshot = new Snapshot(GameVariables, map, map.Objects); Snapshots.Add(newsnapshot); } Console.WriteLine("MAP LOCKED AND LOADED, SIR!"); }
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>(); }