//仅处理无临边的情况 private void NoNeighborConnection(HexDirectionEnum direction, HexCell cell, EdgeVertices edge) { Vector3 center = cell.Position; Vector3 bridge = HexMetrics.GetOneBridge(direction); Vector3 v3 = edge.v1 + bridge; Vector3 v4 = edge.v5 + bridge; Vector3 v5 = center + HexMetrics.GetFirstCorner(direction); Vector3 v6 = center + HexMetrics.GetSecondCorner(direction); HexCell prevNeighbor = cell.GetNeighbor(direction.Previous()); HexCell nextNeighbor = cell.GetNeighbor(direction.Next()); v6.y = v5.y = v4.y = v3.y = 0; EdgeVertices edge2 = new EdgeVertices(v5, v6); if (nextNeighbor == null && prevNeighbor != null) { edge2 = new EdgeVertices(v3, v6); HexCell noneCell = new GameObject().AddComponent <HexCell>(); noneCell.Index = cell.Index; TriangulateCorner(edge.v1, cell, v5, prevNeighbor, v3, noneCell); DestroyObject(noneCell.gameObject); } if (cell.Elevation == HexMetrics.elevationDiffer) { TriangulateEdgeTerraces(edge, cell, edge2, cell, cell.HasRoadThroughEdge(direction)); } else { TriangulateEdgeStrip(edge, weights1, cell.Index, edge2, weights1, cell.Index, cell.HasRoadThroughEdge(direction)); } }
//仅处理无临边的情况 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); }