public void loadShelterLayer(TileLayer tileLayer) { shelterLayer = new ShelterLayer(tileMap.height, tileMap.width, tileMap.tileheight, tileMap.tilewidth); for (int i = 0; i < tileLayer.data.Length; i++) { if (tileLayer.data[i] != 0) { int x = i % tileMap.width; int y = i / tileMap.height; bool canDestroy = tileProp.ContainsKey(tileLayer.data[i]-1) && tileProp[tileLayer.data[i]-1].canDestroy != null; bool canKick = tileProp.ContainsKey(tileLayer.data[i]-1) && tileProp[tileLayer.data[i]-1].canKick != null; Shelter shelter = new Shelter(canDestroy,canKick); shelter.Source = tileImgSrcs[tileLayer.data[i] - 1]; shelterLayer.addShelter(shelter,y,x); } } }
public void loadFloorLayer(TileLayer tileLayer) { floorLayer = new FloorLayer(); for (int i = 0; i < tileMap.height; i++) { floorLayer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(tileMap.tileheight) }); } for (int i = 0; i < tileMap.width; i++) { floorLayer.ColumnDefinitions.Add(new ColumnDefinition() {Width = new GridLength(tileMap.tilewidth) }); } floorLayer.Width = tileMap.width * tileMap.tilewidth; floorLayer.Height = tileMap.height * tileMap.tileheight; for (int i = 0; i < tileLayer.data.Length; i++) { if (tileLayer.data[i] != 0) { int x = i % tileMap.width; int y = i / tileMap.height; Image img = new Image(); img.Source = tileImgSrcs[tileLayer.data[i]-1]; img.SetValue(Grid.ColumnProperty, x); img.SetValue(Grid.RowProperty, y); floorLayer.Children.Add(img); } } }
public void loadObstacleLayer(TileLayer tileLayer) { obstacleLayer = new ObstacleLayer(tileMap.height,tileMap.width,tileMap.tileheight,tileMap.tilewidth); for (int i = 0; i < tileLayer.data.Length; i++) { if (tileLayer.data[i] != 0) { int x = i % tileMap.width; int y = i / tileMap.height; Obstacle img = new Obstacle(); img.Source = tileImgSrcs[tileLayer.data[i] - 1]; obstacleLayer.addObstacle(img,y,x); } } }
public void loadBoxLayer(TileLayer tileLayer) { boxLayer = new BoxLayer(tileMap.height, tileMap.width, tileMap.tileheight, tileMap.tilewidth); for (int i = 0; i < tileLayer.data.Length; i++) { if (tileLayer.data[i] != 0) { int x = i % tileMap.width; int y = i / tileMap.height; bool canDestroy = tileProp.ContainsKey(tileLayer.data[i]-1) && tileProp[tileLayer.data[i]-1].canDestroy!=null; bool canKick = tileProp.ContainsKey(tileLayer.data[i]-1) && tileProp[tileLayer.data[i]-1].canKick != null; Box box = new Box(canDestroy,canKick); box.Source = tileImgSrcs[tileLayer.data[i] - 1]; boxLayer.addBox(box, y, x); } } }