diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll new file mode 100644 index 0000000..6ed0f66 Binary files /dev/null and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll differ diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor-0001.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor-0001.dll new file mode 100644 index 0000000..a5bbc51 Binary files /dev/null and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor-0001.dll differ diff --git a/ProjectFish/Binaries/Win64/UnrealEditor.modules b/ProjectFish/Binaries/Win64/UnrealEditor.modules index 22c08e6..fe900f8 100644 --- a/ProjectFish/Binaries/Win64/UnrealEditor.modules +++ b/ProjectFish/Binaries/Win64/UnrealEditor.modules @@ -2,7 +2,7 @@ "BuildId": "37670630", "Modules": { - "ProjectFish": "UnrealEditor-ProjectFish.dll", - "ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll" + "ProjectFish": "UnrealEditor-ProjectFish-0001.dll", + "ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll" } } \ No newline at end of file diff --git a/ProjectFish/Source/ProjectFish/Definations.h b/ProjectFish/Source/ProjectFish/Definations.h index 240591a..2c936f6 100644 --- a/ProjectFish/Source/ProjectFish/Definations.h +++ b/ProjectFish/Source/ProjectFish/Definations.h @@ -420,6 +420,13 @@ enum class EMapNodeType : uint8 Boss UMETA(DisplayName = "关底Boss") }; +UENUM(BlueprintType) +enum class EMapNodeState : uint8 +{ + Moveable UMETA(DisplayName = "可移动到"), + Immovable UMETA(DisplayName = "不可移动到"), +}; + //地图层 USTRUCT(BlueprintType) struct FMapLayer diff --git a/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.cpp b/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.cpp index 1ada8ba..e7c646f 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.cpp +++ b/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.cpp @@ -58,6 +58,16 @@ int32 UFishingMapSystem::GetNodeAtLayerIndex(FGuid NodeID) const return -1; } +TObjectPtr UFishingMapSystem::GetNode(FGuid NodeID) +{ + for (auto node: AllNodes) + { + if (node->NodeID == NodeID) + return node; + } + return nullptr; +} + void UFishingMapSystem::ClearMap() { AllNodes.Empty(); @@ -65,6 +75,20 @@ void UFishingMapSystem::ClearMap() AllLayers.Empty(); } +void UFishingMapSystem::MoveToNode(FGuid NodeID) +{ + TArray MoveableNodeIDs; + GetAllConnectedNodes(NodeID, MoveableNodeIDs); + for (auto node:AllNodes) + { + if (MoveableNodeIDs.Find(node->NodeID) == -1) + { + //节点不在可移动的列表内,更新状态 + OnNodeStateChange.Broadcast(EMapNodeState::Immovable); + } + } +} + void UFishingMapSystem::GenerateNodes() { @@ -219,3 +243,19 @@ TArray UFishingMapSystem::GenerateNonCrossingConnections(int3 return Connections; } + +void UFishingMapSystem::GetAllConnectedNodes(FGuid NodeID, TArray& ConnectedNodes) +{ + //获取所有可移动的节点 + ConnectedNodes.Add(NodeID); + if (GetNode(NodeID)->ConnectedNodes.Num() != 0) + { + ConnectedNodes.Append(GetNode(NodeID)->ConnectedNodes); + for (auto ConnectedNode : GetNode(NodeID)->ConnectedNodes) + { + GetAllConnectedNodes(ConnectedNode, ConnectedNodes); + } + } + + +} \ No newline at end of file diff --git a/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.h b/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.h index 76986f0..6ff26b3 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.h +++ b/ProjectFish/Source/ProjectFish/Gameplay/MapSystem/FishingMapSystem.h @@ -5,7 +5,7 @@ #include "ProjectFish/Definations.h" #include "FishingMapSystem.generated.h" - +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnNodeStateChange, EMapNodeState, NewState); // 简化的地图节点 UCLASS(BlueprintType) @@ -23,6 +23,10 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "节点类型")) EMapNodeType NodeType = EMapNodeType::Battle; + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "节点状态")) + EMapNodeState NodeState = EMapNodeState::Moveable; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "层级索引")) int32 LayerIndex = 0; @@ -60,25 +64,33 @@ public: UPROPERTY(BlueprintReadOnly, meta = (ToolTip = "按层级组织的节点")) TArray AllLayers; + UPROPERTY(BlueprintAssignable) + FOnNodeStateChange OnNodeStateChange; + // 生成地图 UFUNCTION(BlueprintCallable, Category = "FishingMap") void GenerateMap(); // 使用配置生成地图 void GenerateMapWithConfig(const UMapConfigAsset* Config); - - - + // 获取总层数 int32 GetLayerCount() const { return AllLayers.Num(); } UFUNCTION(BlueprintPure, Category = "FishingMap") int32 GetNodeAtLayerIndex(FGuid NodeID) const; + + TObjectPtr GetNode(FGuid NodeID) ; // 清空地图 UFUNCTION(BlueprintCallable, Category = "FishingMap") void ClearMap(); + UFUNCTION(BlueprintCallable, Category = "FishingMap") + void MoveToNode(FGuid NodeID); + +private: + void GetAllConnectedNodes(FGuid NodeID, TArray& ConnectedNodes); protected: // 生成节点 void GenerateNodes(); @@ -92,4 +104,6 @@ protected: // 生成无交叉的连接方案 TArray GenerateNonCrossingConnections(int32 FromLayer, int32 ToLayer); -}; \ No newline at end of file +}; + +