示例#1
0
        private void PaintElevation(int max, int min, HexagonData hex, Graphics g)
        {
            Color elevationColor;

            if (hex.Elevation < Sealevel)
            {
                double seaIndex = (double)(hex.Elevation - Sealevel) / (double)(min - Sealevel);
                elevationColor = seaGradient.Get(seaIndex);
            }
            else
            {
                double landIndex = (double)(hex.Elevation - Sealevel) / (double)(max - Sealevel);
                elevationColor = landGradient.Get(landIndex);
            }

            g.FillPolygon(new SolidBrush(elevationColor), HexToPoints(hex.Row, hex.Col));
        }
示例#2
0
        public List <HexagonData> GetAdjacent(HexagonData hex)
        {
            int parity = hex.Col % 2;

            var returnList = new List <HexagonData>()
            {
                Get(hex.Row - 1, hex.Col),
                Get(hex.Row + 1, hex.Col),

                Get(hex.Row - 1 + parity, hex.Col + 1),
                Get(hex.Row + parity, hex.Col + 1),

                Get(hex.Row - 1 + parity, hex.Col - 1),
                Get(hex.Row + parity, hex.Col - 1),
            };

            return(returnList.Where(h => h != null).ToList());
        }
示例#3
0
        private void PaintTerrain(HexagonData hex, Graphics g)
        {
            var color = hex.Terrain.Color;

            if (hex.Elevation < Sealevel)
            {
                color = Brushes.DarkBlue;
            }

            g.FillPolygon(color, HexToPoints(hex.Row, hex.Col));

            var fontFamily = new FontFamily("Times New Roman");
            var font       = new Font(fontFamily, parameters.FontSize, FontStyle.Regular, GraphicsUnit.Pixel);

            string coordinate = string.Format("[{0},{1}]", hex.Col, hex.Row);
            string glyph      = hex.Terrain.Glyph;

            if (parameters.GlyphsEnabled)
            {
                g.DrawString(hex.Terrain.Glyph, font, hex.Terrain.TextColor, MiddleText(hex.Row, hex.Col));
            }
        }
示例#4
0
 public List <HexagonData> GetNonBlankAdjacent(HexagonData hex)
 {
     return(GetAdjacent(hex).Where(h => h.Terrain.TerrainEnum != TerrainEnum.NoTerrain).ToList());
 }