예제 #1
0
    public void AddBridge(HexDirection direction, HexMesh hex)
    {
        HexMesh neighbor = GetNeighbor(direction, hex);

        if (neighbor == null)
        {
            return;
        }
        hex.AddNeighbor(direction, neighbor);
        Vector3[] vertices = new Vector3[4];
        vertices[0] = hex.GetCorner(direction);
        vertices[1] = hex.GetCorner(direction.Next());
        vertices[2] = neighbor.GetCorner(direction.Opposite());
        vertices[3] = neighbor.GetCorner(direction.Opposite().Next());
        int[] triangles =
        {
            lVertices.IndexOf(vertices[0]),
            lVertices.IndexOf(vertices[2]),
            lVertices.IndexOf(vertices[1]),
            lVertices.IndexOf(vertices[2]),
            lVertices.IndexOf(vertices[0]),
            lVertices.IndexOf(vertices[3])
        };
        if (!ExistsInList(triangles, lTriangles)) //double check to not add duplicate triangles
        {
            lTriangles.AddRange(triangles);
        }
        else
        {
            Debug.Log("!!Trying to add duplicate triangles!!");
        }
    }