//player chose to destroy public void DestroyTile() { //getting the tile we need DataController.Tile tile = DataController.dc.tileMap[pos.x, pos.y]; //changing the tile to grass tile.type = "grass"; tile.name = "EmptyTile"; tile.level = 0; mapGenerator.CurrentTiles[pos].GetComponent <SpriteRenderer>().sprite = grassSprite; mapInteraction.names.Remove(tile.position); //changing the number of buildings mapInteraction.buildingsCount--; mapInteraction.SetNumberOfTilesTxt(); AudioSource.PlayOneShot(destroyAudio); mapInteraction.dialogues.Remove(pos); Destroy(gameObject); }
void CreateTile(DataController.Tile pTile) { GameObject tileGO = Instantiate(GetTileByType(pTile.type), new Vector2(pTile.position.x, pTile.position.y), Quaternion.identity, tilesHolder.transform); CurrentTiles.Add(pTile.position, tileGO); }