添加节点状态
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",
|
||||
"Modules":
|
||||
{
|
||||
"ProjectFish": "UnrealEditor-ProjectFish.dll",
|
||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll"
|
||||
"ProjectFish": "UnrealEditor-ProjectFish-0001.dll",
|
||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll"
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -58,6 +58,16 @@ int32 UFishingMapSystem::GetNodeAtLayerIndex(FGuid NodeID) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
TObjectPtr<UFishingMapNode> 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<FGuid> 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<FSimpleConnection> UFishingMapSystem::GenerateNonCrossingConnections(int3
|
||||
|
||||
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 "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,6 +64,9 @@ public:
|
||||
UPROPERTY(BlueprintReadOnly, meta = (ToolTip = "按层级组织的节点"))
|
||||
TArray<FMapLayer> AllLayers;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnNodeStateChange OnNodeStateChange;
|
||||
|
||||
// 生成地图
|
||||
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
||||
void GenerateMap();
|
||||
@ -67,18 +74,23 @@ public:
|
||||
// 使用配置生成地图
|
||||
void GenerateMapWithConfig(const UMapConfigAsset* Config);
|
||||
|
||||
|
||||
|
||||
// 获取总层数
|
||||
int32 GetLayerCount() const { return AllLayers.Num(); }
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "FishingMap")
|
||||
int32 GetNodeAtLayerIndex(FGuid NodeID) const;
|
||||
|
||||
TObjectPtr<UFishingMapNode> GetNode(FGuid NodeID) ;
|
||||
|
||||
// 清空地图
|
||||
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
||||
void ClearMap();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "FishingMap")
|
||||
void MoveToNode(FGuid NodeID);
|
||||
|
||||
private:
|
||||
void GetAllConnectedNodes(FGuid NodeID, TArray<FGuid>& ConnectedNodes);
|
||||
protected:
|
||||
// 生成节点
|
||||
void GenerateNodes();
|
||||
@ -93,3 +105,5 @@ protected:
|
||||
// 生成无交叉的连接方案
|
||||
TArray<FSimpleConnection> GenerateNonCrossingConnections(int32 FromLayer, int32 ToLayer);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user