public void AddLayer(MapLayer mapLayer) { if (mapLayer.Width != _mapWidth && mapLayer.Height != _mapHeight) { throw new Exception("Map layer size has incorect dimension"); } _mapLayers.Add(mapLayer); }
public TileMap(Tileset tileset, MapLayer mapLayer) { _tilesets = new List<Tileset> {tileset}; _mapLayers = new List<MapLayer> {mapLayer}; _mapWidth = _mapLayers[0].Width; _mapHeight = _mapLayers[0].Height; }
public void AddLayer(MapLayer layer) { if (layer.Width != mapWidth && layer.Height != mapHeight) { throw new Exception("Map Layer Size Exception"); } mapLayers.Add(layer); }
public TileMap(Tileset tileset, MapLayer baseLayer) { tilesets = new List<Tileset>(); tilesets.Add(tileset); mapLayers = new List<ILayer>(); mapLayers.Add(baseLayer); mapWidth = baseLayer.Width; mapHeight = baseLayer.Height; }
public void CreateWorld() { Texture2D tileSetTextureGrass = Game.Content.Load<Texture2D>(@"TileSets/grassTileSet"); Tileset tileSetGrass = new Tileset(tileSetTextureGrass, 8, 8, 32, 32); Texture2D tileSetTextureTown = Game.Content.Load<Texture2D>(@"TileSets/townTileSet"); Tileset tileSetTown = new Tileset(tileSetTextureTown, 8, 8, 32, 32); List<Tileset> tileSets = new List<Tileset>(); tileSets.Add(tileSetGrass); tileSets.Add(tileSetTown); MapLayer layer = new MapLayer(100, 100); for (int y = 0; y < layer.Height; y++) { for (int x = 0; x < layer.Width; x++) { Tile tile = new Tile(0, 0); layer.SetTile(x, y, tile); } } MapLayer splatter = new MapLayer(100, 100); Random random = new Random(); for (int i = 0; i < 100; i++) { int x = random.Next(0, 100); int y = random.Next(0, 100); int index = random.Next(2, 14); Tile tile = new Tile(index, 0); splatter.SetTile(x, y, tile); } splatter.SetTile(1, 0, new Tile(0, 1)); splatter.SetTile(2, 0, new Tile(2, 1)); splatter.SetTile(3, 0, new Tile(0, 1)); List<MapLayer> mapLayers = new List<MapLayer>(); mapLayers.Add(layer); mapLayers.Add(splatter); TileMap map = new TileMap(tileSets, mapLayers); Level level = new Level(map); World world = new World(gameRef, gameRef.ScreenRectangle); world.Levels.Add(level); world.CurrentLevel = 0; GamePlayScreen.World = world; }
public TileMap(Tileset tileset, MapLayer mapLayer) { tilesets = new List<Tileset>(); tilesets.Add(tileset); mapLayers = new List<MapLayer>(); mapLayers.Add(mapLayer); mapHeight = mapLayers[0].Height; mapWidth = mapLayers[0].Width; }
public TileMap(List<Tileset> tilesets, MapLayer baseLayer, MapLayer buildingLayer, MapLayer splatterLayer) { this.tilesets = tilesets; this.mapLayers = new List<ILayer>(); mapLayers.Add(baseLayer); AddLayer(buildingLayer); AddLayer(splatterLayer); mapWidth = baseLayer.Width; mapHeight = baseLayer.Height; }
public static MapLayer FromMapLayerData(MapLayerData data) { MapLayer layer = new MapLayer(data.Width, data.Height); for (int y = 0; y < data.Height; y++) { for (int x = 0; x < data.Width; x++) { layer.SetTile( x, y, data.GetTile(x, y).TileIndex, data.GetTile(x, y).TileSetIndex); } } return layer; }
protected override void LoadContent() { base.LoadContent(); var tilesets = new List<Tileset>(); var tileset1 = Game.Content.Load<Texture2D>(@"Tilesets\tileset1"); var tileset2 = Game.Content.Load<Texture2D>(@"Tilesets\tileset2"); tilesets.Add(new Tileset(tileset1, 8, 8, 32, 32)); tilesets.Add(new Tileset(tileset2, 8, 8, 32, 32)); var layer = new MapLayer(40, 40); for (var y = 0; y < layer.Height; y++) { for (var x = 0; x < layer.Width; x++) { var tile = new Tile(0, 0); layer.SetTile(x, y, tile); } } var splatter = new MapLayer(40, 40); var random = new Random(); for (var i = 0; i < 80; i++) { var x = random.Next(0, 40); var y = random.Next(0, 40); var index = random.Next(2, 14); splatter.SetTile(x, y, new Tile(index, 0)); } splatter.SetTile(1, 0, new Tile(0, 1)); splatter.SetTile(2, 0, new Tile(2, 1)); splatter.SetTile(3, 0, new Tile(0, 1)); var mapLayers = new List<MapLayer> {layer, splatter}; _map = new TileMap(tilesets, mapLayers); }
private void CreateWorld() { Texture2D tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset1"); Tileset tileset1 = new Tileset(tilesetTexture, 8, 8, 32, 32); tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset2"); Tileset tileset2 = new Tileset(tilesetTexture, 8, 8, 32, 32); MapLayer layer = new MapLayer(100, 100); for (int y = 0; y < layer.Height; y++) { for (int x = 0; x < layer.Width; x++) { Tile tile = new Tile(0, 0); layer.SetTile(x, y, tile); } } MapLayer splatter = new MapLayer(100, 100); Random random = new Random(); for (int i = 0; i < 100; i++) { int x = random.Next(0, 100); int y = random.Next(0, 100); int index = random.Next(2, 14); Tile tile = new Tile(index, 0); splatter.SetTile(x, y, tile); } splatter.SetTile(1, 0, new Tile(0, 1)); splatter.SetTile(2, 0, new Tile(2, 1)); splatter.SetTile(3, 0, new Tile(0, 1)); TileMap map = new TileMap(tileset1, layer); map.AddTileset(tileset2); map.AddLayer(splatter); Level level = new Level(map); World world = new World(GameRef, GameRef.ScreenRectangle); world.Levels.Add(level); world.CurrentLevel = 0; GamePlayScreen.World = world; }
private void CreateWorld() { Texture2D tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset1"); Tileset tileset1 = new Tileset(tilesetTexture, 8, 8, 32, 32); tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset2"); Tileset tileset2 = new Tileset(tilesetTexture, 8, 8, 32, 32); MapLayer layer = new MapLayer(100, 100); for (int y = 0; y < layer.Height; y++) { for (int x = 0; x < layer.Width; x++) { Tile tile = new Tile(0, 0); layer.SetTile(x, y, tile); } } MapLayer splatter = new MapLayer(100, 100); Random random = new Random(); for (int i = 0; i < 100; i++) { int x = random.Next(0, 100); int y = random.Next(0, 100); int index = random.Next(2, 14); Tile tile = new Tile(index, 0); splatter.SetTile(x, y, tile); } splatter.SetTile(1, 0, new Tile(0, 1)); splatter.SetTile(2, 0, new Tile(2, 1)); splatter.SetTile(3, 0, new Tile(0, 1)); TileMap map = new TileMap(tileset1, layer); map.AddTileset(tileset2); map.AddLayer(splatter); Level level = new Level(map); ChestData chestData = Game.Content.Load<ChestData>(@"Game\Chests\Plain Chest"); Chest chest = new Chest(chestData); BaseSprite chestSprite = new BaseSprite( containers, new Rectangle(0, 0, 32, 32), new Point(10, 10)); ItemSprite itemSprite = new ItemSprite( chest, chestSprite); level.Chests.Add(itemSprite); World world = new World(GameRef, GameRef.ScreenRectangle); world.Levels.Add(level); world.CurrentLevel = 0; GamePlayScreen.World = world; }
public TileMap(List <Tileset> tilesets, MapLayer baseLayer, MapLayer buildingLayer, MapLayer splatterLayer) { this.tilesets = tilesets; this.mapLayers = new List <ILayer>(); mapLayers.Add(baseLayer); AddLayer(buildingLayer); AddLayer(splatterLayer); mapWidth = baseLayer.Width; mapHeight = baseLayer.Height; }
public void CreateWorld() { Texture2D tileSetTextureGrass = Game.Content.Load<Texture2D>(@"TileSets/grassTileSet"); Tileset tileSetGrass = new Tileset(tileSetTextureGrass, 8, 8, 32, 32); Texture2D tileSetTextureTown = Game.Content.Load<Texture2D>(@"TileSets/townTileSet"); Tileset tileSetTown = new Tileset(tileSetTextureTown, 8, 8, 32, 32); List<Tileset> tileSets = new List<Tileset>(); tileSets.Add(tileSetGrass); tileSets.Add(tileSetTown); MapLayer layer = new MapLayer(100,100); for (int y = 0; y < layer.Height; y++) { for (int x = 0; x < layer.Width; x++) { Tile tile = new Tile(0,0); layer.SetTile(x,y,tile); } } MapLayer splatter = new MapLayer(100, 100); Random random = new Random(); for (int i = 0; i < 100; i++) { int x = random.Next(0,100); int y = random.Next(0, 100); int index = random.Next(2, 14); Tile tile = new Tile(index, 0); splatter.SetTile(x,y,tile); } splatter.SetTile(1,0,new Tile(0,1)); splatter.SetTile(2,0,new Tile(2,1)); splatter.SetTile(3,0,new Tile(0,1)); List<MapLayer> mapLayers = new List<MapLayer>(); mapLayers.Add(layer); mapLayers.Add(splatter); TileMap map = new TileMap(tileSets, mapLayers); Level level = new Level(map); ChestData chestData = new ChestData(); chestData.Name = "Chest"; chestData.MinGold = 10; chestData.MaxGold = 101; Chest chest = new Chest(chestData); BaseSprite chestSprite = new BaseSprite(containers, new Rectangle(0,0,32,32), new Point(10,10)); ItemSprite itemSprite = new ItemSprite(chest, chestSprite); level.Chests.Add(itemSprite); World world = new World(gameRef, gameRef.ScreenRectangle); world.Levels.Add(level); world.CurrentLevel = 0; GamePlayScreen.World = world; }
public TileMap(List <Tileset> tilesets, AnimatedTileset animatedTileSet, MapLayer baseLayer, MapLayer buildingLayer, MapLayer splatterLayer, CollisionLayer collisionLayer, AnimatedTileLayer animatedLayer) { this.tilesets = tilesets; this.animatedSet = animatedTileSet; this.mapLayers = new List <ILayer>(); this.collisionLayer = collisionLayer; this.animatedTileLayer = animatedLayer; mapLayers.Add(baseLayer); AddLayer(buildingLayer); AddLayer(splatterLayer); mapWidth = baseLayer.Width; mapHeight = baseLayer.Height; }