diff --git a/Content/Blueprint/Level/Actor/Role/BP_Fox.uasset b/Content/Blueprint/Level/Actor/Role/BP_Fox.uasset index 10ab2f4..325b22f 100644 Binary files a/Content/Blueprint/Level/Actor/Role/BP_Fox.uasset and b/Content/Blueprint/Level/Actor/Role/BP_Fox.uasset differ diff --git a/Content/Blueprint/Level/Actor/Role/BP_Rabbit.uasset b/Content/Blueprint/Level/Actor/Role/BP_Rabbit.uasset index 08d418b..b8b343c 100644 Binary files a/Content/Blueprint/Level/Actor/Role/BP_Rabbit.uasset and b/Content/Blueprint/Level/Actor/Role/BP_Rabbit.uasset differ diff --git a/Content/Lua/Level/Actor/LevelFoxRole.lua b/Content/Lua/Level/Actor/LevelFoxRole.lua index f3339be..af26855 100644 --- a/Content/Lua/Level/Actor/LevelFoxRole.lua +++ b/Content/Lua/Level/Actor/LevelFoxRole.lua @@ -8,8 +8,6 @@ end function LevelFoxRole:ReceiveBeginPlay() self["SpineAnimationComponent"]:SetAnimation(0, "Idle/Front", true) self.last_animation = "Idle/Front" - self:InitMoveSpeed(300) - self:InitHealth(500, 500) end diff --git a/Content/Lua/Level/Actor/LevelRabbitRole.lua b/Content/Lua/Level/Actor/LevelRabbitRole.lua index 64ac056..1ad5850 100644 --- a/Content/Lua/Level/Actor/LevelRabbitRole.lua +++ b/Content/Lua/Level/Actor/LevelRabbitRole.lua @@ -7,8 +7,6 @@ end function LevelRabbitRole:ReceiveBeginPlay() self["SpineAnimationComponent"]:SetSkin("back/move") self["SpineAnimationComponent"]:SetAnimation(0, "animation", true) - - self:InitMoveSpeed(380) end diff --git a/Source/BusyRabbit/Private/BusyActorManagerSubSystem.cpp b/Source/BusyRabbit/Private/BusyActorManagerSubSystem.cpp deleted file mode 100644 index a69999b..0000000 --- a/Source/BusyRabbit/Private/BusyActorManagerSubSystem.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "BusyActorManagerSubSystem.h" -#include "BusyGamePlayLibrary.h" -#include "Subsystems/SubsystemBlueprintLibrary.h" - -void UBusyActorManagerSubSystem::Initialize(FSubsystemCollectionBase& Collection){ - Super::Initialize(Collection); - ReceiveSubSystemInitialize(); -} - -void UBusyActorManagerSubSystem::OnWorldBeginPlay(UWorld& InWorld) { - Super::OnWorldBeginPlay(InWorld); - ReceiveWorldBeginPlay(); -} - -void UBusyActorManagerSubSystem::Deinitialize(){ - Super::Deinitialize(); -} - -FString UBusyActorManagerSubSystem::GetLuaFilePath_Implementation() const{ - return TEXT("GamePlay/Level/BusyActorManagerSubSystem"); -} - -bool UBusyActorManagerSubSystem::GetLevelBaseConfig(FBusyLevelBaseConfig& config){ - FBusyLevelBaseConfig* Config; - UDataTable *DataTable = UBusyGameplayLibrary::GetGameDataTable("LevelBaseConfig"); - if (!DataTable) return false; - - Config = DataTable->FindRow( - TEXT("Default"), - TEXT("UBusyActorManagerSubSystem::GetLevelBaseConfig"), - true - ); - - if (!Config) return false; - config = *Config; - return true; -} - -UWorld* UBusyActorManagerSubSystem::K2_GetWorld(){ - return this->GetWorld(); -} - -UBusyActorManagerSubSystem* UBusyActorManagerSubSystem::Get(UObject* WorldContextObject){ - UWorldSubsystem *SubSystem = USubsystemBlueprintLibrary::GetWorldSubsystem( - WorldContextObject, - UBusyActorManagerSubSystem::StaticClass() - ); - return Cast(SubSystem); -} diff --git a/Source/BusyRabbit/Private/BusyGamePlayLibrary.cpp b/Source/BusyRabbit/Private/BusyGameplayLibrary.cpp similarity index 93% rename from Source/BusyRabbit/Private/BusyGamePlayLibrary.cpp rename to Source/BusyRabbit/Private/BusyGameplayLibrary.cpp index f850a36..a7f138d 100644 --- a/Source/BusyRabbit/Private/BusyGamePlayLibrary.cpp +++ b/Source/BusyRabbit/Private/BusyGameplayLibrary.cpp @@ -1,7 +1,7 @@ // Fill out your copyright notice in the Description page of Project Settings. -#include "BusyGamePlayLibrary.h" +#include "BusyGameplayLibrary.h" #include "BusyDataAsset.h" static inline const UBusyDataAsset* GetGameAsset() { @@ -51,10 +51,6 @@ UWorld* UBusyGameplayLibrary::K2_GetWorld(const UObject* UObj){ return UObj->GetWorld(); } -bool UBusyGameplayLibrary::GetLevelBaseConfig(const FName& RowName, FBusyLevelBaseConfig& RowData){ - return GetTableConfig(TEXT("LevelBaseConfig"), RowName, RowData); -} - bool UBusyGameplayLibrary::GetLevelItemConfig(const FName& RowName, FBusyLevelItemConfig& RowData){ return GetTableConfig(TEXT("LevelItems"), RowName, RowData); } diff --git a/Source/BusyRabbit/Private/Level/Actor/BusyPawnBase.cpp b/Source/BusyRabbit/Private/Level/Actor/BusyPawnBase.cpp index a894ad2..c238cd2 100644 --- a/Source/BusyRabbit/Private/Level/Actor/BusyPawnBase.cpp +++ b/Source/BusyRabbit/Private/Level/Actor/BusyPawnBase.cpp @@ -4,6 +4,8 @@ #include "SpineSkeletonAnimationComponent.h" #include "Level/Actor/Components/BusyPawnMovement.h" +DEFINE_LOG_CATEGORY(LogBusyPawn) + ABusyPawnBase::ABusyPawnBase() { @@ -42,7 +44,7 @@ float ABusyPawnBase::GetSpeed_Implementation()const { return Attribute->GetMoveSpeed(); } - return 200; + return 0.f; } void ABusyPawnBase::InitMoveSpeed(const float MoveSpeed)const diff --git a/Source/BusyRabbit/Private/Level/Actor/BusyPlayerRole.cpp b/Source/BusyRabbit/Private/Level/Actor/BusyPlayerRole.cpp index 64b2b27..07bec3d 100644 --- a/Source/BusyRabbit/Private/Level/Actor/BusyPlayerRole.cpp +++ b/Source/BusyRabbit/Private/Level/Actor/BusyPlayerRole.cpp @@ -1,7 +1,11 @@ #include "Level/Actor/BusyPlayerRole.h" #include "Camera/CameraComponent.h" +#include "BusyGameplayLibrary.h" +#include "Animation/AnimAttributes.h" +#include "Tables/BusyPawnConfig.h" #include "GameFramework/SpringArmComponent.h" + ABusyPlayerRole::ABusyPlayerRole() { CameraComponent = CreateDefaultSubobject(TEXT("CameraComponent")); @@ -27,7 +31,34 @@ void ABusyPlayerRole::BeginPlay() InitRoleAttributes(); } -void ABusyPlayerRole::InitRoleAttributes() +bool ABusyPlayerRole::InitRoleAttributes() { + if (!PawnName.IsValid()) return false; + const UDataTable* ConfigTable = UBusyGameplayLibrary::GetGameDataTable(TEXT("LevelRoleBaseConfig")); + if (!ConfigTable) + { + UE_LOG(LogBusyPawn, Log, TEXT("ABusyPlayerRole::InitRoleAttributes Can't find config table: LevelRoleBaseConfig")) + return false; + } + const FBusyRoleBaseConfig* Result = ConfigTable->FindRow( + PawnName, + *FString::Printf(TEXT("ABusyPlayerRole::InitRoleAttributes, PawnName: %ls"), *PawnName.ToString()) + ); + if (Result) + { + UBusyPlayerRoleAttributeSet* RoleAttributes = Cast(Attribute); + RoleAttributes->InitHealth(Result->Health); + RoleAttributes->InitMaxHealth(Result->Health); + RoleAttributes->InitMoveSpeed(Result->MoveSpeed); + + RoleAttributes->InitHunger(Result->Hunger); + RoleAttributes->InitMaxHunger(Result->Hunger); + RoleAttributes->InitHungerConsume(Result->HungerConsume); + + RoleAttributes->InitDamage(Result->Damage); + RoleAttributes->InitDefense(Result->Defense); + return true; + } + return false; } diff --git a/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp b/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp index f5349b3..3605718 100644 --- a/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp +++ b/Source/BusyRabbit/Private/Level/BusyLevelItem.cpp @@ -4,7 +4,7 @@ #include "Level/BusyLevelItem.h" #include "Components/CapsuleComponent.h" #include "Components/WidgetComponent.h" -#include "BusyGamePlayLibrary.h" +#include "BusyGameplayLibrary.h" ABusyLevelItem::ABusyLevelItem(): CurrentItemID("100001") { LuaFilePath = TEXT("GamePlay.LevelItem.LevelItem"); diff --git a/Source/BusyRabbit/Private/Level/LevelItemReward.cpp b/Source/BusyRabbit/Private/Level/LevelItemReward.cpp index 5e500b5..f183df2 100644 --- a/Source/BusyRabbit/Private/Level/LevelItemReward.cpp +++ b/Source/BusyRabbit/Private/Level/LevelItemReward.cpp @@ -6,7 +6,7 @@ #include "Components/SceneComponent.h" #include "PaperFlipbook.h" #include "PaperFlipbookComponent.h" -#include "BusyGamePlayLibrary.h" +#include "BusyGameplayLibrary.h" ALevelItemReward::ALevelItemReward(){ diff --git a/Source/BusyRabbit/Private/Role/BusyRole.cpp b/Source/BusyRabbit/Private/Role/BusyRole.cpp index 8745885..15a1797 100644 --- a/Source/BusyRabbit/Private/Role/BusyRole.cpp +++ b/Source/BusyRabbit/Private/Role/BusyRole.cpp @@ -9,7 +9,7 @@ #include "PaperFlipbookComponent.h" #include "Role/BusyRoleMovement.h" #include "Role/RoleAnimation.h" -#include "BusyGamePlayLibrary.h" +#include "BusyGameplayLibrary.h" #include "Components/InventoryComponent.h" #include "Core/PW_AbilitySystemComponent.h" #include "EnhancedInputComponent.h" diff --git a/Source/BusyRabbit/Private/Role/RoleAnimation.cpp b/Source/BusyRabbit/Private/Role/RoleAnimation.cpp index dbc1453..451440f 100644 --- a/Source/BusyRabbit/Private/Role/RoleAnimation.cpp +++ b/Source/BusyRabbit/Private/Role/RoleAnimation.cpp @@ -3,7 +3,7 @@ #include "Role/RoleAnimation.h" #include "Role/BusyRole.h" -#include "BusyGamePlayLibrary.h" +#include "BusyGameplayLibrary.h" DEFINE_LOG_CATEGORY(LogRoleAnimation); diff --git a/Source/BusyRabbit/Public/BusyActorManagerSubSystem.h b/Source/BusyRabbit/Public/BusyActorManagerSubSystem.h deleted file mode 100644 index ba3362a..0000000 --- a/Source/BusyRabbit/Public/BusyActorManagerSubSystem.h +++ /dev/null @@ -1,67 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Engine/Datatable.h" -#include "LuaOverriderInterface.h" -#include "Subsystems/WorldSubsystem.h" -#include "Level/BusyLevelItem.h" -#include "BusyActorManagerSubSystem.generated.h" - - -USTRUCT(BlueprintType) -struct FBusyLevelBaseConfig : public FTableRowBase { - GENERATED_BODY() - /* 第一个篝火的位置 */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "初始篝火位置") - FVector2D FirstBonfirePosition; - - UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "每次Tick的时间(MS)") - int TickInterval; - - UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "一个物品生成周期包含的Tick次数") - int Period; - - UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName ="关卡中存在的物品配置") - TMap LevelItemIds; -}; - - -/** - * - */ -UCLASS() -class BUSYRABBIT_API UBusyActorManagerSubSystem : public UWorldSubsystem, public ILuaOverriderInterface -{ - GENERATED_BODY() - -public: - // 初始化(关卡加载时调用) - virtual void Initialize(FSubsystemCollectionBase& Collection) override; - - virtual void OnWorldBeginPlay(UWorld& InWorld)override; - - // 销毁(关卡卸载时调用) - virtual void Deinitialize() override; - - virtual FString GetLuaFilePath_Implementation() const override; - - -public: // 需要蓝图实现接口 - UFUNCTION(BlueprintImplementableEvent) - void ReceiveSubSystemInitialize(); - - UFUNCTION(BlueprintImplementableEvent) - void ReceiveWorldBeginPlay(); - -public: - UFUNCTION(BlueprintPure) - bool GetLevelBaseConfig(FBusyLevelBaseConfig& config); - - UFUNCTION(BlueprintCallable) - UWorld* K2_GetWorld(); - - UFUNCTION(BlueprintCallable) - static UBusyActorManagerSubSystem* Get(UObject* WorldContextObject); -}; diff --git a/Source/BusyRabbit/Public/BusyGamePlayLibrary.h b/Source/BusyRabbit/Public/BusyGameplayLibrary.h similarity index 86% rename from Source/BusyRabbit/Public/BusyGamePlayLibrary.h rename to Source/BusyRabbit/Public/BusyGameplayLibrary.h index aab2cf9..f8ec65a 100644 --- a/Source/BusyRabbit/Public/BusyGamePlayLibrary.h +++ b/Source/BusyRabbit/Public/BusyGameplayLibrary.h @@ -3,16 +3,13 @@ #pragma once #include "CoreMinimal.h" -#include "slua.h" #include "Role/BusyRole.h" #include "Engine/World.h" #include "Level/BusyLevelItem.h" #include "Engine/DataTable.h" -#include "BusyActorManagerSubSystem.h" #include "Kismet/BlueprintFunctionLibrary.h" #include "GameAsset/BusyItem.h" -#include "LuaBlueprintLibrary.h" -#include "BusyGamePlayLibrary.generated.h" +#include "BusyGameplayLibrary.generated.h" /** * @@ -34,10 +31,7 @@ public: UFUNCTION(BlueprintPure) static UWorld* K2_GetWorld(const UObject* UObj); - - UFUNCTION(BlueprintPure) - static bool GetLevelBaseConfig(const FName& RowName, FBusyLevelBaseConfig& RowData); - + UFUNCTION(BlueprintPure) static bool GetLevelItemConfig(const FName& RowName, FBusyLevelItemConfig& RowData); diff --git a/Source/BusyRabbit/Public/Level/Actor/BusyPawnBase.h b/Source/BusyRabbit/Public/Level/Actor/BusyPawnBase.h index e6482e8..162b9fb 100644 --- a/Source/BusyRabbit/Public/Level/Actor/BusyPawnBase.h +++ b/Source/BusyRabbit/Public/Level/Actor/BusyPawnBase.h @@ -18,6 +18,8 @@ GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \ GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \ GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName) +DECLARE_LOG_CATEGORY_EXTERN(LogBusyPawn, Log, All); + UCLASS(Blueprintable, BlueprintType) class UBusyPawnAttributeSet : public UAttributeSet @@ -32,12 +34,18 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") FGameplayAttributeData MaxHealth; MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, MaxHealth); - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") FGameplayAttributeData MoveSpeed; MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, MoveSpeed); - + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") + FGameplayAttributeData Damage; + MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Damage); + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes") + FGameplayAttributeData Defense; + MY_ATTRIBUTE_ACCESSORS(UBusyPawnAttributeSet, Defense); }; #undef MY_ATTRIBUTE_ACCESSORS @@ -54,6 +62,9 @@ public: virtual float GetSpeed_Implementation()const override; +public: + virtual bool InitRoleAttributes() { return false; } + protected: UFUNCTION(BlueprintCallable) void InitMoveSpeed(const float MoveSpeed)const; @@ -94,6 +105,9 @@ public: TObjectPtr MovementComponent; /*-------------------------------------------------------------------*/ + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, DisplayName="角色名称") + FName PawnName; + protected: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) diff --git a/Source/BusyRabbit/Public/Level/Actor/BusyPlayerRole.h b/Source/BusyRabbit/Public/Level/Actor/BusyPlayerRole.h index 8506f66..5152007 100644 --- a/Source/BusyRabbit/Public/Level/Actor/BusyPlayerRole.h +++ b/Source/BusyRabbit/Public/Level/Actor/BusyPlayerRole.h @@ -18,12 +18,18 @@ class UBusyPlayerRoleAttributeSet: public UBusyPawnAttributeSet public: UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName="饱食度") FGameplayAttributeData Hunger; + MY_ATTRIBUTE_ACCESSORS(UBusyPlayerRoleAttributeSet, Hunger); + UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName="最大饱食度") FGameplayAttributeData MaxHunger; + MY_ATTRIBUTE_ACCESSORS(UBusyPlayerRoleAttributeSet, MaxHunger); + UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName="饱食度消耗速度") FGameplayAttributeData HungerConsume; + MY_ATTRIBUTE_ACCESSORS(UBusyPlayerRoleAttributeSet, HungerConsume); + }; #undef MY_ATTRIBUTE_ACCESSORS @@ -39,9 +45,9 @@ public: virtual void BeginPlay() override; -protected: - void InitRoleAttributes(); - + + virtual bool InitRoleAttributes()override; + protected: /*--------------------相机相关--------------------------*/