剔除不需要的插件依赖,比如Paper2D系列 #8
Paper2D系列还需要,如瓦片地图。提出了对PaperZD的依赖,以及依赖FlipBook组件的Actor
This commit is contained in:
@ -55,14 +55,6 @@ bool UBusyGameplayLibrary::GetLevelItemConfig(const FName& RowName, FBusyLevelIt
|
||||
return GetTableConfig<FBusyLevelItemConfig>(TEXT("LevelItems"), RowName, RowData);
|
||||
}
|
||||
|
||||
bool UBusyGameplayLibrary::GetRoleConfig(const FName& RowName, FBusyRoleConfig& RowData){
|
||||
return GetTableConfig<FBusyRoleConfig>(TEXT("RoleConfig"), RowName, RowData);
|
||||
}
|
||||
|
||||
bool UBusyGameplayLibrary::GetItemResourceConfig(const FName& RowName, FBusyLevelItemResourceConfig& RowData){
|
||||
return GetTableConfig<FBusyLevelItemResourceConfig>(TEXT("LevelItemResource"), RowName, RowData);
|
||||
}
|
||||
|
||||
bool UBusyGameplayLibrary::GetLevelItemDescription(const FName& RowName, FBusyLevelItemDescription& RowData){
|
||||
return GetTableConfig<FBusyLevelItemDescription>(TEXT("LevelItemDesc"), RowName, RowData);
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ void UPW_TableSwitcher::RebuildSwitcher(const TMap<FName, FTableSwitcherInfo>& I
|
||||
Widget = CreateWidget<UPW_TableSwitcherWidget>(this, Info.SwitcherWidget);
|
||||
UHorizontalBoxSlot *WidgetSlot = SwitcherBar->AddChildToHorizontalBox(Widget);
|
||||
if (WidgetSlot) {
|
||||
WidgetSlot->VerticalAlignment = VAlign_Fill;
|
||||
WidgetSlot->SetVerticalAlignment(VAlign_Fill);
|
||||
}
|
||||
Widget->SetSwitcherName(PageName);
|
||||
Widget->SetSwitcherTitle(Info.TableSwitcherName);
|
||||
|
||||
@ -1,117 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Level/BusyLevelItem.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/WidgetComponent.h"
|
||||
#include "BusyGameplayLibrary.h"
|
||||
|
||||
ABusyLevelItem::ABusyLevelItem(): CurrentItemID("100001") {
|
||||
LuaFilePath = TEXT("GamePlay.LevelItem.LevelItem");
|
||||
|
||||
SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
|
||||
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("LevelItemCapsule"));
|
||||
Sprite = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("Sprite"));
|
||||
|
||||
PickBar = CreateDefaultSubobject<UWidgetComponent>(TEXT("PickBar"));
|
||||
LevelItemAttribute = CreateDefaultSubobject<UBusyLevelItemAttributeSet>("LevelItemAttribute");
|
||||
|
||||
InitSprite();
|
||||
InitCapsule();
|
||||
InitPickBar();
|
||||
|
||||
PickBar->SetupAttachment(CapsuleComp);
|
||||
Sprite->SetupAttachment(CapsuleComp);
|
||||
CapsuleComp->SetupAttachment(SceneComp);
|
||||
this->RootComponent = SceneComp;
|
||||
}
|
||||
|
||||
void ABusyLevelItem::OnConstruction(const FTransform& Transform){
|
||||
Super::OnConstruction(Transform);
|
||||
SetItemDisplay(CurrentItemID);
|
||||
}
|
||||
|
||||
void ABusyLevelItem::BeginPlay(){
|
||||
UClass* cls = UBusyGameplayLibrary::GetGameUIClass("PickBar");
|
||||
if (cls != nullptr) {
|
||||
PickBar->SetWidgetClass(cls);
|
||||
}
|
||||
Super::BeginPlay();
|
||||
bIsBeginPlay = true;
|
||||
}
|
||||
|
||||
void ABusyLevelItem::EndPlay(const EEndPlayReason::Type EndPlayReason){
|
||||
Super::EndPlay(EndPlayReason);
|
||||
bIsBeginPlay = false;
|
||||
}
|
||||
|
||||
void ABusyLevelItem::PostLuaHook(){
|
||||
if (bIsBeginPlay) {
|
||||
CallLuaFunctionIfExist("TempSetting");
|
||||
}
|
||||
}
|
||||
|
||||
void ABusyLevelItem::InitCapsule(){
|
||||
|
||||
CapsuleComp->SetCollisionProfileName(TEXT("Custom"));
|
||||
CapsuleComp->SetNotifyRigidBodyCollision(false);
|
||||
CapsuleComp->SetSimulatePhysics(false);
|
||||
CapsuleComp->SetEnableGravity(false);
|
||||
|
||||
CapsuleComp->SetCollisionObjectType(ECC_WorldStatic); // 设置对象类型
|
||||
|
||||
// 逐个通道设置响应
|
||||
CapsuleComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
||||
//CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore);
|
||||
CapsuleComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
||||
CapsuleComp->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Ignore);
|
||||
|
||||
CapsuleComp->SetCapsuleRadius(10);
|
||||
}
|
||||
|
||||
void ABusyLevelItem::InitSprite(){
|
||||
Sprite->SetRelativeRotation(FRotator(0.0, 0.0, -90.0));
|
||||
}
|
||||
|
||||
void ABusyLevelItem::InitPickBar(){
|
||||
PickBar->SetRelativeRotation(FRotator(90.0, 0.0, -90.0));
|
||||
PickBar->SetRelativeLocation(FVector(0.0, -180.0, 0.0));
|
||||
PickBar->SetGenerateOverlapEvents(false);
|
||||
|
||||
}
|
||||
|
||||
void ABusyLevelItem::SetItemDisplay(const FName& ItemID){
|
||||
UDataTable* Resource = UBusyGameplayLibrary::GetGameDataTable(TEXT("LevelItemResource"));
|
||||
|
||||
// 查物品信息
|
||||
FBusyLevelItemResourceConfig* ResourceConfig = Resource->FindRow<FBusyLevelItemResourceConfig>(
|
||||
ItemID, TEXT("ABusyLevelItem::SetLevelItemID"), true
|
||||
);
|
||||
|
||||
// 设置资源
|
||||
if (ResourceConfig != nullptr && ResourceConfig->StaticResource) {
|
||||
this->Sprite->SetFlipbook(ResourceConfig->StaticResource);
|
||||
this->CurrentItemID = ItemID;
|
||||
}
|
||||
}
|
||||
|
||||
void ABusyLevelItem::SetLevelItemID(const FName& ItemID){
|
||||
// 取物品资源表
|
||||
UDataTable* ConfigTable = UBusyGameplayLibrary::GetGameDataTable(TEXT("LevelItems"));
|
||||
// 查物品信息
|
||||
FBusyLevelItemConfig* ItemConfig = ConfigTable->FindRow<FBusyLevelItemConfig>(
|
||||
ItemID, TEXT("ABusyLevelItem::SetLevelItemID"), true
|
||||
);
|
||||
SetItemDisplay(ItemID);
|
||||
|
||||
// 设置配置属性
|
||||
if (ItemConfig == nullptr) return;
|
||||
|
||||
// 初始化Attribute
|
||||
LevelItemAttribute->InitHealth(ItemConfig->PickTimeCost);
|
||||
LevelItemAttribute->RegisterCustomAttribute();
|
||||
|
||||
CurrentItemID = ItemID;
|
||||
LevelItemConfig = *ItemConfig;
|
||||
ReceiveLevelItemSetted(LevelItemConfig);
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Level/LevelItemReward.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "PaperFlipbook.h"
|
||||
#include "PaperFlipbookComponent.h"
|
||||
#include "BusyGameplayLibrary.h"
|
||||
|
||||
|
||||
ALevelItemReward::ALevelItemReward(){
|
||||
SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
|
||||
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("RoleCapsule"));
|
||||
Sprite = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("Sprite"));
|
||||
CapsuleComp->SetupAttachment(SceneComp);
|
||||
Sprite->SetupAttachment(CapsuleComp);
|
||||
this->RootComponent = SceneComp;
|
||||
}
|
||||
|
||||
void ALevelItemReward::OnConstruction(const FTransform& Transform){
|
||||
SetRewardID(RewardID);
|
||||
}
|
||||
|
||||
void ALevelItemReward::SetRewardID(const FName& CurrentRewardID){
|
||||
bool bIsFind = false;
|
||||
FBusyLevelItemDescription Desc;
|
||||
if (CurrentRewardID.IsNone()) return;
|
||||
bIsFind = UBusyGameplayLibrary::GetLevelItemDescription(CurrentRewardID, Desc);
|
||||
if (!bIsFind) return;
|
||||
this->RewardID = CurrentRewardID;
|
||||
this->Sprite->SetFlipbook(Desc.LevelResource.LoadSynchronous());
|
||||
}
|
||||
@ -1,110 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Role/BusyRole.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "BusyCameraComponent.h"
|
||||
#include "PaperFlipbookComponent.h"
|
||||
#include "Role/BusyRoleMovement.h"
|
||||
#include "Role/RoleAnimation.h"
|
||||
#include "BusyGameplayLibrary.h"
|
||||
#include "Components/InventoryComponent.h"
|
||||
#include "Core/PW_AbilitySystemComponent.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
|
||||
|
||||
|
||||
ABusyRole::ABusyRole(){
|
||||
SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
|
||||
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("RoleCapsule"));
|
||||
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
|
||||
CameraComp = CreateDefaultSubobject<UBusyCameraComponent>(TEXT("RoleCamera"));
|
||||
Sprite = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("Sprite"));
|
||||
|
||||
Movement = CreateDefaultSubobject<UBusyRoleMovement>(TEXT("Movement"));
|
||||
RoleAnimation = CreateDefaultSubobject<URoleAnimation>(TEXT("RoleAnimation"));
|
||||
Inventory = CreateDefaultSubobject<UInventoryComponent>(TEXT("Inventory"));
|
||||
|
||||
RoleAbility = CreateDefaultSubobject<UPW_AbilitySystemComponent>("RoleAbility");
|
||||
RoleAttribute = CreateDefaultSubobject<UBusyRoleAttributeSet>(TEXT("RoleAttributeSet"));
|
||||
|
||||
SpringArmComp->SetRelativeRotation(FRotator(-90.0, -90.0, 0.0));
|
||||
this->InitCapsule();
|
||||
|
||||
Sprite->SetupAttachment(CapsuleComp);
|
||||
CapsuleComp->SetupAttachment(SceneComp);
|
||||
SpringArmComp->SetupAttachment(CapsuleComp);
|
||||
CameraComp->SetupAttachment(SpringArmComp);
|
||||
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
this->RootComponent = SceneComp;
|
||||
}
|
||||
|
||||
void ABusyRole::BeginPlay(){
|
||||
Super::BeginPlay();
|
||||
|
||||
if (APlayerController* PlayerController = Cast<APlayerController>(GetController())) {
|
||||
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer())) {
|
||||
Subsystem->AddMappingContext(InputMapping, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ABusyRole::Tick(float InDeltaSeconds){
|
||||
Super::Tick(InDeltaSeconds);
|
||||
}
|
||||
|
||||
void ABusyRole::SetRole(const FName& Name){
|
||||
UDataTable* Table = UBusyGameplayLibrary::GetGameDataTable("RoleConfig");
|
||||
if (Table == nullptr) {
|
||||
return;
|
||||
}
|
||||
FBusyRoleConfig *Row = Table->FindRow<FBusyRoleConfig>(Name, TEXT("ABusyRole::SetRole"));
|
||||
if (Row == nullptr) {
|
||||
return;
|
||||
}
|
||||
RoleName = Name;
|
||||
RoleConfig = *Row;
|
||||
|
||||
// <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (RoleAttribute) {
|
||||
RoleAttribute->InitHealth(Row->Health);
|
||||
RoleAttribute->InitHunger(Row->Hunger);
|
||||
RoleAttribute->InitMoveSpeed(Row->MoveSpeed);
|
||||
RoleAttribute->RegisterCustomAttribute();
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>
|
||||
for (UClass* AbilityClass : Row->DefaultAbilities) {
|
||||
if (AbilityClass) {
|
||||
RoleAbility->GiveAbility(FGameplayAbilitySpec(AbilityClass));
|
||||
}
|
||||
}
|
||||
ReceiveSetRole(RoleConfig);
|
||||
}
|
||||
|
||||
void ABusyRole::TryActiveAbility(const FName& TagName,const FGameplayEventData& EventData){
|
||||
RoleAbility->HandleGameplayEvent(FGameplayTag::RequestGameplayTag(TagName), &EventData);
|
||||
}
|
||||
|
||||
void ABusyRole::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent){
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
|
||||
if (UEnhancedInputComponent* EnhancedInput = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) {
|
||||
EnhancedInput->BindAction(TouchAction, ETriggerEvent::Triggered, this, FName("OnTouch"));
|
||||
}
|
||||
}
|
||||
|
||||
void ABusyRole::InitCapsule(){
|
||||
FScriptDelegate OverlapDelegate;
|
||||
CapsuleComp->SetCollisionProfileName(TEXT("Pawn"));
|
||||
CapsuleComp->SetNotifyRigidBodyCollision(false);
|
||||
OverlapDelegate.BindUFunction(this, "OnOverlapBegin");
|
||||
CapsuleComp->OnComponentBeginOverlap.Add(OverlapDelegate);
|
||||
|
||||
CapsuleComp->SetCapsuleRadius(10);
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Role/BusyRoleMovement.h"
|
||||
#include "PaperFlipbookComponent.h"
|
||||
|
||||
UBusyRoleMovement::UBusyRoleMovement(){
|
||||
LuaFilePath = TEXT("GamePlay/BusyRole/Movement");
|
||||
this->PrimaryComponentTick.bCanEverTick = true;
|
||||
}
|
||||
|
||||
void UBusyRoleMovement::BeginPlay(){
|
||||
Super::BeginPlay();
|
||||
ReceiveComponentBeginPlay();
|
||||
}
|
||||
|
||||
|
||||
void UBusyRoleMovement::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
const AActor* Owner = GetOwner();
|
||||
if (!Owner) return;
|
||||
this->ReceiveComponentTick(DeltaTime);
|
||||
}
|
||||
|
||||
@ -1,115 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Role/RoleAnimation.h"
|
||||
#include "Role/BusyRole.h"
|
||||
#include "BusyGameplayLibrary.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogRoleAnimation);
|
||||
|
||||
|
||||
URoleAnimation::URoleAnimation(){
|
||||
LuaFilePath = TEXT("GamePlay.BusyRole.Animation");
|
||||
}
|
||||
|
||||
void URoleAnimation::SetMoveAnimation(ERoleMoveDirection direction){
|
||||
FBusyRoleAnimationData* Config;
|
||||
UPaperFlipbookComponent* Sprite;
|
||||
|
||||
if (!GetOwnerRoleInfo(Sprite, Config)) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetMoveAnimation, Can't get owner info"));
|
||||
return;
|
||||
}
|
||||
SetRoleAnimation(Sprite, Config->MoveAnimations.Find(direction));
|
||||
}
|
||||
|
||||
void URoleAnimation::SetIdleAnimation(ERoleMoveDirection direction){
|
||||
FBusyRoleAnimationData* Config;
|
||||
UPaperFlipbookComponent* Sprite;
|
||||
|
||||
if (!GetOwnerRoleInfo(Sprite, Config)) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetMoveAnimation, Can't get owner info"));
|
||||
return;
|
||||
}
|
||||
SetRoleAnimation(Sprite, Config->IdleAnimations.Find(direction));
|
||||
}
|
||||
|
||||
void URoleAnimation::PlayPickAnimation(const FName& ItemName, ERoleMoveDirection Direction, EBusyAnimationPhase Phase, float PlayRate){
|
||||
FBusyRoleAnimationData* Config;
|
||||
UPaperFlipbookComponent* Sprite;
|
||||
|
||||
if (!GetOwnerRoleInfo(Sprite, Config)) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get owner info"));
|
||||
return;
|
||||
}
|
||||
FBusyRolePickingAnimationData *Directions = Config->PickingAnimations.Find(ItemName);
|
||||
if (Directions == nullptr) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get Directions Animation"));
|
||||
return;
|
||||
}
|
||||
FBusyAnimationPhaseData *PhaseData = Directions->DirectionAnimations.Find(Direction);
|
||||
if (PhaseData == nullptr) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get PhaseData Animation"));
|
||||
return;
|
||||
}
|
||||
UPaperFlipbook **Animation = PhaseData->PhaseAnimation.Find(Phase);
|
||||
if (Animation == nullptr) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get Animation"));
|
||||
return;
|
||||
}
|
||||
PlayAnimationOnce(Sprite, Animation, PlayRate);
|
||||
}
|
||||
|
||||
|
||||
bool URoleAnimation::GetOwnerRoleInfo(UPaperFlipbookComponent*& Sprite, FBusyRoleAnimationData*& AnimationData){
|
||||
ABusyRole* Role = Cast<ABusyRole>(this->GetOwner());
|
||||
if (Role == nullptr) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::GetPaperFilpBookComponent, Can't get Role"));
|
||||
return false;
|
||||
}
|
||||
|
||||
UDataTable* DataTable = UBusyGameplayLibrary::GetGameDataTable("RoleAnimation");
|
||||
if (DataTable == nullptr) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::GetOwnerRoleInfo, Can't get Animation DataTable"))
|
||||
return false;
|
||||
}
|
||||
|
||||
FBusyRoleAnimationData* Config = DataTable->FindRow<FBusyRoleAnimationData>(
|
||||
Role->RoleName, TEXT("URoleAnimation::GetOwnerRoleInfo")
|
||||
);
|
||||
|
||||
if (Config == nullptr) {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::GetOwnerRoleInfo, Can't get role info from table"))
|
||||
return false;
|
||||
}
|
||||
|
||||
Sprite = Role->Sprite;
|
||||
AnimationData = Config;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void URoleAnimation::SetRoleAnimation(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim){
|
||||
if (Anim && *Anim) {
|
||||
Sprite->Stop();
|
||||
Sprite->SetLooping(true);
|
||||
Sprite->SetPlayRate(1.0);
|
||||
Sprite->SetFlipbook(*Anim);
|
||||
Sprite->PlayFromStart();
|
||||
} else {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetRoleAnimation, Can't set role animation"));
|
||||
}
|
||||
}
|
||||
|
||||
void URoleAnimation::PlayAnimationOnce(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim, float PlayRate){
|
||||
if (Anim && *Anim) {
|
||||
Sprite->Stop();
|
||||
Sprite->SetLooping(false);
|
||||
Sprite->SetPlayRate(PlayRate);
|
||||
Sprite->SetFlipbook(*Anim);
|
||||
Sprite->PlayFromStart();
|
||||
}
|
||||
else {
|
||||
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::PlayAnimationOnce failed"));
|
||||
}
|
||||
}
|
||||
@ -3,9 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Role/BusyRole.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Level/BusyLevelItem.h"
|
||||
#include "Engine/DataTable.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "GameAsset/BusyItem.h"
|
||||
@ -35,12 +33,6 @@ public:
|
||||
UFUNCTION(BlueprintPure)
|
||||
static bool GetLevelItemConfig(const FName& RowName, FBusyLevelItemConfig& RowData);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
static bool GetRoleConfig(const FName& RowName, FBusyRoleConfig& RowData);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
static bool GetItemResourceConfig(const FName& RowName, FBusyLevelItemResourceConfig& RowData);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
static bool GetLevelItemDescription(const FName& RowName, FBusyLevelItemDescription& RowData);
|
||||
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "BusyItem.generated.h"
|
||||
|
||||
class UPaperFlipbook;
|
||||
|
||||
UENUM(BlueprintType) // 烹饪火候
|
||||
enum class ECookingHeat : uint8 {
|
||||
LOW_HEAT, // 小火
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
#include "LuaOverriderInterface.h"
|
||||
#include "GameplayModMagnitudeCalculation.h"
|
||||
#include "BusyMagnitudeCalculation.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UBusyMagnitudeCalculation : public UGameplayModMagnitudeCalculation, public ILuaOverriderInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
virtual FString GetLuaFilePath_Implementation();
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
FString LuaFilePath;
|
||||
};
|
||||
|
||||
inline FString UBusyMagnitudeCalculation::GetLuaFilePath_Implementation()
|
||||
{
|
||||
return LuaFilePath;
|
||||
}
|
||||
@ -1,116 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LuaActor.h"
|
||||
#include "Engine/Datatable.h"
|
||||
#include "PaperFlipbookComponent.h"
|
||||
#include "Gas/BusyAttributeSet.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "GameAsset/BusyItem.h"
|
||||
#include "BusyLevelItem.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EBusyItemEffectType: uint8 {
|
||||
Health = 0,
|
||||
Hunger = 1,
|
||||
Speed = 2,
|
||||
};
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EBusyLevelItemType : uint8 {
|
||||
None = 0,
|
||||
Collection = 1,
|
||||
Building = 2,
|
||||
Reward= 3,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyLevelItemResourceConfig : public FTableRowBase { // 物品资源表
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品图标资源")
|
||||
TObjectPtr<UTexture2D> IconResource;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品静态资源")
|
||||
TObjectPtr<UPaperFlipbook> StaticResource;
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyLevelItemGenerateConfig {
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "每个周期生成物品的数量")
|
||||
int CountOfPeriod;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class BUSYRABBIT_API ABusyLevelItem : public ALuaActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
ABusyLevelItem();
|
||||
|
||||
public:
|
||||
virtual void OnConstruction(const FTransform& Transform) override;
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason)override;
|
||||
|
||||
virtual void PostLuaHook() override;
|
||||
|
||||
protected:
|
||||
void InitCapsule();
|
||||
void InitSprite();
|
||||
void InitPickBar();
|
||||
|
||||
void SetItemDisplay(const FName &ItemID);
|
||||
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UCapsuleComponent> CapsuleComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class USceneComponent> SceneComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UPaperFlipbookComponent> Sprite;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UBusyAbilitySystemComponent> AbilityComponent; // 技能组件
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UWidgetComponent> PickBar;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnyWhere, BlueprintReadOnly)
|
||||
FName CurrentItemID;
|
||||
|
||||
public: // 提供给蓝图的接口
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetLevelItemID(const FName& ItemID);
|
||||
|
||||
protected:
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FBusyLevelItemConfig LevelItemConfig;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UBusyLevelItemAttributeSet> LevelItemAttribute;
|
||||
|
||||
protected:
|
||||
bool bIsBeginPlay;
|
||||
|
||||
public: // 需要蓝图实现的函数
|
||||
// LevelItem被设置时的回调
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void ReceiveLevelItemSetted(const FBusyLevelItemConfig& Config);
|
||||
};
|
||||
@ -1,57 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LuaActor.h"
|
||||
#include "Engine/Datatable.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Core/BusyLuaActorComponent.h"
|
||||
#include "LevelItemReward.generated.h"
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FLevelItemRewardConfig : public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "道具备注")
|
||||
FString Comment;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品标签列表")
|
||||
FGameplayTagContainer TypeTagContainer;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "使用后能带来的效果")
|
||||
TMap<FGameplayTag, float> GameplayEffects;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class BUSYRABBIT_API ALevelItemReward : public ALuaActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
ALevelItemReward();
|
||||
|
||||
public:
|
||||
virtual void OnConstruction(const FTransform& Transform) override;
|
||||
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UCapsuleComponent> CapsuleComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class USceneComponent> SceneComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UPaperFlipbookComponent> Sprite;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetRewardID(const FName& CurrentRewardID);
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnyWhere, BlueprintReadOnly)
|
||||
FName RewardID;
|
||||
};
|
||||
@ -1,148 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "slua.h"
|
||||
#include "CoreMinimal.h"
|
||||
#include "LuaPawn.h"
|
||||
#include "Engine/Datatable.h"
|
||||
#include "Gas/BusyAttributeSet.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "BusyRole.generated.h"
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EBusyRoleState : uint8{
|
||||
BonfireIdle, // 篝火旁闲置
|
||||
Searching, // 外出搜索物品
|
||||
Picking, // 正在与物品交互
|
||||
PickFinished, // 与物品交互完毕
|
||||
BackBonfire, // 返回篝火
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyRoleConfig: public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的生命值")
|
||||
int32 Health;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的饥饿值")
|
||||
int32 Hunger;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色饥饿值消耗速度")
|
||||
int HungerConsumeSpeed;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色生命值消耗速度")
|
||||
int HealthConsumeSpeed;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的采集效率")
|
||||
int PickEffect;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的移动速度")
|
||||
int MoveSpeed;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的技能列表")
|
||||
TArray<TSubclassOf<UGameplayAbility>> DefaultAbilities;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyRoleResourceConfig : public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色头像图标")
|
||||
int32 Health;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class BUSYRABBIT_API ABusyRole : public ALuaPawn{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
ABusyRole();
|
||||
virtual void BeginPlay()override;
|
||||
virtual void Tick(float InDeltaSeconds)override;
|
||||
|
||||
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class USceneComponent> SceneComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class USpringArmComponent> SpringArmComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UCapsuleComponent> CapsuleComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UBusyCameraComponent> CameraComp;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UPaperFlipbookComponent> Sprite;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UBusyRoleMovement> Movement; // 移动组件
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UPW_AbilitySystemComponent> RoleAbility; // 技能组件
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<class UInventoryComponent> Inventory; // 仓库组件
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
TObjectPtr<class URoleAnimation> RoleAnimation;
|
||||
|
||||
public: // 蓝图接口
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetRole(const FName& Name);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void TryActiveAbility(const FName& TagName, const FGameplayEventData& EventData);
|
||||
|
||||
public:
|
||||
// 输入相关
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Input")
|
||||
TObjectPtr<class UInputMappingContext> InputMapping;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Input")
|
||||
TObjectPtr<class UInputAction> TouchAction;
|
||||
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)override;
|
||||
|
||||
protected:
|
||||
void InitCapsule();
|
||||
|
||||
public: // 蓝图实现
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void OnTouch(const FInputActionValue& Value) const;
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void OnOverlapBegin(
|
||||
UPrimitiveComponent* OverlappedComp,
|
||||
AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp,
|
||||
int32 OtherBodyIndex,
|
||||
bool bFromSweep,
|
||||
const FHitResult& SweepResult
|
||||
);
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void ReceiveSetRole(const FBusyRoleConfig& RoleTableConfig);
|
||||
|
||||
protected:
|
||||
FTimerHandle TimerHandle;
|
||||
|
||||
public: // 角色属性
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FName RoleName;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Value")
|
||||
FBusyRoleConfig RoleConfig;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TObjectPtr<UBusyRoleAttributeSet> RoleAttribute;
|
||||
|
||||
public: // 不暴露给蓝图的属性
|
||||
|
||||
};
|
||||
@ -1,43 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LuaOverriderInterface.h"
|
||||
#include "LuaActorComponent.h"
|
||||
#include "GameFramework/MovementComponent.h"
|
||||
#include "BusyRoleMovement.generated.h"
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class ERoleMoveDirection: uint8 {
|
||||
Move_Right,
|
||||
Move_Left,
|
||||
Move_All_Cnt
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class BUSYRABBIT_API UBusyRoleMovement : public ULuaActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UBusyRoleMovement();
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
virtual void BeginPlay()override;
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void ReceiveComponentTick(float DeltaTime);
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void ReceiveComponentBeginPlay();
|
||||
|
||||
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)override;
|
||||
|
||||
protected:
|
||||
FVector MovementDirection;
|
||||
};
|
||||
@ -1,77 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LuaActorComponent.h"
|
||||
#include "Engine/Datatable.h"
|
||||
#include "PaperFlipbookComponent.h"
|
||||
#include "BusyRoleMovement.h"
|
||||
#include "../Core/BusyLuaActorComponent.h"
|
||||
#include "RoleAnimation.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogRoleAnimation, Log, All);
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EBusyAnimationPhase : uint8{
|
||||
PrepareCast, // 动作前摇阶段
|
||||
Casting, // 动作释放阶段
|
||||
PostCast, // 动作后摇阶段
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyAnimationPhaseData : public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "各个阶段的动作")
|
||||
TMap<EBusyAnimationPhase, UPaperFlipbook*> PhaseAnimation;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyRolePickingAnimationData : public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "各个方向的采集动作")
|
||||
TMap<ERoleMoveDirection, FBusyAnimationPhaseData> DirectionAnimations;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyRoleAnimationData : public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "移动时的动作")
|
||||
TMap<ERoleMoveDirection, UPaperFlipbook*> MoveAnimations;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "静止时的动作")
|
||||
TMap<ERoleMoveDirection, UPaperFlipbook*> IdleAnimations;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "采集物品时的动作")
|
||||
TMap<FName, FBusyRolePickingAnimationData> PickingAnimations;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class BUSYRABBIT_API URoleAnimation : public UBusyLuaActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
URoleAnimation();
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetMoveAnimation(ERoleMoveDirection direction);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetIdleAnimation(ERoleMoveDirection direction);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void PlayPickAnimation(const FName& ItemName, ERoleMoveDirection Direction, EBusyAnimationPhase Phase, float PlayRate);
|
||||
|
||||
protected:
|
||||
bool GetOwnerRoleInfo(UPaperFlipbookComponent* &Sprite, FBusyRoleAnimationData* &AnimationData);
|
||||
|
||||
// 设置表格里面的动作
|
||||
void SetRoleAnimation(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim);
|
||||
|
||||
void PlayAnimationOnce(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim, float PlayRate);
|
||||
};
|
||||
Reference in New Issue
Block a user