| @ -15,7 +15,7 @@ ManualIPAddress= | |||||||
| [/Script/EngineSettings.GameMapsSettings] | [/Script/EngineSettings.GameMapsSettings] | ||||||
| GlobalDefaultGameMode=/Game/Blueprint/Bp_BusyGameMode.Bp_BusyGameMode_C | GlobalDefaultGameMode=/Game/Blueprint/Bp_BusyGameMode.Bp_BusyGameMode_C | ||||||
| GameInstanceClass=/Script/BusyRabbit.BusyGameInstance | GameInstanceClass=/Script/BusyRabbit.BusyGameInstance | ||||||
| EditorStartupMap=/Game/Level/HomeLand.HomeLand | EditorStartupMap=/Game/Level/FalconPlain.FalconPlain | ||||||
| GameDefaultMap=/Game/Level/FalconPlain.FalconPlain | GameDefaultMap=/Game/Level/FalconPlain.FalconPlain | ||||||
|  |  | ||||||
| [/Script/Engine.RendererSettings] | [/Script/Engine.RendererSettings] | ||||||
|  | |||||||
| @ -1,3 +1,4 @@ | |||||||
|  | ;METADATA=(Diff=true, UseCommands=true) | ||||||
| [/Script/GameplayTags.GameplayTagsSettings] | [/Script/GameplayTags.GameplayTagsSettings] | ||||||
| ImportTagsFromConfig=True | ImportTagsFromConfig=True | ||||||
| WarnOnInvalidTags=True | WarnOnInvalidTags=True | ||||||
| @ -57,6 +58,9 @@ NetIndexFirstBitSegment=16 | |||||||
| +GameplayTagList=(Tag="Ingredient.Vegetable.Carrot",DevComment="胡萝卜") | +GameplayTagList=(Tag="Ingredient.Vegetable.Carrot",DevComment="胡萝卜") | ||||||
| +GameplayTagList=(Tag="Recover.Role.Health",DevComment="回复生命值") | +GameplayTagList=(Tag="Recover.Role.Health",DevComment="回复生命值") | ||||||
| +GameplayTagList=(Tag="Recover.Role.Hunger",DevComment="恢复饥饿值") | +GameplayTagList=(Tag="Recover.Role.Hunger",DevComment="恢复饥饿值") | ||||||
|  | +GameplayTagList=(Tag="Resource",DevComment="资源") | ||||||
|  | +GameplayTagList=(Tag="Resource.Building",DevComment="建筑物") | ||||||
|  | +GameplayTagList=(Tag="Resource.Building.Campsite",DevComment="营地") | ||||||
| +GameplayTagList=(Tag="Status.Role.Invincible",DevComment="不掉血标签") | +GameplayTagList=(Tag="Status.Role.Invincible",DevComment="不掉血标签") | ||||||
| +GameplayTagList=(Tag="Terrain.Desert",DevComment="荒漠地形") | +GameplayTagList=(Tag="Terrain.Desert",DevComment="荒漠地形") | ||||||
| +GameplayTagList=(Tag="Terrain.Forest",DevComment="森林") | +GameplayTagList=(Tag="Terrain.Forest",DevComment="森林") | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Content/Data/Level/LevelResourceConfig.uasset
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Data/Level/LevelResourceConfig.uasset
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -1,5 +1,7 @@ | |||||||
|  | using UnrealSharp; | ||||||
| using UnrealSharp.Attributes; | using UnrealSharp.Attributes; | ||||||
| using UnrealSharp.BusyRabbit; | using UnrealSharp.BusyRabbit; | ||||||
|  | using UnrealSharp.CoreUObject; | ||||||
| using UnrealSharp.Engine; | using UnrealSharp.Engine; | ||||||
|  |  | ||||||
| namespace Level.GameSettings; | namespace Level.GameSettings; | ||||||
| @ -11,7 +13,17 @@ public class ABusyLevelPlayerState : ALevelPlayerState | |||||||
|     { |     { | ||||||
|         base.BeginPlay(); |         base.BeginPlay(); | ||||||
|         APlayerController pc = UGameplayStatics.GetPlayerController(0); |         APlayerController pc = UGameplayStatics.GetPlayerController(0); | ||||||
|         var role = CreateRoleRoster(pc) as APawn; |         UGameplayStatics.GetAllActorsWithTag("Resource.Building.Campsite", out IList<AActor> FoundActors); | ||||||
|         pc.Possess(role); |         FVector SpawnLocation = new FVector(0, 0, 10); | ||||||
|  |         if (FoundActors.Count > 0) | ||||||
|  |         { | ||||||
|  |             SpawnLocation = FoundActors[0].ActorLocation; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if(CreateRoleRoster(pc) is APawn Role) | ||||||
|  |         { | ||||||
|  |             pc.Possess(Role); | ||||||
|  |             Role.SetActorLocation(SpawnLocation); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| #include "Level/Actor/BusyStaticResource.h" | #include "Level/Actor/BusyStaticResource.h" | ||||||
| #include "SpineSkeletonRendererComponent.h" | #include "SpineSkeletonRendererComponent.h" | ||||||
| #include "SpineSkeletonAnimationComponent.h" | #include "SpineSkeletonAnimationComponent.h" | ||||||
|  | #include "BusyGameplayLibrary.h" | ||||||
|  | #include "Data/BusyResourceConfig.h" | ||||||
|  |  | ||||||
| ABusyStaticResource::ABusyStaticResource() | ABusyStaticResource::ABusyStaticResource() | ||||||
| { | { | ||||||
| @ -21,4 +23,19 @@ void ABusyStaticResource::BeginPlay() | |||||||
| 	Super::BeginPlay(); | 	Super::BeginPlay(); | ||||||
| 	SpineAnimationComponent->SetSkin("default"); | 	SpineAnimationComponent->SetSkin("default"); | ||||||
| 	SpineAnimationComponent->SetAnimation(0, "idle", true); | 	SpineAnimationComponent->SetAnimation(0, "idle", true); | ||||||
|  |  | ||||||
|  | 	if (ResourceName.IsNone()) return; | ||||||
|  |  | ||||||
|  | 	const UDataTable* ResourceTable = UBusyGameplayLibrary::GetGameDataTable("ResourceConfig"); | ||||||
|  | 	if (!ResourceTable) return; | ||||||
|  |  | ||||||
|  | 	FBusyResourceConfig* Config = ResourceTable->FindRow<FBusyResourceConfig>( | ||||||
|  | 		ResourceName, *FString::Printf(TEXT("ABusyStaticResource::BeginPlay Find Config: %s"), *ResourceName.ToString()) | ||||||
|  | 	); | ||||||
|  | 	if (Config == nullptr) return; | ||||||
|  |  | ||||||
|  | 	for (const FGameplayTag& Tag : Config->GameplayTags) | ||||||
|  | 	{ | ||||||
|  | 		Tags.AddUnique(Tag.GetTagName()); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -113,7 +113,7 @@ void UStaticResourceLayerComponent::GenerateResourcePoints(TArray<FVector2D>& Ou | |||||||
| 	const IGameMapInterface * MapInterface = Cast<IGameMapInterface>(Owner); | 	const IGameMapInterface * MapInterface = Cast<IGameMapInterface>(Owner); | ||||||
| 	if (!MapInterface) return; | 	if (!MapInterface) return; | ||||||
|  |  | ||||||
| 	float MapWidth, MapHeight; | 	int32 MapWidth, MapHeight; | ||||||
| 	MapInterface->Execute_GetMapSize(Owner, MapWidth, MapHeight); | 	MapInterface->Execute_GetMapSize(Owner, MapWidth, MapHeight); | ||||||
| 	 | 	 | ||||||
| 	const UMitchellBestCandidate *PointCreator = NewObject<UMitchellBestCandidate>(); | 	const UMitchellBestCandidate *PointCreator = NewObject<UMitchellBestCandidate>(); | ||||||
|  | |||||||
| @ -171,11 +171,25 @@ UTerrainLayerComponent::UTerrainLayerComponent() | |||||||
| void UTerrainLayerComponent::BeginPlay() | void UTerrainLayerComponent::BeginPlay() | ||||||
| { | { | ||||||
| 	Super::BeginPlay(); | 	Super::BeginPlay(); | ||||||
|  |  | ||||||
|  | 	AActor* Owner = GetOwner(); | ||||||
|  | 	if (IGameMapInterface* GameMap = Cast<IGameMapInterface>(Owner)) | ||||||
|  | 	{ | ||||||
|  | 		GameMap->Execute_GetMapSize(Owner, MapWidth, MapHeight); | ||||||
|  | 		TileSetSize = GameMap->Execute_GetMapFieldSize(Owner); | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
|  | 		MapWidth = MapHeight = 32; | ||||||
|  | 		TileSetSize = 128; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	SetupTerrainActors(); | 	SetupTerrainActors(); | ||||||
|  |  | ||||||
| 	TArray<int32> Priority; | 	TArray<int32> Priority; | ||||||
| 	TArray<FGameplayTag> TerrainData; | 	TArray<FGameplayTag> TerrainData; | ||||||
| 	TArray<FGameplayTag> TerrainTypes; | 	TArray<FGameplayTag> TerrainTypes; | ||||||
|  |  | ||||||
| 	for (auto TileSetConfig : TileSetConfigs) | 	for (auto TileSetConfig : TileSetConfigs) | ||||||
| 	{ | 	{ | ||||||
| 		TerrainTypes.Add(TileSetConfig.Key); | 		TerrainTypes.Add(TileSetConfig.Key); | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ AGameMapActor::AGameMapActor() | |||||||
| 	this->RootComponent = SceneComp; | 	this->RootComponent = SceneComp; | ||||||
| } | } | ||||||
|  |  | ||||||
| void AGameMapActor::GetMapSize_Implementation(float& OutWidth, float& OutHeight) | void AGameMapActor::GetMapSize_Implementation(int32& OutWidth, int32& OutHeight) | ||||||
| { | { | ||||||
| 	OutWidth = MapWidth; | 	OutWidth = MapWidth; | ||||||
| 	OutHeight = MapHeight; | 	OutHeight = MapHeight; | ||||||
| @ -22,7 +22,7 @@ FGameplayTag AGameMapActor::GetTerrainAt_Implementation(const float X, const flo | |||||||
| 	return TerrainLayer->GetTerrainAt(X, Y); | 	return TerrainLayer->GetTerrainAt(X, Y); | ||||||
| } | } | ||||||
|  |  | ||||||
| float AGameMapActor::GetMapFieldSize_Implementation() | int32 AGameMapActor::GetMapFieldSize_Implementation() | ||||||
| { | { | ||||||
| 	return MapFieldSize; | 	return MapFieldSize; | ||||||
| } | } | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ class BUSYRABBIT_API UBusyGameplayLibrary : public UBlueprintFunctionLibrary | |||||||
| 	GENERATED_BODY() | 	GENERATED_BODY() | ||||||
|  |  | ||||||
| public: | public: | ||||||
| 	UFUNCTION(BlueprintCallable) | 	UFUNCTION(BlueprintPure) | ||||||
| 	static UDataTable* GetGameDataTable(const FString& TableName); | 	static UDataTable* GetGameDataTable(const FString& TableName); | ||||||
|  |  | ||||||
| 	UFUNCTION(BlueprintCallable) | 	UFUNCTION(BlueprintCallable) | ||||||
|  | |||||||
							
								
								
									
										15
									
								
								Source/BusyRabbit/Public/Data/BusyResourceConfig.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Source/BusyRabbit/Public/Data/BusyResourceConfig.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | |||||||
|  | #pragma once | ||||||
|  | #include "GameplayTagContainer.h" | ||||||
|  | #include "BusyResourceConfig.generated.h" | ||||||
|  |  | ||||||
|  | USTRUCT(BlueprintType) | ||||||
|  | struct FBusyResourceConfig : public FTableRowBase | ||||||
|  | { | ||||||
|  | 	GENERATED_BODY() | ||||||
|  |  | ||||||
|  | 	UPROPERTY(EditAnywhere, DisplayName="备注") | ||||||
|  | 	FString Desc; | ||||||
|  |  | ||||||
|  | 	UPROPERTY(EditAnywhere, DisplayName="物品标签") | ||||||
|  | 	FGameplayTagContainer GameplayTags; | ||||||
|  | }; | ||||||
| @ -29,4 +29,8 @@ public: | |||||||
| 	TObjectPtr<USpineSkeletonAnimationComponent> SpineAnimationComponent; | 	TObjectPtr<USpineSkeletonAnimationComponent> SpineAnimationComponent; | ||||||
| 	/*-------------------------------------------------------------------*/ | 	/*-------------------------------------------------------------------*/ | ||||||
|  |  | ||||||
|  | protected: | ||||||
|  | 	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) | ||||||
|  | 	FName ResourceName; | ||||||
|  | 	 | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -62,14 +62,9 @@ protected: | |||||||
|  |  | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite) | 	int32 MapWidth = 32;   // 用Owner的Width覆盖 | ||||||
| 	int32 MapWidth = 32; | 	int32 MapHeight = 32;  // 用Owner的Height覆盖 | ||||||
|  | 	int32 TileSetSize = 128;	// 用Owner的Size覆盖 | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite) |  | ||||||
| 	int32 MapHeight = 32; |  | ||||||
|  |  | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite) |  | ||||||
| 	int32 TileSetSize = 128; |  | ||||||
| 	 | 	 | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | ||||||
| 	TMap<FGameplayTag, TObjectPtr<UPaperTileSet>> TileSetConfigs; | 	TMap<FGameplayTag, TObjectPtr<UPaperTileSet>> TileSetConfigs; | ||||||
|  | |||||||
| @ -18,10 +18,10 @@ class IGameMapInterface | |||||||
| 	GENERATED_BODY() | 	GENERATED_BODY() | ||||||
| public: | public: | ||||||
| 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent) | 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent) | ||||||
| 	void GetMapSize(float &OutX, float &OutY); | 	void GetMapSize(int32 &OutX, int32 &OutY); | ||||||
|  |  | ||||||
| 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent) | 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent) | ||||||
| 	float GetMapFieldSize(); | 	int32 GetMapFieldSize(); | ||||||
| 	 | 	 | ||||||
| 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent) | 	UFUNCTION(BlueprintCallable, BlueprintNativeEvent) | ||||||
| 	FGameplayTag GetTerrainAt(const float X, const float Y); | 	FGameplayTag GetTerrainAt(const float X, const float Y); | ||||||
| @ -37,9 +37,9 @@ public: | |||||||
| 	AGameMapActor(); | 	AGameMapActor(); | ||||||
|  |  | ||||||
| public: | public: | ||||||
| 	virtual void GetMapSize_Implementation(float& OutWidth, float& OutHeight) override; | 	virtual void GetMapSize_Implementation(int32& OutWidth, int32& OutHeight) override; | ||||||
| 	virtual FGameplayTag GetTerrainAt_Implementation(const float X, const float Y) override; | 	virtual FGameplayTag GetTerrainAt_Implementation(const float X, const float Y) override; | ||||||
| 	virtual float GetMapFieldSize_Implementation() override; | 	virtual int32 GetMapFieldSize_Implementation() override; | ||||||
|  |  | ||||||
| public: | public: | ||||||
| 	virtual void BeginPlay() override; | 	virtual void BeginPlay() override; | ||||||
| @ -58,11 +58,11 @@ public: | |||||||
|  |  | ||||||
| protected: | protected: | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | ||||||
| 	float MapWidth = 32; | 	int32 MapWidth = 32; | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | ||||||
| 	float MapHeight = 32; | 	int32 MapHeight = 32; | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly) | ||||||
| 	float MapFieldSize = 128; | 	int32 MapFieldSize = 128; | ||||||
|  |  | ||||||
| 	 | 	 | ||||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) | 	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user