示例#1
0
    private void TriangulateEdgeTerrace(
        HexCell c1, Vector3 beginLeft, Vector3 beginRight,
        HexCell c2, Vector3 endLeft, Vector3 endRight)
    {
        Vector3 v3     = HexMatrics.TerraceLerp(beginLeft, endLeft, 1);
        Vector3 v4     = HexMatrics.TerraceLerp(beginRight, endRight, 1);
        Color   color2 = HexMatrics.TerraceLerpColor(c1.CellColor, c2.CellColor, 1);


        AddQuad(beginLeft, beginRight, v3, v4);
        AddQuadColor(c1.CellColor, color2);

        for (int n = 2; n < HexMatrics.TerracesSteps; n++)
        {
            Vector3 v1     = v3;
            Vector3 v2     = v4;
            Color   color1 = color2;

            v3     = HexMatrics.TerraceLerp(beginLeft, endLeft, n);
            v4     = HexMatrics.TerraceLerp(beginRight, endRight, n);
            color2 = HexMatrics.TerraceLerpColor(c1.CellColor, c2.CellColor, n);

            AddQuad(v1, v2, v3, v4);
            AddQuadColor(color1, color2);
        }



        AddQuad(v3, v4, endLeft, endRight);
        AddQuadColor(color2, c2.CellColor);
    }
示例#2
0
    private void TriangulateConnection(Vector3 v1, Vector3 v2, HexDirection dir, HexCell cell)
    {
        if (cell.GetNeiborCell(dir) == null)
        {
            return;
        }

        Vector3 birdge = HexMatrics.GetBridge(dir);

        Vector3 v3 = v1 + birdge;
        Vector3 v4 = v2 + birdge;

        HexCell neiborCell   = cell.GetNeiborCell(dir) ?? cell;
        HexCell nextNeighbor = cell.GetNeiborCell(dir.Next()) ?? cell;

        //Debug.Log(neiborCell.Elevation);

        v3.y = v4.y = neiborCell.Elevation * HexMatrics.ElevationStep;

        /*AddQuad(v1, v2, v3, v4);
         * AddQuadColor(cell.CellColor, neiborCell.CellColor);
         */

        TriangulateEdgeTerrace(cell, v1, v2, neiborCell, v3, v4);

        if (dir <= HexDirection.E && nextNeighbor != null)
        {
            Vector3 v5 = v2 + HexMatrics.GetBridge(dir.Next());
            v5.y = nextNeighbor.Elevation * HexMatrics.ElevationStep;
            AddTriangle(v2, v4, v5);
            AddTriangleColor(cell.CellColor, neiborCell.CellColor, nextNeighbor.CellColor);
        }
    }
示例#3
0
    void Triangulate(HexDirection direction, HexCell cell)
    {
        Vector3 center = cell.transform.localPosition;
        Vector3 v1     = center + HexMatrics.GetFirstSolidCorner(direction);
        Vector3 v2     = center + HexMatrics.GetSecondSolidCorner(direction);

        AddTriangle(center, v1, v2);
        AddTriangleColor(cell.color);

        Vector3 v3 = center + HexMatrics.GetFirstCorner(direction);
        Vector3 v4 = center + HexMatrics.GetSecondCorner(direction);

        AddQuad(v1, v2, v3, v4);

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

        AddQuadColor(
            cell.color,
            cell.color,
            (cell.color + prevNeighbor.color + neighbor.color) / 3f,
            (cell.color + neighbor.color + nextNeighbor.color) / 3f
            );
    }
示例#4
0
    private void TriangulateCell(HexCell cell)
    {
        Vector3 center = cell.transform.localPosition;

        for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++)
        {
            Vector3 v1 = center + HexMatrics.GetFirstSoildCorner(d);
            Vector3 v2 = center + HexMatrics.GetSecondSoildCorner(d);
            AddTriangle(center, v1, v2);
            AddTriangleColor(cell.CellColor);
            if (d <= HexDirection.SE)
            {
                TriangulateConnection(v1, v2, d, cell);
            }
        }
    }
示例#5
0
    void Triangulate(HexDirection direction, HexCell cell)
    {
        Vector3 center = cell.transform.localPosition;
        Vector3 v1     = center + HexMatrics.GetFirstSolidCorner(direction);
        Vector3 v2     = center + HexMatrics.GetSecondSolidCorner(direction);


        AddTriangle(center, v1, v2);
        AddTriangleColor(cell.color);

        Vector3 bridge = HexMatrics.GetBridge(direction);

        Vector3 v3 = v1 + bridge;
        Vector3 v4 = v2 + bridge;

        AddQuad(v1, v2, v3, v4);

        HexCell prevNeighbor = cell.GetNeighbor(direction.Previous()) ?? cell;
        HexCell neighbor     = cell.GetNeighbor(direction) ?? cell;
        HexCell nextneighbor = cell.GetNeighbor(direction.Next()) ?? cell;


        Color bridgeColor = (cell.color + neighbor.color) * 0.5f;

        AddQuadColor(cell.color, bridgeColor);

        AddTriangle(v1, center + HexMatrics.GetFirstCorner(direction), v3);
        AddTriangleColor
        (
            cell.color,
            (cell.color + prevNeighbor.color + neighbor.color) / 3f,
            bridgeColor
        );

        AddTriangle(v2, v4, center + HexMatrics.GetSecondCorner(direction));
        AddTriangleColor
        (
            cell.color,
            bridgeColor,
            (cell.color + nextneighbor.color + neighbor.color) / 3f
        );
    }
示例#6
0
    public HexEdgeType GetEdgeType(HexDirection dir)
    {
        HexCell neibor = NeiborCells[(int)dir];

        return(HexMatrics.GetEdgeType(_elevation, neibor.Elevation));
    }