diff --git a/ProjectFish/Content/Characters/BP_Dabaza_Pawn.uasset b/ProjectFish/Content/Characters/BP_Dabaza_Pawn.uasset index 957108a..b7b30e3 100644 Binary files a/ProjectFish/Content/Characters/BP_Dabaza_Pawn.uasset and b/ProjectFish/Content/Characters/BP_Dabaza_Pawn.uasset differ diff --git a/ProjectFish/Content/Characters/BP_DeepFish.uasset b/ProjectFish/Content/Characters/BP_DeepFish.uasset index 876ede7..310518b 100644 Binary files a/ProjectFish/Content/Characters/BP_DeepFish.uasset and b/ProjectFish/Content/Characters/BP_DeepFish.uasset differ diff --git a/ProjectFish/Content/DataTable/FishRobs.uasset b/ProjectFish/Content/DataTable/FishRobs.uasset new file mode 100644 index 0000000..d020e53 Binary files /dev/null and b/ProjectFish/Content/DataTable/FishRobs.uasset differ diff --git a/ProjectFish/Content/Gameplay/BP_Dabaza_GameMode.uasset b/ProjectFish/Content/Gameplay/BP_Dabaza_GameMode.uasset index c715d86..40d25e1 100644 Binary files a/ProjectFish/Content/Gameplay/BP_Dabaza_GameMode.uasset and b/ProjectFish/Content/Gameplay/BP_Dabaza_GameMode.uasset differ diff --git a/ProjectFish/Content/__ExternalActors__/Maps/Dabaza/8/VO/DV1AKH9EUYVRMVYP3DYZVH.uasset b/ProjectFish/Content/__ExternalActors__/Maps/Dabaza/8/VO/DV1AKH9EUYVRMVYP3DYZVH.uasset index c76dfe3..9d855e9 100644 Binary files a/ProjectFish/Content/__ExternalActors__/Maps/Dabaza/8/VO/DV1AKH9EUYVRMVYP3DYZVH.uasset and b/ProjectFish/Content/__ExternalActors__/Maps/Dabaza/8/VO/DV1AKH9EUYVRMVYP3DYZVH.uasset differ diff --git a/ProjectFish/Source/ProjectFish/Components/FishingRodComponent.cpp b/ProjectFish/Source/ProjectFish/Components/FishingRodComponent.cpp new file mode 100644 index 0000000..de222d7 --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Components/FishingRodComponent.cpp @@ -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(rowName.Value); + if (data && data->FishingRod_Name ==FishRobData.RowContents ) + { + FishRob = *data; + break; + } + } + APawnWithSkill* OwnerPawn = Cast(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(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); + } + } + // ... +} + diff --git a/ProjectFish/Source/ProjectFish/Components/FishingRodComponent.h b/ProjectFish/Source/ProjectFish/Components/FishingRodComponent.h new file mode 100644 index 0000000..af6e965 --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Components/FishingRodComponent.h @@ -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; +}; diff --git a/ProjectFish/Source/ProjectFish/Definations.h b/ProjectFish/Source/ProjectFish/Definations.h index c49fae6..9562236 100644 --- a/ProjectFish/Source/ProjectFish/Definations.h +++ b/ProjectFish/Source/ProjectFish/Definations.h @@ -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 Skills; +}; diff --git a/ProjectFish/Source/ProjectFish/PawnWithSkill.cpp b/ProjectFish/Source/ProjectFish/PawnWithSkill.cpp index e6e45ea..d06b4cd 100644 --- a/ProjectFish/Source/ProjectFish/PawnWithSkill.cpp +++ b/ProjectFish/Source/ProjectFish/PawnWithSkill.cpp @@ -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 diff --git a/ProjectFish/Source/ProjectFish/ProjectFish.Build.cs b/ProjectFish/Source/ProjectFish/ProjectFish.Build.cs index 144f1bd..fbd275c 100644 --- a/ProjectFish/Source/ProjectFish/ProjectFish.Build.cs +++ b/ProjectFish/Source/ProjectFish/ProjectFish.Build.cs @@ -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" }); } }