// Destroy a wall // (x, y) is the coordinate of the tile // direction is the direction from the tile where the wall should be destroyed public void DestroyWall(int x, int y, int direction) { TileClass tile = GetTileAtCoordinate(x, y).GetComponent <TileClass>(); GameObject obj = GetNeighbouringTile(x, y, direction); TileClass otherTile = null; if (obj != null) { otherTile = obj.GetComponent <TileClass>(); } GameObject wall = null; int opposite = TileClass.getOppositeDirection(direction); if (otherTile != null && otherTile.HasWall(opposite)) { wall = otherTile.GetWall(opposite); otherTile.SetWall(opposite, null); } if (tile.HasWall(direction)) { wall = tile.GetWall(direction); otherTile.SetWall(direction, null); } if (wall != null) { Destroy(wall); } }