public override void updatePreview() { RailPattern rp = RailPattern.get(currentDirection, currentDirection.opposite); using (PreviewDrawer drawer = new PreviewDrawer(preview.Size, new Size(1, 1), 0)) { // draw the rail for (int i = -5; i < 5; i++) { if (currentDirection.isParallelToX) { drawer.draw(rp, i, 0); } else { drawer.draw(rp, 0, i); } } // draw the signal drawer.draw(rp, 0, 0); drawer.draw(currentType.getSprite(currentDirection), 0, 0); // draw the arrow currentDirection.drawArrow(drawer.surface, drawer.getPoint(-currentDirection.offsetX, -currentDirection.offsetY)); preview.Image = drawer.createBitmap(); } }
public SignalRailRoad(TrafficVoxel v, RailSignalContribution _type, Direction _dir) : base(v, _dir) { this.direction = _dir; this.type = _type; pattern = RailPattern.get(direction, direction.opposite); Debug.Assert(dir1.isSharp); Debug.Assert(dir2.isSharp); }
public void drawVoxel(QuarterViewDrawer view, DrawContextEx dc, Location loc, Point pt) { if (loc == baseLoc) { RailPattern.get(currentDirection, currentDirection.opposite) .drawAlpha(dc.surface, pt); currentType.getSprite(currentDirection) .drawAlpha(dc.surface, pt); } }
/// <summary> /// Builds a nice preview of a train. /// </summary> public PreviewDrawer CreatePreview(Size pixelSize, int trainlength) { PreviewDrawer pd = new PreviewDrawer(pixelSize, new Size(1, 3), 0); // build up rail like // // /~~~~~ // / for (int x = -10; x < 0; x++) { pd.Draw(RailPattern.get(Direction.WEST, Direction.EAST), x, 0); } pd.Draw(RailPattern.get(Direction.WEST, Direction.SOUTHEAST), 0, 0); for (int x = 1; x <= 10; x++) { pd.Draw(RailPattern.get(Direction.NORTHWEST, Direction.SOUTHEAST), x, x); } TrainCarContribution[] cars = Create(trainlength); /*if( cars==null ) { * for( int i=6; cars==null && i<15; i++ ) * cars = create(i); * for( int i=4; cars==null && i>0; i-- ) * cars = create(i); * if( cars==null ) * return pd; // no preview * }*/ if (cars == null) { return(pd); // no preview } int[] pos = new int[] { -2, 0, -1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; int[] angle = new int[] { 12, 12, 13, 14, 14, 14, 14, 14 }; int[] offset = new int[] { 0, 0, 0, 0, 4, +2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; using (DrawContext dc = new DrawContext(pd.Surface)) { for (int i = 7; i >= 0; i--) { if (cars.Length <= i) { continue; // no car } Point pt = pd.GetPoint(pos[i * 2], pos[i * 2 + 1]); cars[i].Draw(pd.Surface, new Point(pt.X + offset[i * 2], pt.Y + offset[i * 2 + 1] - 9), angle[i]); } } return(pd); }
public override void updatePreview() { using (PreviewDrawer drawer = new PreviewDrawer(picture.Size, new Size(1, 10), 0)) { for (int i = 0; i < 10; i++) { drawer.draw(RailPattern.get(Direction.NORTH, Direction.SOUTH), 0, i); } if (picture.Image != null) { picture.Image.Dispose(); } picture.Image = drawer.createBitmap(); } }
public override PreviewDrawer createPreview(Size pixelSize) { PreviewDrawer drawer = new PreviewDrawer(pixelSize, new Size(10, 1), 0); for (int x = 9; x >= 0; x--) { if (x == 5) { drawer.draw(sprites[0, 0], x, 0); } drawer.draw(RailPattern.get(Direction.EAST, Direction.WEST), x, 0); if (x == 5) { drawer.draw(sprites[0, 1], x, 0); } } return(drawer); }
/// <summary> /// /// </summary> /// <param name="d"></param> /// <param name="canvas"></param> /// <param name="pt"></param> protected override void Draw(Direction d, DrawContext canvas, Point pt) { RailPattern.get(d, d.opposite).DrawAlpha(canvas.Surface, pt); }
/// <summary> /// Replace this garage by a normal rail road /// </summary> internal void remove() { new SingleRailRoad(voxel, RailPattern.get(dir1, dir2)); }