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!"); }
/// <summary> /// LoadContentContent loads everything else that isnt the title screen /// </summary> private void LoadContentContent() { // TODO: use this.Content to load your game content here map.LoadContent(this.Content); player.LoadContent(this.Content, font); gui = new GUI(font, player.InvList, proj); gui.LoadContent(this.Content); scripthandler = new ScriptHandler(map, player, items, this); }