protected override void DrawHex(Graphics graphics, Hex hex, int alpha = 0) { HexCoordinate positionOnVisibleMap = hex.Coordinate.Minus(UiInterface.GetMapBox().TopLeftCoordinate); Point positionOnScreen = PositionManager.HexToScreen(positionOnVisibleMap); var pictureLocationAndSize = new Rectangle(positionOnScreen, new Size(50, 44)); if (hex.RiverSections.Count == 0) { return; } else if (hex.RiverSections.Count == 1) { var river = hex.RiverSections[0]; DrawSection(graphics, river, pictureLocationAndSize); } //else if (hex.RiverSections.Count == 2 && hex.RiverSections[0].Type == hex.RiverSections[1].Type) //{ // graphics.DrawArc(); //} else { foreach (var riverSection in hex.RiverSections) { DrawSection(graphics, riverSection, pictureLocationAndSize); } } }
protected override void DrawHex(Graphics graphics, Hex hex, int alpha = 100) { HexCoordinate positionOnVisibleMap = hex.Coordinate.Minus(UiInterface.GetMapBox().TopLeftCoordinate); Point positionOnScreen = PositionManager.HexToScreen(positionOnVisibleMap); positionOnScreen.Offset(-1, -1); var size = new Size(TileConfigInterface.HexWidth + 2, TileConfigInterface.HexHeight + 2); var pictureLocationAndSize = new Rectangle(positionOnScreen, size); int typeAlpha = 100; if (hex.FogOfWar == 1) //Draw partially transparent fog of war { typeAlpha = 50; } else if (hex.FogOfWar == 2) //Don't draw any fog of war { return; } float dAlpha = (typeAlpha / 100.0f) * (alpha / 100.0f); var iconImageLocation = "Images/FogOfWar.png"; using (var image = Tiles.GetImage(iconImageLocation)) { if (typeAlpha == 100 && alpha == 100) { graphics.DrawImage(image, pictureLocationAndSize); } else { ColorMatrix matrix = new ColorMatrix(); //set the opacity matrix.Matrix33 = dAlpha; //create image attributes ImageAttributes attributes = new ImageAttributes(); //set the color(opacity) of the image attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //now draw the image graphics.DrawImage(image, pictureLocationAndSize, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); } } }
protected override void DrawHex(Graphics graphics, Hex hex, int alpha = 0) { HexCoordinate positionOnVisibleMap = hex.Coordinate.Minus(UiInterface.GetMapBox().TopLeftCoordinate); Point positionOnScreen = PositionManager.HexToScreen(positionOnVisibleMap); var pictureLocationAndSize = new Rectangle(positionOnScreen, new Size(50, 44)); foreach (var roadSection in hex.RoadSections) { var points = HexConnectionPointsFor(roadSection); var pen = GetRoadPen(roadSection.Type); var from = new Point(pictureLocationAndSize.X + points[0], pictureLocationAndSize.Y + points[1]); var to = new Point(pictureLocationAndSize.X + points[2], pictureLocationAndSize.Y + points[3]); graphics.DrawLine(pen, from, to); } }
protected override void DrawHex(Graphics graphics, Hex hex, int alpha = 100) { HexCoordinate positionOnVisibleMap = hex.Coordinate.Minus(UiInterface.GetMapBox().TopLeftCoordinate); Point positionOnScreen = PositionManager.HexToScreen(positionOnVisibleMap); var pictureLocationAndSize = new Rectangle(positionOnScreen, new Size(TileConfigInterface.HexWidth, TileConfigInterface.HexHeight)); var tileMarker = hex.TerrainId + "|" + hex.VegetationId; if (!_mapTileImages.ContainsKey(tileMarker)) { Image terrainTile = CreateTerrainImage(hex); _mapTileImages[tileMarker] = terrainTile as Bitmap; } graphics.DrawImage((Bitmap)_mapTileImages[tileMarker].Clone(), pictureLocationAndSize); }
protected override void DrawHex(Graphics graphics, Hex hex, int alpha) { HexCoordinate selectedCoordinate = hex.Coordinate; if (selectedCoordinate != null) { HexCoordinate positionOnVisibleMap = selectedCoordinate.Minus(UiInterface.GetMapBox().TopLeftCoordinate); Point positionOnScreen = PositionManager.HexToScreen(positionOnVisibleMap); var pictureLocationAndSize = new Rectangle(positionOnScreen, new Size(50, 44)); using (var selectImage = Image.FromFile("Images/SelectBorder.png")) { graphics.DrawImage(selectImage, pictureLocationAndSize); } } }
protected override void DrawHex(Graphics graphics, Hex hex, int alpha = 100) { //Change composite mode so that previous image in that hex gets overwritten, ignoring transparency graphics.CompositingMode = CompositingMode.SourceCopy; HexCoordinate positionOnVisibleMap = hex.Coordinate.Minus(UiInterface.GetMapBox().TopLeftCoordinate); Point positionOnScreen = PositionManager.HexToScreen(positionOnVisibleMap); positionOnScreen.Offset(TileConfigInterface.HexWidth / 4, TileConfigInterface.HexHeight / 4); var size = new Size(TileConfigInterface.HexWidth / 2, TileConfigInterface.HexHeight / 2); var pictureLocationAndSize = new Rectangle(positionOnScreen, size); var iconImageLocation = Tiles.GetIcon(hex.Icons[0]).ImageLocation; using (var image = Tiles.GetImage(iconImageLocation)) { if (alpha == 100) { graphics.DrawImage(image, pictureLocationAndSize); } else { ColorMatrix matrix = new ColorMatrix(); //set the opacity matrix.Matrix33 = alpha / 100.0f; //create image attributes ImageAttributes attributes = new ImageAttributes(); //set the color(opacity) of the image attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //now draw the image graphics.DrawImage(image, pictureLocationAndSize, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); } } }