调整间隔生成节点
This commit is contained in:
parent
314c35b8e2
commit
1dfaab4de9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,4 +22,10 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= MapConfig, meta = (ToolTip = "总层数", ClampMin = 2))
|
||||
int32 TotalLayers = 4;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= MapConfig, meta = (ToolTip = "节点水平间距"))
|
||||
int32 NodeOffsetX = 100;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= MapConfig, meta = (ToolTip = "节点垂直间距"))
|
||||
int32 NodeOffsetY = 300;
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "FishingMapSystem.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "ProjectFish/DataAsset/MapConfigAsset.h"
|
||||
|
||||
UFishingMapNode::UFishingMapNode()
|
||||
{
|
||||
@ -105,27 +106,22 @@ void UFishingMapSystem::GenerateNodes()
|
||||
|
||||
void UFishingMapSystem::CalculateNodePositions()
|
||||
{
|
||||
// float LayerSpacing = 1000.0f; // 层之间的距离
|
||||
// float NodeSpacing = 300.0f; // 节点之间的距离
|
||||
//
|
||||
// for (int32 LayerIndex = 0; LayerIndex < AllLayers.Num(); ++LayerIndex)
|
||||
// {
|
||||
// FMapLayer& Layer= AllLayers[LayerIndex];
|
||||
// int32 NodeCount = Layer.GetNodeNum();
|
||||
//
|
||||
// float X = LayerIndex * LayerSpacing;
|
||||
// float TotalWidth = (NodeCount - 1) * NodeSpacing;
|
||||
// float StartY = -TotalWidth * 0.5f;
|
||||
//
|
||||
// for (int32 NodeIndex = 0; NodeIndex <NodeCount; ++NodeIndex)
|
||||
// {
|
||||
// if (LayerNodes[NodeIndex])
|
||||
// {
|
||||
// float Y = StartY + NodeIndex * NodeSpacing;
|
||||
// LayerNodes[NodeIndex]->Position = FVector2D(X, Y);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (int32 LayerIndex = 0; LayerIndex < AllLayers.Num(); ++LayerIndex)
|
||||
{
|
||||
|
||||
FMapLayer& Layer= AllLayers[LayerIndex];
|
||||
int32 NodeCount = Layer.GetNodeNum();
|
||||
float TotalWidth = (NodeCount - 1) * (MapConfig->NodeOffsetX); //水平总距离
|
||||
float Y = LayerIndex * MapConfig->NodeOffsetY; //垂直高度
|
||||
|
||||
float StartX = -TotalWidth * 0.5f;
|
||||
|
||||
for (int32 NodeIndex = 0; NodeIndex <NodeCount; ++NodeIndex)
|
||||
{
|
||||
float X = StartX + NodeIndex * MapConfig->NodeOffsetX;
|
||||
Layer.GetNode(NodeIndex)->Position = FVector2D(X, Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UFishingMapSystem::GenerateConnections()
|
||||
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "MapConfigAsset.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "ProjectFish/Definations.h"
|
||||
#include "FishingMapSystem.generated.h"
|
||||
@ -50,7 +49,7 @@ public:
|
||||
UFishingMapSystem();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "地图配置"))
|
||||
UMapConfigAsset* MapConfig;
|
||||
class UMapConfigAsset* MapConfig;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, meta = (ToolTip = "所有节点"))
|
||||
TArray<TObjectPtr<UFishingMapNode>> AllNodes;
|
||||
Loading…
x
Reference in New Issue
Block a user