public void addShelter(Shelter shelter,int row,int column) { shelter.SetValue(Grid.ColumnProperty, column); shelter.SetValue(Grid.RowProperty, row); shelters[row, column] = shelter; shelterPositions[shelter] = new Int32Point(column, row); Children.Add(shelter); }
public void destroy(Shelter shelter) { Int32Point pos = shelterPositions[shelter]; if (pos == null) { return; } shelters[pos.y, pos.x] = null; shelterPositions[shelter] = null; Children.Remove(shelter); }
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); } } }