Example #1
0
        private void RenderHexagon(Hexagon hexagon)
        {
            var visualSettings           = World.GameSettings.VisualSettings;
            var colorCollection          = visualSettings.ColorCollection;
            var layoutSettings           = World.GameSettings.LayoutSettings;
            var worldPosition            = hexagon.Position.GetWorldPosition(layoutSettings.HexagonRadius, layoutSettings.HexagonMargin);
            var corners                  = Corners.Select(c => c * layoutSettings.HexagonRadius + worldPosition).ToArray();
            var innerColor               = colorCollection.GetInnerHexagonColor(hexagon.ResourceType);
            var outerColor               = colorCollection.GetOuterHexagonColor(hexagon.ResourceType);
            var center                   = new CCV3F_C4B(worldPosition, innerColor);
            var adjacentHexagonPositions = hexagon.Position.GetAdjacentHexagonPositions();

            for (int i = 0; i < corners.Length; i++)
            {
                var p1 = new CCV3F_C4B(corners[i], outerColor);
                var p2 = new CCV3F_C4B(corners[(i + 1) % corners.Length], outerColor);
                DrawNode.DrawTriangle(p1, center, p2);
                if (World.HexagonManager[adjacentHexagonPositions[(6 - i + 2) % 6]]?.ResourceType != hexagon.ResourceType)
                {
                    DrawNode.DrawLine(corners[i], corners[(i + 1) % corners.Length], visualSettings.HexagonOuterBorderThickness, colorCollection.HexagonBorder);
                }
            }
            DrawNode.DrawText(worldPosition, hexagon.ResourceType.GetText(), Font.ArialFonts[32], new CCSize(layoutSettings.HexagonRadius * 2, layoutSettings.HexagonRadius * 2));
        }