添加鱼竿component 和对应的配表
This commit is contained in:
parent
5e186c3d06
commit
ff988535aa
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/DataTable/FishRobs.uasset
Normal file
BIN
ProjectFish/Content/DataTable/FishRobs.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,80 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "FishingRodComponent.h"
|
||||
|
||||
#include "EngineUtils.h"
|
||||
#include "ProjectFish/Definations.h"
|
||||
#include "ProjectFish/PawnWithSkill.h"
|
||||
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UFishingRobComponent::UFishingRobComponent()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void UFishingRobComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
for (auto rowName: FishRobData.DataTable->GetRowMap())
|
||||
{
|
||||
FFishingRod* data = reinterpret_cast<FFishingRod*>(rowName.Value);
|
||||
if (data && data->FishingRod_Name ==FishRobData.RowContents )
|
||||
{
|
||||
FishRob = *data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(GetOwner());
|
||||
|
||||
if (OwnerPawn != nullptr)
|
||||
{
|
||||
//叠加角色的属性信息
|
||||
OwnerPawn->CurrentEndurance += FishRob.Endurance_Add;
|
||||
OwnerPawn->MaxEndurance += FishRob.Endurance_Add;
|
||||
OwnerPawn->CurrentTenacity += FishRob.Tenacity_Add;
|
||||
OwnerPawn->MaxTenacity+= FishRob.Tenacity_Add;
|
||||
|
||||
GetWorld()->GetTimerManager().SetTimerForNextTick([this, OwnerPawn]()
|
||||
{
|
||||
// 执行依赖其他Actor的逻辑
|
||||
for (auto pawn: TActorRange<APawnWithSkill>(GetWorld()))
|
||||
{
|
||||
if (pawn != OwnerPawn)
|
||||
{
|
||||
Enemy = pawn;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void UFishingRobComponent::TickComponent(float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
CurrentCDTime += DeltaTime;
|
||||
if (CurrentCDTime >= FishRob.DamageCD)
|
||||
{
|
||||
CurrentCDTime = 0;
|
||||
UE_LOG(LogTemp, Warning, TEXT("鱼竿: %s 造成伤害 %d"), *FishRob.FishingRod_Name.ToString(), FishRob.Damage);
|
||||
if (Enemy)
|
||||
{
|
||||
Enemy->ApplyyEndurance(-FishRob.Damage);
|
||||
}
|
||||
}
|
||||
// ...
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "ProjectFish/Definations.h"
|
||||
#include "FishingRodComponent.generated.h"
|
||||
|
||||
|
||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||
class PROJECTFISH_API UFishingRobComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UFishingRobComponent();
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
|
||||
FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿配置文件"))
|
||||
FDataTableCategoryHandle FishRobData;
|
||||
|
||||
FFishingRod FishRob;
|
||||
class APawnWithSkill* Enemy;
|
||||
float CurrentCDTime = 0.f;
|
||||
};
|
@ -152,3 +152,43 @@ class PROJECTFISH_API UDefinations : public UObject
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FFishingRodSkill
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿技能名称"))
|
||||
FName SkillName;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (AllowedClasses = "Object", ToolTip = "技能图片"))
|
||||
FSoftObjectPath SkillObject;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FFishingRod: public FTableRowBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿名称"))
|
||||
FName FishingRod_Name;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿伤害CD"))
|
||||
int32 DamageCD;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿伤害"))
|
||||
int32 Damage;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "附加的耐力值"))
|
||||
int32 Endurance_Add;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "附加的附加的韧性值"))
|
||||
int32 Tenacity_Add;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "物品背包大小"))
|
||||
FIntPoint BagSize;
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能效果组"))
|
||||
TArray<FFishingRodSkill> Skills;
|
||||
};
|
||||
|
@ -25,8 +25,8 @@ void APawnWithSkill::ApplyyTenacity_Implementation(float tenacityOffset)
|
||||
void APawnWithSkill::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
CurrentEndurance = MaxEndurance;
|
||||
CurrentTenacity = MaxTenacity;
|
||||
CurrentEndurance += MaxEndurance;
|
||||
CurrentTenacity += MaxTenacity;
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
|
@ -7,7 +7,7 @@ public class ProjectFish : ModuleRules
|
||||
public ProjectFish(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
OptimizeCode = CodeOptimization.Never;
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput", "GameplayTags" });
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user