Exemple #1
0
    void QuatBridge(HexDirection direction, Vector3 center, Vector3 v1, Vector3 v2, Color c1)
    {
        HexCell neigbor_middle = hexCell.GetNeighbor(direction);

        if (neigbor_middle != null)
        {
            Vector3 bridge     = HexCellConf.GetBridge(direction);
            Vector3 v3         = v1 + bridge;
            Vector3 v4         = v2 + bridge;
            float   waterLevel = neigbor_middle.WaterLevel;
            if (!neigbor_middle.IsUnderWater())
            {
                waterLevel = Mathf.Min(hexCell.WaterLevel, neigbor_middle.Elevation);
            }
            v3.y = v4.y = waterLevel * HexCellConf.elevationStep;

            Color c2 = HexCellConf.color2;

            if (direction == HexDirection.Left || direction == HexDirection.LeftDown || direction == HexDirection.RightDown || !neigbor_middle.IsUnderWater())
            {
                if (hexCell.GetEdgeType(direction) == HexEdgeType.Slope)
                {
                    TriangulateEdgeTerracesQuat(v1, v2, c1, v3, v4, c2);
                }
                else
                {
                    TriangulateEdgeQuat(v1, v2, c1, v3, v4, c2);
                }
            }

            //Bridge
            ShareTriangle(direction, neigbor_middle, v2, v4, c1, c2);
        }
    }
Exemple #2
0
    void QuatBridge(HexDirection direction, Vector3 center, Vector3 v1, Vector3 v2, Color c1)
    {
        HexCell neigbor_middle = hexCell.GetNeighbor(direction);

        if (neigbor_middle != null)
        {
            Vector3 bridge = HexCellConf.GetBridge(direction);
            Vector3 v3     = v1 + bridge;
            Vector3 v4     = v2 + bridge;
            v3.y = v4.y = neigbor_middle.Elevation * HexCellConf.elevationStep;

            terrainTypeVector3.y = (int)neigbor_middle.terrainType;
            Color c2 = HexCellConf.color2;

            if (hexCell.GetEdgeType(direction) == HexEdgeType.Slope)
            {
                TriangulateEdgeTerracesQuat(v1, v2, c1, v3, v4, c2);
            }
            else
            {
                TriangulateEdgeQuat(v1, v2, c1, v3, v4, c2);
            }

            //Bridge
            ShareTriangle(direction, neigbor_middle, v2, v4, c1, c2);
        }
    }
Exemple #3
0
    void ShareTriangle(HexDirection direction, HexCell neigbor_middle, Vector3 v2, Vector3 v4, Color c1, Color c2)
    {
        if (direction == HexDirection.Left)
        {
            return;
        }

        HexCell neigbor_next = hexCell.GetNeighbor(direction.Next());

        if (neigbor_next != null)
        {
            Vector3 v5 = v2 + HexCellConf.GetBridge(direction.Next());
            v5.y = neigbor_next.Elevation * HexCellConf.elevationStep;

            terrainTypeVector3.z = (int)neigbor_next.terrainType;
            Color c3 = HexCellConf.color3;
            if (hexCell.GetEdgeType(direction) == HexEdgeType.Slope)
            {
                TriangulateCornerTerracesCliff(v5, c3, neigbor_next, v2, c1, hexCell, v4, c2, neigbor_middle);
            }
            else if (hexCell.GetEdgeType(direction.Next()) == HexEdgeType.Slope)
            {
                TriangulateCornerTerracesCliff(v4, c2, neigbor_middle, v5, c3, neigbor_next, v2, c1, hexCell);
            }
            else if (neigbor_next.GetEdgeType(direction.Previous()) == HexEdgeType.Slope)
            {
                TriangulateCornerTerracesCliff(v2, c1, hexCell, v4, c2, neigbor_middle, v5, c3, neigbor_next);
            }
            else
            {
                AddTriangle(v4, v5, v2);
                AddTriangleColor(c2, c3, c1);
                AddTriangleTerrain(terrainTypeVector3);
                AddTriangleUV(Vector2.zero, Vector2.zero, Vector2.zero);
            }
        }
    }
Exemple #4
0
    void ShareTriangle(HexDirection direction, HexCell neigbor_middle, Vector3 v2, Vector3 v4, Color c1, Color c2)
    {
        HexCell neigbor_next = hexCell.GetNeighbor(direction.Next());

        if (neigbor_next != null)
        {
            if (direction == HexDirection.LeftUp || direction == HexDirection.Left)
            {
                if (neigbor_next.IsUnderWater())
                {
                    return;
                }
                if (direction == HexDirection.Left)
                {
                    if (neigbor_middle.IsUnderWater())
                    {
                        return;
                    }
                }
            }
            if (direction == HexDirection.RightUp || direction == HexDirection.Right)
            {
                if (neigbor_middle.IsUnderWater())
                {
                    return;
                }
                if (direction == HexDirection.Right)
                {
                    if (neigbor_next.IsUnderWater())
                    {
                        return;
                    }
                }
            }

            Vector3 v5         = v2 + HexCellConf.GetBridge(direction.Next());
            float   waterLevel = neigbor_next.WaterLevel;
            if (!neigbor_next.IsUnderWater())
            {
                waterLevel = Mathf.Min(hexCell.WaterLevel, neigbor_next.Elevation);
            }
            v5.y = waterLevel * HexCellConf.elevationStep;

            Color c3 = HexCellConf.color3;
            if (hexCell.GetEdgeType(direction) == HexEdgeType.Slope)
            {
                TriangulateCornerTerracesCliff(v5, c3, neigbor_next, v2, c1, hexCell, v4, c2, neigbor_middle);
            }
            else if (hexCell.GetEdgeType(direction.Next()) == HexEdgeType.Slope)
            {
                TriangulateCornerTerracesCliff(v4, c2, neigbor_middle, v5, c3, neigbor_next, v2, c1, hexCell);
            }
            else if (neigbor_next.GetEdgeType(direction.Previous()) == HexEdgeType.Slope)
            {
                TriangulateCornerTerracesCliff(v2, c1, hexCell, v4, c2, neigbor_middle, v5, c3, neigbor_next);
            }
            else
            {
                AddTriangle(v4, v5, v2);
                AddTriangleColor(c2, c3, c1);
            }
        }
    }