void renderTile(Tileset tset, Graphics g, int x, int y, bool overdraw = false) { Tile tile = tiles[tcoord(x, y)]; Rectangle dst = new Rectangle(x * this.tile_size, y * this.tile_size, this.tile_size, this.tile_size); // only draw tile if not (0, 0) if (!(tile.getTX() == 0 && tile.getTY() == 0) || overdraw) { Rectangle src = new Rectangle(tile.getTX() * this.tile_size, tile.getTY() * this.tile_size, this.tile_size, this.tile_size); if (tile.getRot() > 0) { g.TranslateTransform((float)(dst.X + this.tile_size / 2), (float)(dst.Y + this.tile_size / 2)); g.RotateTransform(tile.getRot() * 90); g.TranslateTransform(-(float)(dst.X + this.tile_size / 2), -(float)(dst.Y + this.tile_size / 2)); } g.DrawImage(tset.getBuffer(), dst, src, GraphicsUnit.Pixel); if (tile.getRot() > 0) { g.ResetTransform(); } } if (ShowFlags <= 0) { return; } // always draw flags, if any g.CompositingMode = CompositingMode.SourceOver; Brush brush = null; switch (tile.getFlags()) { case Tile.Flags.SOLID: brush = solidBrush; break; case Tile.Flags.ABYSS: brush = abyssBrush; break; case Tile.Flags.WATER: brush = waterBrush; break; case Tile.Flags.PUDDLE: brush = puddleBrush; break; case Tile.Flags.SLOW: brush = slowBrush; break; case Tile.Flags.ICE: brush = iceBrush; break; case Tile.Flags.ENTRANCE: brush = entranceBrush; break; case Tile.Flags.ACTIVATE: brush = activateBrush; break; case Tile.Flags.PUSHBACK: brush = pushbackBrush; break; case Tile.Flags.AUTOJUMP: brush = jumpBrush; break; default: return; } if (brush != null) { if (ShowFlags > 1 && brush is SolidBrush) { Color c = ((SolidBrush)brush).Color; SolidBrush final = new SolidBrush(Color.FromArgb(255, c.R, c.G, c.B)); renderData(g, dst, final, tile.getForm()); } else { renderData(g, dst, brush, tile.getForm()); } } // assist showing rotation if ((int)tile.getFlags() >= 32) { Point p0, p1; switch (tile.getRot()) { case 0: p0 = new Point(dst.X + dst.Size.Width / 2, dst.Y + dst.Size.Height); p1 = new Point(dst.X + dst.Size.Width / 2, dst.Y); break; case 1: p0 = new Point(dst.X, dst.Y + dst.Size.Height / 2); p1 = new Point(dst.X + dst.Size.Width, dst.Y + dst.Size.Height / 2); break; case 2: p0 = new Point(dst.X + dst.Size.Width / 2, dst.Y); p1 = new Point(dst.X + dst.Size.Width / 2, dst.Y + dst.Size.Height); break; case 3: p0 = new Point(dst.X + dst.Size.Width, dst.Y + dst.Size.Height / 2); p1 = new Point(dst.X, dst.Y + dst.Size.Height / 2); break; default: throw new System.Exception("Invalid rotation for direction arrow"); } g.DrawLine(arrowPen, p0, p1); } }
public void setTiles(List <Tile> tiles, Tileset tset) { this.tiles = tiles; this.invalidate(tset); }