调整连线的生成算法
This commit is contained in:
parent
776de95929
commit
314c35b8e2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
"BuildId": "37670630",
|
"BuildId": "37670630",
|
||||||
"Modules":
|
"Modules":
|
||||||
{
|
{
|
||||||
"ProjectFish": "UnrealEditor-ProjectFish-0006.dll",
|
"ProjectFish": "UnrealEditor-ProjectFish.dll",
|
||||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0006.dll"
|
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,6 +85,7 @@ void UFishingMapSystem::GenerateNodes()
|
|||||||
{
|
{
|
||||||
// 随机生成节点数量
|
// 随机生成节点数量
|
||||||
int32 NodeCount = FMath::RandRange(MapConfig->Layer_MinNodes, MapConfig->Layer_MaxNodes);
|
int32 NodeCount = FMath::RandRange(MapConfig->Layer_MinNodes, MapConfig->Layer_MaxNodes);
|
||||||
|
//int32 NodeCount = 4;
|
||||||
// 生成节点
|
// 生成节点
|
||||||
for (int32 NodeIndex = 0; NodeIndex < NodeCount; ++NodeIndex)
|
for (int32 NodeIndex = 0; NodeIndex < NodeCount; ++NodeIndex)
|
||||||
{
|
{
|
||||||
@ -183,17 +184,18 @@ TArray<FSimpleConnection> UFishingMapSystem::GenerateNonCrossingConnections(int3
|
|||||||
int32 connectionBeginIndex = LastToNodeIndex;
|
int32 connectionBeginIndex = LastToNodeIndex;
|
||||||
int32 endIndex = ToNodes.GetNodeNum() - 1;
|
int32 endIndex = ToNodes.GetNodeNum() - 1;
|
||||||
//随机连线的最左侧位置,根据当前所在layer的index 调整概率
|
//随机连线的最左侧位置,根据当前所在layer的index 调整概率
|
||||||
int32 connectionEndIndex = FMath::Max(connectionBeginIndex,
|
// int32 connectionEndIndex = FMath::Max(connectionBeginIndex,
|
||||||
(FMath::RandRange(connectionBeginIndex, endIndex + (FromNodes.GetNodeNum() - NodeIndex)) - (FromNodes.GetNodeNum() - NodeIndex)) );
|
// (FMath::RandRange(connectionBeginIndex, endIndex + (FromNodes.GetNodeNum() - NodeIndex)) - (FromNodes.GetNodeNum() - NodeIndex)) );
|
||||||
|
int32 connectionEndIndex = FMath::RandRange(connectionBeginIndex, endIndex);
|
||||||
//随机指定当前node 连接上层node的范围
|
//随机指定当前node 连接上层node的范围
|
||||||
LastToNodeIndex = connectionEndIndex;
|
LastToNodeIndex = connectionEndIndex;
|
||||||
for(int32 i = connectionBeginIndex; i <= connectionEndIndex; ++i)
|
for(int32 i = connectionBeginIndex; i <= connectionEndIndex; ++i)
|
||||||
{
|
{
|
||||||
//添加连线
|
//添加连线
|
||||||
Connections.Add(FSimpleConnection(FromNodes.GetNode(NodeIndex)->NodeID, ToNodes.GetNode(connectionEndIndex)->NodeID));
|
Connections.Add(FSimpleConnection(FromNodes.GetNode(NodeIndex)->NodeID, ToNodes.GetNode(i )->NodeID));
|
||||||
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("下层 %d -> 上层 %d "),GetNodeAtLayerIndex(FromNodes.GetNode(NodeIndex)->NodeID),
|
UE_LOG(LogTemp, Warning, TEXT("下层 %d -> 上层 %d "),GetNodeAtLayerIndex(FromNodes.GetNode(NodeIndex)->NodeID),
|
||||||
GetNodeAtLayerIndex(ToNodes.GetNode(connectionEndIndex)->NodeID));
|
GetNodeAtLayerIndex(ToNodes.GetNode(i )->NodeID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//第二步 确保tolayer 每个节点都有连接线,没有连接线的分配 指定范围内的下层节点
|
//第二步 确保tolayer 每个节点都有连接线,没有连接线的分配 指定范围内的下层节点
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user