//----------------------------------------------------------------------------- // Methods //----------------------------------------------------------------------------- public void LoadWorld(string fileName) { WorldFile worldFile = new WorldFile(); World world = worldFile.Load(fileName); LoadWorld(world); }
// Open a world file with the given filename. public void OpenFile(string fileName) { // Load the world. WorldFile worldFile = new WorldFile(); World loadedWorld = worldFile.Load(fileName); // Verify the world was loaded successfully. if (loadedWorld != null) { CloseFile(); hasMadeChanges = false; worldFilePath = fileName; worldFileName = Path.GetFileName(fileName); needsRecompiling = true; world = loadedWorld; if (world.Levels.Count > 0) { OpenLevel(0); } RefreshWorldTreeView(); editorForm.worldTreeView.ExpandAll(); } else { // Display the error. MessageBox.Show(editorForm, "Failed to open world file:\n" + worldFile.ErrorMessage, "Error Opening World", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void LoadGeoRefImage(string layerName, string ImagefileName) { if (File.Exists(ImagefileName)) { InterpolationMode = InterpolationMode.HighQualityBicubic; _image = (Bitmap)Image.FromFile(ImagefileName); _imagefilename = ImagefileName; _layerName = layerName; worldFile.Load(ImagefileName); // base.CenterCoordinate base.Width = _image.Width; //_emptyBlock = CreateCompatibleBitmap(null, TileBlock.BlockSize, TileBlock.BlockSize, PiFormat); //int width, int height, GeomCoordinate centerCoordinate, int level) : base(width, height, centerCoordinate, level) } }
// Open a world file with the given filename. public void OpenFile(string fileName) { CloseFile(); hasMadeChanges = false; worldFilePath = fileName; worldFileName = Path.GetFileName(fileName); // Load the world. WorldFile worldFile = new WorldFile(); world = worldFile.Load(fileName); if (world.Levels.Count > 0) OpenLevel(0); RefreshWorldTreeView(); editorForm.LevelTreeView.ExpandAll(); }
public static World CreateTestWorld() { // Create the world. World world = new World(); world.StartLevelIndex = 0; world.StartRoomLocation = new Point2I(2, 1); world.StartTileLocation = new Point2I(3, 2); // Load the levels from java level files. world.Levels.Add(LoadJavaLevel("Content/Worlds/test_level.zwd")); world.Levels.Add(LoadJavaLevel("Content/Worlds/interiors.zwd")); world.Levels.Add(LoadJavaLevel("Content/Worlds/big_interiors.zwd")); world.Levels[0].Properties.Set("id", "overworld"); world.Levels[1].Properties.Set("id", "interiors"); world.Levels[2].Properties.Set("id", "big_interiors"); TileData tdBlock = Resources.GetResource<TileData>("movable_block"); TileData tdDiamond = Resources.GetResource<TileData>("diamond_rock"); TileData tdBush = Resources.GetResource<TileData>("bush"); TileData tdPot = Resources.GetResource<TileData>("pot"); TileData tdRock = Resources.GetResource<TileData>("rock"); TileData tdGrass = Resources.GetResource<TileData>("grass"); TileData tdOwl = Resources.GetResource<TileData>("owl"); TileData tdLantern = Resources.GetResource<TileData>("lantern"); TileData tdSign = Resources.GetResource<TileData>("sign"); TileData tdChest = Resources.GetResource<TileData>("chest"); TileData tdReward = Resources.GetResource<TileData>("reward"); EventTileData etdWarp = Resources.GetResource<EventTileData>("warp"); Level level; Room r; TileDataInstance t; EventTileDataInstance e; // Setup the overworld rooms. level = world.Levels[0]; r = level.GetRoomAt(2, 1); t = r.CreateTile(tdOwl, 8, 1, 1); t.Properties.Set("text", "Hello, World!"); t = r.CreateTile(tdChest, 7, 1, 1); t.Properties.Set("reward", "heart_piece"); t = r.CreateTile(tdReward, 6, 3, 1); t.Properties.Set("reward", "item_flippers_1"); t = r.CreateTile(tdSign, 1, 1, 1); t.Properties.Set("text", "This will<n> prime your load catchers and boost your desktop wallpaper."); t = r.CreateTile(tdReward, 2, 6, 1); t.Properties.Set("reward", "heart_piece"); r.CreateTile(tdBlock, 2, 5, 1); r.CreateTile(tdGrass, 2, 2, 1); r.CreateTile(tdGrass, 2, 3, 1); r.CreateTile(tdGrass, 2, 4, 1); r.CreateTile(tdGrass, 3, 4, 1); r.CreateTile(tdGrass, 4, 5, 1); r.CreateTile(tdGrass, 3, 6, 1); r.CreateTile(tdGrass, 4, 6, 1); r.CreateTile(tdGrass, 5, 6, 1); r.CreateTile(tdGrass, 4, 7, 1); r.CreateTile(tdGrass, 5, 7, 1); r.CreateTile(tdGrass, 6, 7, 1); r.CreateTile(tdGrass, 7, 7, 1); r.CreateTile(tdGrass, 7, 2, 1); r.CreateTile(tdGrass, 8, 2, 1); r.CreateTile(tdGrass, 8, 3, 1); r = level.GetRoomAt(2, 2); e = r.CreateEventTile(etdWarp, 16, 64); e.Properties.Add(Property.CreateString("id", "warp_a")); e.Properties.Add(Property.CreateString("warp_type", "tunnel")); e.Properties.Add(Property.CreateString("destination_level", "overworld")); e.Properties.Add(Property.CreateString("destination_warp_point", "warp_b")); r = level.GetRoomAt(1, 1); e = r.CreateEventTile(etdWarp, 64, 96); e.Properties.Add(Property.CreateString("id", "warp_b")); e.Properties.Add(Property.CreateString("warp_type", "stairs")); e.Properties.Add(Property.CreateString("destination_level", "overworld")); e.Properties.Add(Property.CreateString("destination_warp_point", "warp_a")); r = level.GetRoomAt(new Point2I(1, 1)); r.CreateTile(tdDiamond, 1, 1, 1); r.CreateTile(tdDiamond, 2, 2, 1); r.CreateTile(tdDiamond, 2, 4, 1); r.CreateTile(tdPot, 8, 2, 1); r = level.GetRoomAt(new Point2I(3, 0)); r.CreateTile(tdLantern, 3, 2, 1); r = level.GetRoomAt(new Point2I(1, 0)); r.CreateTile(tdRock, 8, 2, 1); r = level.GetRoomAt(new Point2I(2, 0)); for (int x = 1; x < 8; x++) { for (int y = 2; y < 6; y++) { r.CreateTile(tdBush, x, y, 1); } } // Set the rooms to random zones. /*Random random = new Random(); for (int x = 0; x < level.Width; x++) { for (int y = 0; y < level.Height; y++) { int index = random.Next(0, 3); Zone zone = GameData.ZONE_SUMMER; if (index == 1) zone = GameData.ZONE_GRAVEYARD; else if (index == 2) zone = GameData.ZONE_FOREST; level.GetRoom(new Point2I(x, y)).Zone = zone; } }*/ // Setup the interior rooms. level = world.Levels[1]; r = level.GetRoomAt(2, 1); r.Zone = GameData.ZONE_INTERIOR; r.CreateTile(tdPot, 1, 2, 1); r.CreateTile(tdPot, 1, 3, 1); r.CreateTile(tdPot, 5, 1, 1); r = level.GetRoomAt(3, 1); r.Zone = GameData.ZONE_INTERIOR; r.CreateTile(tdChest, 8, 1, 1); r.CreateTile(tdPot, 8, 2, 1); r.CreateTile(tdPot, 4, 6, 1); r.CreateTile(tdPot, 5, 6, 1); r.CreateTile(tdPot, 6, 6, 1); r.CreateTile(tdPot, 7, 6, 1); r.CreateTile(tdPot, 8, 6, 1); // Save and load the world. { WorldFile worldFile = new WorldFile(); worldFile.Save("Content/Worlds/custom_world.zwd", world); } { WorldFile worldFile = new WorldFile(); world = worldFile.Load("Content/Worlds/custom_world.zwd"); } return world; }
// Open a world file with the given filename. public void OpenFile(string fileName) { // Load the world. WorldFile worldFile = new WorldFile(); World loadedWorld = worldFile.Load(fileName); // Verify the world was loaded successfully. if (loadedWorld != null) { CloseFile(); hasMadeChanges = false; worldFilePath = fileName; worldFileName = Path.GetFileName(fileName); needsRecompiling = true; world = loadedWorld; if (world.Levels.Count > 0) OpenLevel(0); RefreshWorldTreeView(); editorForm.worldTreeView.ExpandAll(); } else { // Display the error. MessageBox.Show(editorForm, "Failed to open world file:\n" + worldFile.ErrorMessage, "Error Opening World", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//----------------------------------------------------------------------------- // Methods //----------------------------------------------------------------------------- // Start a new game. public void StartGame() { roomTicks = 0; roomTicks = 0; // Setup the player beforehand so certain classes such as the HUD can reference it player = new Player(); inventory = new Inventory(this); menuWeapons = new MenuWeapons(gameManager); menuSecondaryItems = new MenuSecondaryItems(gameManager); menuEssences = new MenuEssences(gameManager); menuWeapons.PreviousMenu = menuEssences; menuWeapons.NextMenu = menuSecondaryItems; menuSecondaryItems.PreviousMenu = menuWeapons; menuSecondaryItems.NextMenu = menuEssences; menuEssences.PreviousMenu = menuSecondaryItems; menuEssences.NextMenu = menuWeapons; GameData.LoadInventory(inventory, true); inventory.ObtainAmmo("ammo_scent_seeds"); //inventory.ObtainAmmo("ammo_pegasus_seeds"); //inventory.ObtainAmmo("ammo_gale_seeds"); inventory.ObtainAmmo("ammo_mystery_seeds"); hud = new HUD(this); hud.DynamicHealth = player.Health; rewardManager = new RewardManager(this); GameData.LoadRewards(rewardManager); // Create the room control. roomControl = new RoomControl(); gameManager.PushGameState(roomControl); // Create the test world. // Load the world. //WorldFile worldFile = new WorldFile(); //world = worldFile.Load("Content/Worlds/temp_world.zwd"); // Begin the room state. if (gameManager.LaunchParameters.Length > 0) { WorldFile worldFile = new WorldFile(); world = worldFile.Load(gameManager.LaunchParameters[0]); if (gameManager.LaunchParameters.Length > 1 && gameManager.LaunchParameters[1] == "-test") { int startLevel = Int32.Parse(gameManager.LaunchParameters[2]); int startRoomX = Int32.Parse(gameManager.LaunchParameters[3]); int startRoomY = Int32.Parse(gameManager.LaunchParameters[4]); int startPlayerX = Int32.Parse(gameManager.LaunchParameters[5]); int startPlayerY = Int32.Parse(gameManager.LaunchParameters[6]); player.Position = new Point2I(startPlayerX, startPlayerY) * GameSettings.TILE_SIZE + new Point2I(8, 16); roomControl.BeginRoom(world.Levels[startLevel].Rooms[startRoomX, startRoomY]); } else { player.Position = world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 16); roomControl.BeginRoom(world.StartRoom); } } else { world = GameDebug.CreateTestWorld(); player.Position = world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 16); roomControl.BeginRoom(world.StartRoom); } roomStateStack = new RoomStateStack(new RoomStateNormal()); roomStateStack.Begin(this); AudioSystem.MasterVolume = 0.06f; }
public static World CreateTestWorld() { // Create the world. World world = new World(); world.StartLevelIndex = 0; world.StartRoomLocation = new Point2I(2, 1); world.StartTileLocation = new Point2I(3, 2); // Load the levels from java level files. world.Levels.Add(LoadJavaLevel("Content/Worlds/test_level.zwd")); world.Levels.Add(LoadJavaLevel("Content/Worlds/interiors.zwd")); world.Levels.Add(LoadJavaLevel("Content/Worlds/big_interiors.zwd")); world.Levels[0].Properties.Set("id", "overworld"); world.Levels[1].Properties.Set("id", "interiors"); world.Levels[2].Properties.Set("id", "big_interiors"); TileData tdBlock = Resources.GetResource <TileData>("movable_block"); TileData tdDiamond = Resources.GetResource <TileData>("diamond_rock"); TileData tdBush = Resources.GetResource <TileData>("bush"); TileData tdPot = Resources.GetResource <TileData>("pot"); TileData tdRock = Resources.GetResource <TileData>("rock"); TileData tdGrass = Resources.GetResource <TileData>("grass"); TileData tdOwl = Resources.GetResource <TileData>("owl"); TileData tdLantern = Resources.GetResource <TileData>("lantern"); TileData tdSign = Resources.GetResource <TileData>("sign"); TileData tdChest = Resources.GetResource <TileData>("chest"); TileData tdReward = Resources.GetResource <TileData>("reward"); EventTileData etdWarp = Resources.GetResource <EventTileData>("warp"); Level level; Room r; TileDataInstance t; EventTileDataInstance e; // Setup the overworld rooms. level = world.Levels[0]; r = level.GetRoomAt(2, 1); t = r.CreateTile(tdOwl, 8, 1, 1); t.Properties.Set("text", "Hello, World!"); t = r.CreateTile(tdChest, 7, 1, 1); t.Properties.Set("reward", "heart_piece"); t = r.CreateTile(tdReward, 6, 3, 1); t.Properties.Set("reward", "item_flippers_1"); t = r.CreateTile(tdSign, 1, 1, 1); t.Properties.Set("text", "This will<n> prime your load catchers and boost your desktop wallpaper."); t = r.CreateTile(tdReward, 2, 6, 1); t.Properties.Set("reward", "heart_piece"); r.CreateTile(tdBlock, 2, 5, 1); r.CreateTile(tdGrass, 2, 2, 1); r.CreateTile(tdGrass, 2, 3, 1); r.CreateTile(tdGrass, 2, 4, 1); r.CreateTile(tdGrass, 3, 4, 1); r.CreateTile(tdGrass, 4, 5, 1); r.CreateTile(tdGrass, 3, 6, 1); r.CreateTile(tdGrass, 4, 6, 1); r.CreateTile(tdGrass, 5, 6, 1); r.CreateTile(tdGrass, 4, 7, 1); r.CreateTile(tdGrass, 5, 7, 1); r.CreateTile(tdGrass, 6, 7, 1); r.CreateTile(tdGrass, 7, 7, 1); r.CreateTile(tdGrass, 7, 2, 1); r.CreateTile(tdGrass, 8, 2, 1); r.CreateTile(tdGrass, 8, 3, 1); r = level.GetRoomAt(2, 2); e = r.CreateEventTile(etdWarp, 16, 64); e.Properties.Set("id", "warp_a"); e.Properties.Set("warp_type", "tunnel"); e.Properties.Set("destination_level", "overworld"); e.Properties.Set("destination_warp_point", "warp_b"); r = level.GetRoomAt(1, 1); e = r.CreateEventTile(etdWarp, 64, 96); e.Properties.Set("id", "warp_b"); e.Properties.Set("warp_type", "stairs"); e.Properties.Set("destination_level", "overworld"); e.Properties.Set("destination_warp_point", "warp_a"); r = level.GetRoomAt(new Point2I(1, 1)); r.CreateTile(tdDiamond, 1, 1, 1); r.CreateTile(tdDiamond, 2, 2, 1); r.CreateTile(tdDiamond, 2, 4, 1); r.CreateTile(tdPot, 8, 2, 1); r = level.GetRoomAt(new Point2I(3, 0)); r.CreateTile(tdLantern, 3, 2, 1); r = level.GetRoomAt(new Point2I(1, 0)); r.CreateTile(tdRock, 8, 2, 1); r = level.GetRoomAt(new Point2I(2, 0)); for (int x = 1; x < 8; x++) { for (int y = 2; y < 6; y++) { r.CreateTile(tdBush, x, y, 1); } } // Set the rooms to random zones. /*Random random = new Random(); * for (int x = 0; x < level.Width; x++) { * for (int y = 0; y < level.Height; y++) { * int index = random.Next(0, 3); * Zone zone = GameData.ZONE_SUMMER; * if (index == 1) * zone = GameData.ZONE_GRAVEYARD; * else if (index == 2) * zone = GameData.ZONE_FOREST; * level.GetRoom(new Point2I(x, y)).Zone = zone; * } * }*/ // Setup the interior rooms. level = world.Levels[1]; r = level.GetRoomAt(2, 1); r.Zone = GameData.ZONE_INTERIOR; r.CreateTile(tdPot, 1, 2, 1); r.CreateTile(tdPot, 1, 3, 1); r.CreateTile(tdPot, 5, 1, 1); r = level.GetRoomAt(3, 1); r.Zone = GameData.ZONE_INTERIOR; r.CreateTile(tdChest, 8, 1, 1); r.CreateTile(tdPot, 8, 2, 1); r.CreateTile(tdPot, 4, 6, 1); r.CreateTile(tdPot, 5, 6, 1); r.CreateTile(tdPot, 6, 6, 1); r.CreateTile(tdPot, 7, 6, 1); r.CreateTile(tdPot, 8, 6, 1); // Save and load the world. { WorldFile worldFile = new WorldFile(); worldFile.Save("Content/Worlds/custom_world.zwd", world); } { WorldFile worldFile = new WorldFile(); world = worldFile.Load("Content/Worlds/custom_world.zwd"); } return(world); }