public bool LoadWorld(string worldpath) { ScrollingWorld world; if (worldpath!=null) { //world = Serializer.DeSerialize(worldpath); world = new ScrollingWorld(worldpath, true); cwname = worldpath; } else { return false; } if (world != null) { //this.world = world; currentWorld = world; //world.LoadContent(Content); currentWorld.reloadNonSerializedAssets(); //Bug: When reloading a game, player starts at last known rotation, but kicking //box is always redrawn from initial rotaion. (So kicking box is offset) //Solution: Always create a new player, only transferring state. (No one will notice/care) //****// //world.player.Rotation = world.player.OriginalRotation; return true; } return false; }
public bool NewWorld() { // new game deletes the autosave if (File.Exists(GetCurrDir() + Constants.SAVED_GAME_FILENAME)) { File.Delete(GetCurrDir() + "\\" + Constants.SAVED_GAME_FILENAME); } // either way, start a new saved game savedgame = new SavedGame(); savedgame.disabledOptions.AddRange(new List<int> { 1, 2, 3 }); //string currdir = (Directory.GetCurrentDirectory()).Replace("bin\\x86\\Debug", "Content").Replace("bin\\x86\\Release", "Content").Replace("\\Worlds", ""); cwname = GetCurrDir() + "\\Levels\\" + Constants.NEW_GAME_NAME; ScrollingWorld world = new ScrollingWorld(cwname, true); if (world != null) { //this.world = world; currentWorld = world; //world.LoadContent(Content); currentWorld.reloadNonSerializedAssets(); return true; } return false; }
public bool LoadWorld() { ScrollingWorld world; //First, choose the file we want to load. This is slightly magic. Forms.OpenFileDialog dialog = new Forms.OpenFileDialog(); dialog.Filter = "World Files | *.world"; dialog.InitialDirectory = "."; dialog.Title = "Select a world file."; Forms.DialogResult result = dialog.ShowDialog(); //If the result was ok, load the resultant file into world and return it. Otherwise, //return null. if (result == Forms.DialogResult.OK) { //world = Serializer.DeSerialize(dialog.FileName); world = new ScrollingWorld(dialog.FileName, true); cwname = dialog.FileName; } else { return false; } if (world != null) { //this.world = world; currentWorld = world; //world.LoadContent(Content); currentWorld.reloadNonSerializedAssets(); //Bug: When reloading a game, player starts at last known rotation, but kicking //box is always redrawn from initial rotaion. (So kicking box is offset) //Solution: Always create a new player, only transferring state. (No one will notice/care) //****// //world.player.Rotation = world.player.OriginalRotation; return true; } return false; }