Ejemplo n.º 1
0
    //仅处理无临边的情况
    private void NoNeighborConnection(HexDirectionEnum direction, HexCell cell, Vector3 v1, Vector3 v2)
    {
        Vector3 center = cell.center;

        Vector3 bridge = HexMetrics.GetOneBridge(direction);
        Vector3 v3     = v1 + bridge;
        Vector3 v4     = v2 + bridge;
        Vector3 v5     = center + HexMetrics.GetFirstCorner(direction);
        Vector3 v6     = center + HexMetrics.GetSecondConrner(direction);

        HexCell prevNeighbor = cell.GetNeighbor(direction.Previous());
        HexCell nextNeighbor = cell.GetNeighbor(direction.Next());

        Vector3 v7 = v5;
        Vector3 v8 = v6;

        if (nextNeighbor == null && prevNeighbor != null)
        {
            v7 = v3;
            v8 = v6;

            Color firstColor = (cell.color + cell.color + prevNeighbor.color) / 3f;
            AddTriangle(v1, v5, v3);
            AddTriangleColor(cell.color, firstColor, cell.color);
        }

        AddQuad(v1, v2, v7, v8);
        AddQuadColor(cell.color);
    }
Ejemplo n.º 2
0
    private void RightTrangulateConnection(HexDirectionEnum direction, HexCell cell, Vector3 v1, Vector3 v2)
    {
        HexCell neighbor = cell.GetNeighbor(direction);

        if (neighbor == null)
        {
            NoNeighborConnection(direction, cell, v1, v2);
            return;
        }
        Vector3 bridge = HexMetrics.GetTwoBridge(direction);
        Vector3 v3     = v1 + bridge;
        Vector3 v4     = v2 + bridge;

        AddQuad(v1, v2, v3, v4);
        AddQuadColor(cell.color, neighbor.color);

        HexCell nextNeighbor = cell.GetNeighbor(direction.Next());

        if (nextNeighbor != null)
        {
            AddTriangle(v2, v4, v2 + HexMetrics.GetTwoBridge(direction.Next()));
            AddTriangleColor(cell.color, neighbor.color, nextNeighbor.color);
        }
        else
        {
            //绘制缺失的小三角
            AddTriangle(v2, v4, cell.center + HexMetrics.GetSecondConrner(direction));
            AddTriangleColor(cell.color, neighbor.color, (cell.color + neighbor.color) * 0.5f);
        }
        //绘制缺失的小三角
        HexCell prevNeighbor = cell.GetNeighbor(direction.Previous());

        if (prevNeighbor == null)
        {
            AddTriangle(v1, cell.center + HexMetrics.GetFirstCorner(direction), v3);
            AddTriangleColor(cell.color, (cell.color + cell.color + neighbor.color) / 3f, neighbor.color);
        }
    }