using System; using System.Collections.Generic; using System.Linq; using System.Text; using VBXSE; namespace SnakeRPG { public class Map { public string[,] neighbors = new string[3, 3]; public Tile[,] tiles = new Tile[Main.MAP_WIDTH, Main.MAP_HEIGHT]; public List entities = new List(); public string filename = ""; public string music = ""; public void Destroy() { for (int i = 0; i < entities.Count; i++) { Entity entity = entities[i]; SpriteEngine.EraseGObject(entity.sprite); SpriteEngine.EraseGObject(entity.underSprite); entity.sprite = null; entity.underSprite = null; entities[i] = null; } entities.Clear(); for (int iy = 0; iy < Main.MAP_HEIGHT; iy++) { for (int ix = 0; ix < Main.MAP_WIDTH; ix++) { SpriteEngine.EraseGObject(tiles[ix, iy].sprite); tiles[ix, iy] = null; } } } public void Relocate(int newOffsetX, int newOffsetY) { for (int i = 0; i < entities.Count; i++) { Entity entity = entities[i]; entity.SetOffsets(newOffsetX, newOffsetY); entity.SetPosition(entity.x, entity.y); } for (int iy = 0; iy < Main.MAP_HEIGHT; iy++) { for (int ix = 0; ix < Main.MAP_WIDTH; ix++) { Tile tile = tiles[ix, iy]; tile.sprite.SetPosition(ix * Main.SPRITE_WIDTH + newOffsetX * Main.MAP_WIDTH * Main.SPRITE_WIDTH, iy * Main.SPRITE_HEIGHT + newOffsetY * Main.MAP_HEIGHT * Main.SPRITE_HEIGHT); } } } } }