添加节点状态
This commit is contained in:
parent
1dfaab4de9
commit
0fc222490a
BIN
ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll
Normal file
BIN
ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll
Normal file
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
"BuildId": "37670630",
|
"BuildId": "37670630",
|
||||||
"Modules":
|
"Modules":
|
||||||
{
|
{
|
||||||
"ProjectFish": "UnrealEditor-ProjectFish.dll",
|
"ProjectFish": "UnrealEditor-ProjectFish-0001.dll",
|
||||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll"
|
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,6 +420,13 @@ enum class EMapNodeType : uint8
|
|||||||
Boss UMETA(DisplayName = "关底Boss")
|
Boss UMETA(DisplayName = "关底Boss")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UENUM(BlueprintType)
|
||||||
|
enum class EMapNodeState : uint8
|
||||||
|
{
|
||||||
|
Moveable UMETA(DisplayName = "可移动到"),
|
||||||
|
Immovable UMETA(DisplayName = "不可移动到"),
|
||||||
|
};
|
||||||
|
|
||||||
//地图层
|
//地图层
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
struct FMapLayer
|
struct FMapLayer
|
||||||
|
|||||||
@ -58,6 +58,16 @@ int32 UFishingMapSystem::GetNodeAtLayerIndex(FGuid NodeID) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TObjectPtr<UFishingMapNode> UFishingMapSystem::GetNode(FGuid NodeID)
|
||||||
|
{
|
||||||
|
for (auto node: AllNodes)
|
||||||
|
{
|
||||||
|
if (node->NodeID == NodeID)
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void UFishingMapSystem::ClearMap()
|
void UFishingMapSystem::ClearMap()
|
||||||
{
|
{
|
||||||
AllNodes.Empty();
|
AllNodes.Empty();
|
||||||
@ -65,6 +75,20 @@ void UFishingMapSystem::ClearMap()
|
|||||||
AllLayers.Empty();
|
AllLayers.Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UFishingMapSystem::MoveToNode(FGuid NodeID)
|
||||||
|
{
|
||||||
|
TArray<FGuid> MoveableNodeIDs;
|
||||||
|
GetAllConnectedNodes(NodeID, MoveableNodeIDs);
|
||||||
|
for (auto node:AllNodes)
|
||||||
|
{
|
||||||
|
if (MoveableNodeIDs.Find(node->NodeID) == -1)
|
||||||
|
{
|
||||||
|
//节点不在可移动的列表内,更新状态
|
||||||
|
OnNodeStateChange.Broadcast(EMapNodeState::Immovable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UFishingMapSystem::GenerateNodes()
|
void UFishingMapSystem::GenerateNodes()
|
||||||
{
|
{
|
||||||
@ -219,3 +243,19 @@ TArray<FSimpleConnection> UFishingMapSystem::GenerateNonCrossingConnections(int3
|
|||||||
|
|
||||||
return Connections;
|
return Connections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UFishingMapSystem::GetAllConnectedNodes(FGuid NodeID, TArray<FGuid>& ConnectedNodes)
|
||||||
|
{
|
||||||
|
//获取所有可移动的节点
|
||||||
|
ConnectedNodes.Add(NodeID);
|
||||||
|
if (GetNode(NodeID)->ConnectedNodes.Num() != 0)
|
||||||
|
{
|
||||||
|
ConnectedNodes.Append(GetNode(NodeID)->ConnectedNodes);
|
||||||
|
for (auto ConnectedNode : GetNode(NodeID)->ConnectedNodes)
|
||||||
|
{
|
||||||
|
GetAllConnectedNodes(ConnectedNode, ConnectedNodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -5,7 +5,7 @@
|
|||||||
#include "ProjectFish/Definations.h"
|
#include "ProjectFish/Definations.h"
|
||||||
#include "FishingMapSystem.generated.h"
|
#include "FishingMapSystem.generated.h"
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnNodeStateChange, EMapNodeState, NewState);
|
||||||
|
|
||||||
// 简化的地图节点
|
// 简化的地图节点
|
||||||
UCLASS(BlueprintType)
|
UCLASS(BlueprintType)
|
||||||
@ -23,6 +23,10 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "节点类型"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "节点类型"))
|
||||||
EMapNodeType NodeType = EMapNodeType::Battle;
|
EMapNodeType NodeType = EMapNodeType::Battle;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "节点状态"))
|
||||||
|
EMapNodeState NodeState = EMapNodeState::Moveable;
|
||||||
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "层级索引"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "层级索引"))
|
||||||
int32 LayerIndex = 0;
|
int32 LayerIndex = 0;
|
||||||
|
|
||||||
@ -60,25 +64,33 @@ public:
|
|||||||
UPROPERTY(BlueprintReadOnly, meta = (ToolTip = "按层级组织的节点"))
|
UPROPERTY(BlueprintReadOnly, meta = (ToolTip = "按层级组织的节点"))
|
||||||
TArray<FMapLayer> AllLayers;
|
TArray<FMapLayer> AllLayers;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintAssignable)
|
||||||
|
FOnNodeStateChange OnNodeStateChange;
|
||||||
|
|
||||||
// 生成地图
|
// 生成地图
|
||||||
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
||||||
void GenerateMap();
|
void GenerateMap();
|
||||||
|
|
||||||
// 使用配置生成地图
|
// 使用配置生成地图
|
||||||
void GenerateMapWithConfig(const UMapConfigAsset* Config);
|
void GenerateMapWithConfig(const UMapConfigAsset* Config);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取总层数
|
// 获取总层数
|
||||||
int32 GetLayerCount() const { return AllLayers.Num(); }
|
int32 GetLayerCount() const { return AllLayers.Num(); }
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = "FishingMap")
|
UFUNCTION(BlueprintPure, Category = "FishingMap")
|
||||||
int32 GetNodeAtLayerIndex(FGuid NodeID) const;
|
int32 GetNodeAtLayerIndex(FGuid NodeID) const;
|
||||||
|
|
||||||
|
TObjectPtr<UFishingMapNode> GetNode(FGuid NodeID) ;
|
||||||
|
|
||||||
// 清空地图
|
// 清空地图
|
||||||
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
||||||
void ClearMap();
|
void ClearMap();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
||||||
|
void MoveToNode(FGuid NodeID);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GetAllConnectedNodes(FGuid NodeID, TArray<FGuid>& ConnectedNodes);
|
||||||
protected:
|
protected:
|
||||||
// 生成节点
|
// 生成节点
|
||||||
void GenerateNodes();
|
void GenerateNodes();
|
||||||
@ -92,4 +104,6 @@ protected:
|
|||||||
|
|
||||||
// 生成无交叉的连接方案
|
// 生成无交叉的连接方案
|
||||||
TArray<FSimpleConnection> GenerateNonCrossingConnections(int32 FromLayer, int32 ToLayer);
|
TArray<FSimpleConnection> GenerateNonCrossingConnections(int32 FromLayer, int32 ToLayer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user