public DoubleCurvedChild(DoubleCurvedTrackBlock parentBlock,
                          int rotationOffset) : base(parentBlock.x, parentBlock.y,
                                                     rotationOffset, parentBlock.Parent)
 {
     this.parentBlock = parentBlock;
 }
        private AbstractTrackBlock generateTrackPiece(int x, int y)
        {
            //give random spin
            int rotation = random.Next();
            AbstractTrackBlock result;

            if (!_engineOptions.mapWraps)
            {
                if (x == 0 || x == _engineOptions.gridWidth - 1 ||
                    y == 0 || y == _engineOptions.gridHeight - 1)
                {
                    // it is on the edge
                    debugLog(String.Format("[{0}, {1}] is on the edge", x, y));
                    if (random.Next() % 2 == 0)
                    {
                        return(new DoubleCurvedTrackBlock(x, y, rotation, this));
                    }
                    return(new CurvedTrackBlock(x, y, rotation, this));
                }
                if ((x == 1 || x == _engineOptions.gridWidth - 2) &&
                    (y == 1 || y == _engineOptions.gridHeight - 2))
                {
                    if (random.Next() % 10 == 0)
                    {
                        return(new DoubleStraightTrackBlock(x, y, rotation,
                                                            this));
                    }
                    return(new DoubleCurvedTrackBlock(x, y, rotation, this));
                }
            }

            TrackType type = (TrackType)(random.Next() %
                                         (int)TrackType.Station);//it is assumed that the station is the last one

            //TODO: add weights
            switch (type)
            {
            case TrackType.Curved:
                result = new CurvedTrackBlock(x, y, rotation,
                                              this);
                break;

            case TrackType.Straight:
                result = new StraightTrackBlock(x, y, rotation,
                                                this);
                break;

            case TrackType.DoubleCurved:
                result = new DoubleCurvedTrackBlock(x, y,
                                                    rotation, this);
                break;

            case TrackType.DoubleStraight:
                result = new DoubleStraightTrackBlock(x, y,
                                                      rotation, this);
                break;

            default:
                throw new InvalidOperationException(
                          "Unexpected track type " + type + "!");
            }
            return(result);
        }