public void SetBackgroundTile(Tile tile) { for (short row = 0; row < this.size.height; row++) { for (short col = 0; col < this.size.width; col++) { Tile newTile = new Tile(tile.GetName(), tile.GetWalkable(), tile.GetBuildable()); newTile.SetPosition(col, row); this.stageTiles.Add(newTile); newTile.SetParentStage(this); } } }
public void CreateRandomTiles() { for (int h = 0; h < this.size.height; h++) { for (int w = 0; w < this.size.width; w++) { //with the randomization of the tiles, we're going to randomize whether or not this is buildiable int rand = JsMath.round(JsMath.random()); //int rand = (new Random()).Next(0, 1); //check whether the random # is 0 or 1, the long way, because apparently boolean.parse won't figure it out bool buildable = false; if (rand == 1) { buildable = true; } Tile aTile = new Tile("", true, buildable); aTile.SetParentStage(this); aTile.SetPosition(w, h); stageTiles.Add(aTile); } } }
/// <summary> /// Fill the map with empty visible tiles. /// </summary> public void FillTiles() { for (int h = 0; h < this.size.height; h++) { for (int w = 0; w < this.size.width; w++) { Tile aTile = new Tile("", true, true); aTile.SetParentStage(this); aTile.SetPosition(w, h); stageTiles.Add(aTile); } } }
public Tile AddTile(string name, bool walkable, bool buildable, Point tilePos) { // If a tile already exists at this position, destroy it (for now)... foreach(Tile tile in this.stageTiles) { if(tile.GetPosition().x == tilePos.x && tile.GetPosition().y == tilePos.y) { //this.stageTiles.Remove(tile); //tile.Destroy(); tile.SetBuildable(buildable); tile.SetWalkable(walkable); tile.SetSprite(Sprite.GetSpriteByName(name)); return tile; } } // (else) Tile newTile = new Tile(name, walkable, buildable); newTile.SetPosition(tilePos.x, tilePos.y); this.stageTiles.Add(newTile); newTile.SetParentStage(this); return newTile; }