Compare commits
No commits in common. "d8623fb375e930b7a20a7a53db92c3d1aec63a2d" and "2984aaa4bed71f1d2b4f0c5a58a65fed38177137" have entirely different histories.
d8623fb375
...
2984aaa4be
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/UI/WBP_EnduranceBar.uasset
Normal file
BIN
ProjectFish/Content/UI/WBP_EnduranceBar.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,96 +0,0 @@
|
|||||||
// 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
|
|
||||||
UFishingRodComponent::UFishingRodComponent()
|
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
void UFishingRodComponent::AddFishRodDamage(int32 Damage)
|
|
||||||
{
|
|
||||||
FishRodData.Damage += Damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Called when the game starts
|
|
||||||
void UFishingRodComponent::BeginPlay()
|
|
||||||
{
|
|
||||||
Super::BeginPlay();
|
|
||||||
|
|
||||||
for (auto rowName: FishRodDataTable.DataTable->GetRowMap())
|
|
||||||
{
|
|
||||||
FFishingRod* data = reinterpret_cast<FFishingRod*>(rowName.Value);
|
|
||||||
if (data && data->FishingRod_Name ==FishRodDataTable.RowContents )
|
|
||||||
{
|
|
||||||
FishRodData = *data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(GetOwner());
|
|
||||||
|
|
||||||
if (OwnerPawn != nullptr)
|
|
||||||
{
|
|
||||||
//叠加角色的属性信息
|
|
||||||
OwnerPawn->CurrentEndurance += FishRodData.Endurance_Add;
|
|
||||||
OwnerPawn->MaxEndurance += FishRodData.Endurance_Add;
|
|
||||||
OwnerPawn->CurrentTenacity += FishRodData.Tenacity_Add;
|
|
||||||
OwnerPawn->MaxTenacity+= FishRodData.Tenacity_Add;
|
|
||||||
|
|
||||||
GetWorld()->GetTimerManager().SetTimerForNextTick([this, OwnerPawn]()
|
|
||||||
{
|
|
||||||
// 执行依赖其他Actor的逻辑
|
|
||||||
for (auto pawn: TActorRange<APawnWithSkill>(GetWorld()))
|
|
||||||
{
|
|
||||||
if (pawn != OwnerPawn)
|
|
||||||
{
|
|
||||||
Enemy = pawn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//初始化鱼竿技能
|
|
||||||
for (auto skill : FishRodData.Skills)
|
|
||||||
{
|
|
||||||
UFishingRodSKill_Base* SkillObject = NewObject<UFishingRodSKill_Base>(OwnerPawn, skill.SkillClass);
|
|
||||||
if (SkillObject != nullptr)
|
|
||||||
{
|
|
||||||
FRSkills.Add(SkillObject);
|
|
||||||
SkillObject->Init(OwnerPawn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
// ...
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Called every frame
|
|
||||||
void UFishingRodComponent::TickComponent(float DeltaTime, ELevelTick TickType,
|
|
||||||
FActorComponentTickFunction* ThisTickFunction)
|
|
||||||
{
|
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
|
||||||
CurrentCDTime += DeltaTime;
|
|
||||||
if (CurrentCDTime >= FishRodData.DamageCD)
|
|
||||||
{
|
|
||||||
CurrentCDTime = 0;
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("鱼竿: %s 造成伤害 %d"), *FishRodData.FishingRod_Name.ToString(), FishRodData.Damage);
|
|
||||||
if (Enemy)
|
|
||||||
{
|
|
||||||
Enemy->ApplyyEndurance(-FishRodData.Damage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
|||||||
// 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 "ProjectFish/FishingRodSKill_Base.h"
|
|
||||||
#include "FishingRodComponent.generated.h"
|
|
||||||
|
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
|
||||||
class PROJECTFISH_API UFishingRodComponent : public UActorComponent
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Sets default values for this component's properties
|
|
||||||
UFishingRodComponent();
|
|
||||||
void AddFishRodDamage(int32 Damage);
|
|
||||||
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, meta = (ToolTip = "鱼竿配置文件"))
|
|
||||||
FDataTableCategoryHandle FishRodDataTable;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "鱼竿数据"))
|
|
||||||
FFishingRod FishRodData;
|
|
||||||
|
|
||||||
class APawnWithSkill* Enemy;
|
|
||||||
float CurrentCDTime = 0.f;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly)
|
|
||||||
TArray<UFishingRodSKill_Base*> FRSkills;
|
|
||||||
};
|
|
@ -17,38 +17,34 @@ enum class ESkillEffectType: uint8
|
|||||||
Charge UMETA(DisplayName = "充能", ToolTip = "使技能的冷却进度加快"),
|
Charge UMETA(DisplayName = "充能", ToolTip = "使技能的冷却进度加快"),
|
||||||
ModifySpeed UMETA(DisplayName = "速度修改", ToolTip = "使技能冷却进度倍率进展 持续指定时间"),
|
ModifySpeed UMETA(DisplayName = "速度修改", ToolTip = "使技能冷却进度倍率进展 持续指定时间"),
|
||||||
SkillEnduranceRestore UMETA(DisplayName = "技能耐久度恢复", ToolTip = "使技能耐久度恢复"),
|
SkillEnduranceRestore UMETA(DisplayName = "技能耐久度恢复", ToolTip = "使技能耐久度恢复"),
|
||||||
EnhanceFishRod UMETA(DisplayName = "增强鱼竿", ToolTip = "使鱼竿上海增加"),
|
|
||||||
EnhanceSkill UMETA(DisplayName = "增强技能", ToolTip = "增强指定的技能数值"),
|
|
||||||
DamageReduce UMETA(DisplayName = "减伤", ToolTip = "减少所受的伤害"),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//技能对象类型
|
//技能对象类型
|
||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class ESkillTargetType: uint8
|
enum class ESkillTargetType: uint8
|
||||||
{
|
{
|
||||||
Self UMETA(DisplayName = "目标是自身角色"),
|
Self UMETA(DisplayName = "自身"),
|
||||||
Other UMETA(DisplayName = "目标是对方角色"),
|
Other UMETA(DisplayName = "对方"),
|
||||||
Around UMETA(DisplayName = "格子周围的技能")
|
AdjacentLeft UMETA(DisplayName = "左侧相邻"),
|
||||||
// AdjacentLeft UMETA(DisplayName = "左侧相邻"),
|
AdjacentRight UMETA(DisplayName = "右侧相邻"),
|
||||||
// AdjacentRight UMETA(DisplayName = "右侧相邻"),
|
AllLeft UMETA(DisplayName = "左侧全部"),
|
||||||
// AllLeft UMETA(DisplayName = "左侧全部"),
|
AllRight UMETA(DisplayName = "右侧全部"),
|
||||||
// AllRight UMETA(DisplayName = "右侧全部"),
|
|
||||||
};
|
};
|
||||||
//随机对象类型
|
//随机对象类型
|
||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class ERandomTargetType: uint8
|
enum class ERandomTargetType: uint8
|
||||||
{
|
{
|
||||||
AllSelf UMETA(DisplayName = "我方全部技能"),
|
AllSelf UMETA(DisplayName = "我方全部"),
|
||||||
AllOther UMETA(DisplayName = "敌方全部技能"),
|
AllOther UMETA(DisplayName = "敌方全部"),
|
||||||
};
|
};
|
||||||
|
|
||||||
//技能选择器类型
|
//技能选择器类型
|
||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class ETargetSelecterType: uint8
|
enum class ETargetSelecterType: uint8
|
||||||
{
|
{
|
||||||
SkillPos UMETA(DisplayName = "指定对象选择"),
|
SkillPos UMETA(DisplayName = "根据技能位置选择"),
|
||||||
SkillTag UMETA(DisplayName = "根据技能Tag选择"),
|
SkillTag UMETA(DisplayName = "根据技能Tag选择"),
|
||||||
RandomScope UMETA(DisplayName = "指定技能组选择"),
|
RandomScope UMETA(DisplayName = "随机范围选择"),
|
||||||
};
|
};
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
@ -57,8 +53,8 @@ struct FSkillContext
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "敌人"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "敌人"))
|
||||||
class USkillManager* SkillManager;
|
class USkillManager* SkillManager;
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "所属的技能"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "自身"))
|
||||||
class USkill* OwnerSkill;
|
APawnWithSkill* Self;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,30 +112,20 @@ struct FSkillData: public FTableRowBase
|
|||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (AllowedClasses = "Texture2D", ToolTip = "技能图片"))
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (AllowedClasses = "Texture2D", ToolTip = "技能图片"))
|
||||||
FSoftObjectPath SkillTexture;
|
FSoftObjectPath SkillTexture;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD"))
|
||||||
|
float CD;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD速度"))
|
||||||
|
float Speed = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能耐久度"))
|
||||||
|
int32 Endurance;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能Tag"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能Tag"))
|
||||||
FGameplayTag SkillTag;
|
FGameplayTag SkillTag;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "背包占用"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "背包占用"))
|
||||||
FIntPoint SkillWeight = FIntPoint(1, 1);
|
int32 WeightLimit;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "是否为主动技能"))
|
|
||||||
bool bActiveSkill = true;
|
|
||||||
|
|
||||||
//主动技能属性
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD", EditConditionHides, EditCondition = "bActiveSkill"))
|
|
||||||
float CD;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能CD速度", EditConditionHides, EditCondition = "bActiveSkill"))
|
|
||||||
float Speed = 1.0f;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能耐久度", EditConditionHides, EditCondition = "bActiveSkill"))
|
|
||||||
int32 Endurance;
|
|
||||||
|
|
||||||
//被动技能属性
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "被动技能触发器,没有配置的话为光环类技能默认进行触发", AllowedClasses = "SkillTrigger", EditConditionHides, EditCondition = "!bActiveSkill"))
|
|
||||||
TSubclassOf<class USkillTrigger> SkillTrigger;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能效果组"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "技能效果组"))
|
||||||
TArray<FSkillEffectData> SkillEffects;
|
TArray<FSkillEffectData> SkillEffects;
|
||||||
@ -156,7 +142,6 @@ public:
|
|||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
FName SkillRowName;
|
FName SkillRowName;
|
||||||
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -167,43 +152,3 @@ class PROJECTFISH_API UDefinations : public UObject
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
|
||||||
struct FFishingRodSkill
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "鱼竿技能名称"))
|
|
||||||
FName SkillName;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "鱼钩技能"))
|
|
||||||
TSubclassOf<class UFishingRodSKill_Base> SkillClass;
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "FishingRodSKill_Base.h"
|
|
||||||
|
|
||||||
UFishingRodSKill_Base::UFishingRodSKill_Base()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "Definations.h"
|
|
||||||
#include "UObject/Object.h"
|
|
||||||
#include "FishingRodSKill_Base.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS(Blueprintable)
|
|
||||||
class PROJECTFISH_API UFishingRodSKill_Base : public UObject
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
UFishingRodSKill_Base();
|
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
|
||||||
void Init(class APawnWithSkill* Owner);
|
|
||||||
|
|
||||||
};
|
|
@ -13,33 +13,14 @@ APawnWithSkill::APawnWithSkill()
|
|||||||
|
|
||||||
void APawnWithSkill::ApplyyEndurance_Implementation(float enduranceOffset)
|
void APawnWithSkill::ApplyyEndurance_Implementation(float enduranceOffset)
|
||||||
{
|
{
|
||||||
if (enduranceOffset < 0)
|
|
||||||
{
|
|
||||||
//受到伤害
|
|
||||||
OnReceiveDamage.Broadcast();
|
|
||||||
//受到的伤害最低为1点
|
|
||||||
enduranceOffset = FMath::Min(-1, enduranceOffset + DamageReduce);
|
|
||||||
}
|
|
||||||
CurrentEndurance += enduranceOffset;;
|
CurrentEndurance += enduranceOffset;;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void APawnWithSkill::ApplyyTenacity_Implementation(float tenacityOffset)
|
|
||||||
{
|
|
||||||
CurrentTenacity += tenacityOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void APawnWithSkill::SetDamageReduce(int32 damageReduce)
|
|
||||||
{
|
|
||||||
DamageReduce = damageReduce;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
void APawnWithSkill::BeginPlay()
|
void APawnWithSkill::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
CurrentEndurance += MaxEndurance;
|
CurrentEndurance = MaxEndurance;
|
||||||
CurrentTenacity += MaxTenacity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "GameFramework/Pawn.h"
|
#include "GameFramework/Pawn.h"
|
||||||
#include "PawnWithSkill.generated.h"
|
#include "PawnWithSkill.generated.h"
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnReceiveDamage);
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class PROJECTFISH_API APawnWithSkill : public APawn
|
class PROJECTFISH_API APawnWithSkill : public APawn
|
||||||
{
|
{
|
||||||
@ -17,10 +16,6 @@ public:
|
|||||||
APawnWithSkill();
|
APawnWithSkill();
|
||||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
||||||
void ApplyyEndurance(float enduranceOffset);
|
void ApplyyEndurance(float enduranceOffset);
|
||||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
|
||||||
void ApplyyTenacity(float tenacityOffset);
|
|
||||||
|
|
||||||
void SetDamageReduce(int32 damageReduce);
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
@ -35,22 +30,6 @@ public:
|
|||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "当前耐久度"))
|
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "当前耐久度"))
|
||||||
float CurrentEndurance;
|
float CurrentEndurance;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "减伤值"))
|
|
||||||
float DamageReduce;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "最大耐久度"))
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "最大耐久度"))
|
||||||
float MaxEndurance;
|
float MaxEndurance;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "当前韧性"))
|
|
||||||
float CurrentTenacity;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "最大韧性"))
|
|
||||||
float MaxTenacity;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "韧性归零时眩晕时长"))
|
|
||||||
float TenacityStun_Time = 5;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable)
|
|
||||||
FOnReceiveDamage OnReceiveDamage;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ public class ProjectFish : ModuleRules
|
|||||||
public ProjectFish(ReadOnlyTargetRules Target) : base(Target)
|
public ProjectFish(ReadOnlyTargetRules Target) : base(Target)
|
||||||
{
|
{
|
||||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||||
OptimizeCode = CodeOptimization.Never;
|
|
||||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput", "GameplayTags" });
|
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput", "GameplayTags" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,23 +3,18 @@
|
|||||||
|
|
||||||
#include "Skill.h"
|
#include "Skill.h"
|
||||||
|
|
||||||
#include "SkillTrigger.h"
|
|
||||||
#include "SkillEffects/SkillEffect_Charge.h"
|
#include "SkillEffects/SkillEffect_Charge.h"
|
||||||
#include "SkillEffects/SkillEffect_Damage.h"
|
#include "SkillEffects/SkillEffect_Damage.h"
|
||||||
#include "SkillEffects/SkillEffect_DamageReduce.h"
|
|
||||||
#include "SkillEffects/SkillEffect_EnhanceFishRod.h"
|
|
||||||
#include "SkillEffects/SkillEffect_EnhanceSkill.h"
|
|
||||||
#include "SkillEffects/SkillEffect_Heal.h"
|
#include "SkillEffects/SkillEffect_Heal.h"
|
||||||
#include "SkillEffects/SkillEffect_ModifyCD.h"
|
#include "SkillEffects/SkillEffect_ModifyCD.h"
|
||||||
#include "SkillEffects/SkillEffect_ModifySpeed.h"
|
#include "SkillEffects/SkillEffect_ModifySpeed.h"
|
||||||
#include "SkillEffects/SkillEffect_SER.h"
|
#include "SkillEffects/SkillEffect_SER.h"
|
||||||
|
|
||||||
void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkillData skillData, FIntPoint BagPos)
|
void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkillData skillData)
|
||||||
{
|
{
|
||||||
this->Owner = owner;
|
this->Owner = owner;
|
||||||
this->SkillManager = skillManager;
|
this->SkillManager = skillManager;
|
||||||
this->SkillData = skillData;
|
this->SkillData = skillData;
|
||||||
this->BagPosition = BagPos;
|
|
||||||
this->RemainingTime = SkillData.CD;
|
this->RemainingTime = SkillData.CD;
|
||||||
this->RemainingEndurance = SkillData.Endurance;
|
this->RemainingEndurance = SkillData.Endurance;
|
||||||
for (auto effectData: skillData.SkillEffects)
|
for (auto effectData: skillData.SkillEffects)
|
||||||
@ -45,18 +40,6 @@ void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkil
|
|||||||
case ESkillEffectType::SkillEnduranceRestore:
|
case ESkillEffectType::SkillEnduranceRestore:
|
||||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_SER::StaticClass());
|
skillEffect = NewObject<USkillEffect>(this, USkillEffect_SER::StaticClass());
|
||||||
break;
|
break;
|
||||||
case ESkillEffectType::EnhanceFishRod:
|
|
||||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_EnhanceFishRod::StaticClass());
|
|
||||||
break;
|
|
||||||
case ESkillEffectType::EnhanceSkill:
|
|
||||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_EnhanceSkill::StaticClass());
|
|
||||||
break;
|
|
||||||
case ESkillEffectType::DamageReduce:
|
|
||||||
skillEffect = NewObject<USkillEffect>(this, USkillEffect_DamageReduce::StaticClass());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
const UEnum* EnumPtr = StaticEnum<ESkillEffectType>();
|
|
||||||
UE_LOG(LogTemp, Error, TEXT("没有配置 %s类型的Skill Effect"), *EnumPtr->GetNameStringByValue(static_cast<int64>(effectData.EffectType)))
|
|
||||||
}
|
}
|
||||||
if (IsValid(skillEffect))
|
if (IsValid(skillEffect))
|
||||||
{
|
{
|
||||||
@ -67,67 +50,35 @@ void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USkill::InitSkillTrigger()
|
|
||||||
{
|
|
||||||
if (!SkillData.bActiveSkill)
|
|
||||||
{
|
|
||||||
if (SkillData.SkillTrigger)
|
|
||||||
{
|
|
||||||
USkillTrigger* SkillTrigger = NewObject<USkillTrigger>(this, SkillData.SkillTrigger);
|
|
||||||
FSkillContext context;
|
|
||||||
context.OwnerSkill = this;
|
|
||||||
context.SkillManager = SkillManager;
|
|
||||||
SkillTrigger->Init(context);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//UE_LOG(LogTemp, Warning, TEXT("没有Trigger的被动技能,直接触发"));
|
|
||||||
ExecuteSkill();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool USkill::SkillTickAble()
|
bool USkill::SkillTickAble()
|
||||||
{
|
{
|
||||||
//剩余次数无限制或者拥有者没有被韧性眩晕
|
return RemainingEndurance >0 || RemainingEndurance == -1;
|
||||||
return (RemainingEndurance >0 || RemainingEndurance == -1 ) && Owner->CurrentTenacity > 0 && SkillData.bActiveSkill;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void USkill::TickSkill(float deltaTime)
|
void USkill::TickSkill(float deltaTime)
|
||||||
{
|
{
|
||||||
if (SkillTickAble())
|
|
||||||
RemainingTime -= deltaTime * SkillData.Speed;
|
RemainingTime -= deltaTime * SkillData.Speed;
|
||||||
if (RemainingTime <= 0 )
|
if (RemainingTime <= 0 && SkillTickAble())
|
||||||
{
|
|
||||||
ExecuteSkill();
|
|
||||||
}
|
|
||||||
if (RemainingEndurance == 0)
|
|
||||||
{
|
|
||||||
FSkillContext context;
|
|
||||||
context.OwnerSkill = this;
|
|
||||||
context.SkillManager = SkillManager;
|
|
||||||
for (auto Effect: SkillEffects)
|
|
||||||
{
|
|
||||||
Effect->EffectEnded(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void USkill::ExecuteSkill()
|
|
||||||
{
|
{
|
||||||
RemainingTime = 0;
|
RemainingTime = 0;
|
||||||
if (RemainingEndurance >0)
|
if (RemainingEndurance >0)
|
||||||
--RemainingEndurance;
|
--RemainingEndurance;
|
||||||
FSkillContext context;
|
FSkillContext context;
|
||||||
context.OwnerSkill = this;
|
context.Self = Owner;
|
||||||
context.SkillManager = SkillManager;
|
context.SkillManager = SkillManager;
|
||||||
for (auto Effect: SkillEffects)
|
for (auto Effect: SkillEffects)
|
||||||
{
|
{
|
||||||
Effect->Execute(context);
|
Effect->Execute(context);
|
||||||
}
|
}
|
||||||
RemainingTime = SkillData.CD;
|
RemainingTime = SkillData.CD;
|
||||||
OnSkillExecute.Broadcast(SkillData.SkillName.ToString());
|
}
|
||||||
|
if (RemainingEndurance == 0)
|
||||||
|
{
|
||||||
|
for (auto Effect: SkillEffects)
|
||||||
|
{
|
||||||
|
Effect->EffectEnded();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FString USkill::GetSkillName() const
|
FString USkill::GetSkillName() const
|
||||||
@ -140,11 +91,6 @@ FSkillData& USkill::GetSkillData()
|
|||||||
return SkillData;
|
return SkillData;
|
||||||
}
|
}
|
||||||
|
|
||||||
FIntPoint USkill::GetBagPos()
|
|
||||||
{
|
|
||||||
return BagPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void USkill::SetSkillData(FSkillData data)
|
void USkill::SetSkillData(FSkillData data)
|
||||||
{
|
{
|
||||||
SkillData = data;
|
SkillData = data;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "Skill.generated.h"
|
#include "Skill.generated.h"
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FSkillUpdate);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FSkillUpdate);
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSkillExecute, FString, SkillName );
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -19,23 +19,14 @@ class PROJECTFISH_API USkill : public UObject
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
void InitSkill(class APawnWithSkill* owner, USkillManager* skillManager, FSkillData SkillData, FIntPoint BagPos);
|
void InitSkill(class APawnWithSkill* owner, USkillManager* skillManager, FSkillData SkillData);
|
||||||
void InitSkillTrigger();
|
|
||||||
void TickSkill(float deltaTime);
|
void TickSkill(float deltaTime);
|
||||||
void ExecuteSkill();
|
|
||||||
|
|
||||||
FString GetSkillName() const;
|
FString GetSkillName() const;
|
||||||
class APawnWithSkill* GetOwner();
|
class APawnWithSkill* GetOwner();
|
||||||
|
|
||||||
FSkillData& GetSkillData();
|
FSkillData& GetSkillData();
|
||||||
TArray<USkillEffect*> GetAllSkillEffects()
|
|
||||||
{
|
|
||||||
return SkillEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
FIntPoint GetBagPos();
|
|
||||||
void SetSkillData( FSkillData SkillData);
|
void SetSkillData( FSkillData SkillData);
|
||||||
UFUNCTION(BlueprintCallable)
|
|
||||||
void ApplyRemainingTimeOffset(int timeOffset);
|
void ApplyRemainingTimeOffset(int timeOffset);
|
||||||
void ApplyRemainingRemainingEnduranceOffset(int Offset);
|
void ApplyRemainingRemainingEnduranceOffset(int Offset);
|
||||||
|
|
||||||
@ -44,9 +35,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
UPROPERTY(BlueprintAssignable)
|
UPROPERTY(BlueprintAssignable)
|
||||||
FSkillUpdate OnSkillUpdate;
|
FSkillUpdate OnSkillUpdate;
|
||||||
UPROPERTY(BlueprintAssignable)
|
|
||||||
FSkillExecute OnSkillExecute;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "技能效果"))
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "技能效果"))
|
||||||
FSkillData SkillData;
|
FSkillData SkillData;
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "技能效果"))
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "技能效果"))
|
||||||
@ -59,9 +47,6 @@ protected:
|
|||||||
float RemainingTime;
|
float RemainingTime;
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "剩余耐久度"))
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "剩余耐久度"))
|
||||||
int32 RemainingEndurance;
|
int32 RemainingEndurance;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, EditAnywhere, meta = (ToolTip = "背包位置"))
|
|
||||||
FIntPoint BagPosition;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,14 +34,13 @@ void USkillEffect::Execute(const FSkillContext& context)
|
|||||||
const UEnum* EnumPtr = StaticEnum<ESkillEffectType>();
|
const UEnum* EnumPtr = StaticEnum<ESkillEffectType>();
|
||||||
FString type = EnumPtr->GetNameStringByValue(static_cast<int64>(effectData.EffectType)) ;
|
FString type = EnumPtr->GetNameStringByValue(static_cast<int64>(effectData.EffectType)) ;
|
||||||
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("技能:%s 拥有者: %s 目标: %s 效果: %s")
|
UE_LOG(LogTemp, Warning, TEXT("技能:%s 目标: %s 效果: %s")
|
||||||
, *OwnerSkill->GetSkillData().SkillName.ToString()
|
, *OwnerSkill->GetSkillData().SkillName.ToString()
|
||||||
,*OwnerSkill->GetOwner()->GetActorNameOrLabel()
|
|
||||||
,*strTargets
|
,*strTargets
|
||||||
, *( GetSkillEffectDes()));
|
, *( GetSkillEffectDes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void USkillEffect::EffectEnded(const FSkillContext& context)
|
void USkillEffect::EffectEnded()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,15 +132,52 @@ void USkillEffect::GetEffectTargetsByTargetType(const FSkillContext& context, TA
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESkillTargetType::Around:
|
case ESkillTargetType::AdjacentLeft:
|
||||||
{
|
{
|
||||||
//技能左侧的技能
|
//技能左侧的技能
|
||||||
TArray<USkill*> aroundSkills = context.SkillManager->GetSkillsAround(context.OwnerSkill);
|
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||||
for (auto skill: aroundSkills)
|
int32 index = allSkills.Find(OwnerSkill);
|
||||||
|
if ((index - 1) >= 0)
|
||||||
{
|
{
|
||||||
result.Add(skill);
|
result.Add(allSkills[index - 1]);
|
||||||
}
|
}
|
||||||
break;;
|
break;;
|
||||||
}
|
}
|
||||||
|
case ESkillTargetType::AdjacentRight:
|
||||||
|
{
|
||||||
|
//技能右侧的技能
|
||||||
|
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||||
|
int32 index = allSkills.Find(OwnerSkill);
|
||||||
|
if ((index + 1) < allSkills.Num())
|
||||||
|
{
|
||||||
|
result.Add(allSkills[index + 1]);
|
||||||
|
}
|
||||||
|
break;;
|
||||||
|
}
|
||||||
|
case ESkillTargetType::AllLeft:
|
||||||
|
{
|
||||||
|
//所有当前技能左侧的技能
|
||||||
|
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||||
|
int32 index = allSkills.Find(OwnerSkill);
|
||||||
|
for (int i = 0; i < index; ++i)
|
||||||
|
{
|
||||||
|
if (allSkills[i]->GetOwner() == OwnerSkill->GetOwner())
|
||||||
|
result.Add(allSkills[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ESkillTargetType::AllRight:
|
||||||
|
{
|
||||||
|
//所有当前技能右侧的技能
|
||||||
|
TArray< USkill*> allSkills = context.SkillManager->GetAllSkills();
|
||||||
|
int32 index = allSkills.Find(OwnerSkill);
|
||||||
|
for (int i = index + 1; i < allSkills.Num(); ++i)
|
||||||
|
{
|
||||||
|
if (allSkills[i]->GetOwner() == OwnerSkill->GetOwner())
|
||||||
|
result.Add(allSkills[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,12 @@ class USkillEffect : public UObject
|
|||||||
public:
|
public:
|
||||||
void InitSkillEffect(class USkill* skill, FSkillEffectData data);
|
void InitSkillEffect(class USkill* skill, FSkillEffectData data);
|
||||||
virtual void Execute(const FSkillContext& context) ;
|
virtual void Execute(const FSkillContext& context) ;
|
||||||
virtual void EffectEnded(const FSkillContext& context);
|
virtual void EffectEnded();
|
||||||
TArray<UObject*> GetApplyTargets(const FSkillContext& context);
|
TArray<UObject*> GetApplyTargets(const FSkillContext& context);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
virtual FString GetSkillEffectDes();
|
virtual FString GetSkillEffectDes();
|
||||||
FSkillEffectData& GetEffectData()
|
|
||||||
{
|
|
||||||
return effectData;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
void GetEffectTargetsByTargetType(const FSkillContext& context, TArray<UObject*>& result);
|
void GetEffectTargetsByTargetType(const FSkillContext& context, TArray<UObject*>& result);
|
||||||
protected:
|
protected:
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "SkillEffect_DamageReduce.h"
|
|
||||||
|
|
||||||
#include "ProjectFish/Skill/Skill.h"
|
|
||||||
|
|
||||||
void USkillEffect_DamageReduce::Execute(const FSkillContext& context)
|
|
||||||
{
|
|
||||||
Super::Execute(context);
|
|
||||||
TArray<UObject*> targets = GetApplyTargets(context);
|
|
||||||
for (auto target: targets)
|
|
||||||
{
|
|
||||||
if (!target->GetClass()->IsChildOf(APawnWithSkill::StaticClass()))
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a pawn "), *(OwnerSkill->GetSkillName()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//设置目标护盾值
|
|
||||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(target);
|
|
||||||
OwnerPawn->SetDamageReduce( (int32)(effectData.EffectValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void USkillEffect_DamageReduce::EffectEnded(const FSkillContext& context)
|
|
||||||
{
|
|
||||||
Super::EffectEnded(context);
|
|
||||||
TArray<UObject*> targets = GetApplyTargets(context);
|
|
||||||
for (auto target: targets)
|
|
||||||
{
|
|
||||||
if (!target->GetClass()->IsChildOf(APawnWithSkill::StaticClass()))
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a pawn "), *(OwnerSkill->GetSkillName()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//恢复目标护盾值
|
|
||||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(target);
|
|
||||||
OwnerPawn->SetDamageReduce(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FString USkillEffect_DamageReduce::GetSkillEffectDes()
|
|
||||||
{
|
|
||||||
return FString::Printf(TEXT("减少目标受到的伤害 %d点"), (int32)(effectData.EffectValue));
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "ProjectFish/Skill/SkillEffect.h"
|
|
||||||
#include "SkillEffect_DamageReduce.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class PROJECTFISH_API USkillEffect_DamageReduce : public USkillEffect
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
void Execute(const FSkillContext& context) override;
|
|
||||||
void EffectEnded(const FSkillContext& context) override;
|
|
||||||
FString GetSkillEffectDes() override;
|
|
||||||
};
|
|
@ -1,38 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "SkillEffect_EnhanceFishRod.h"
|
|
||||||
|
|
||||||
#include "ProjectFish/Components/FishingRodComponent.h"
|
|
||||||
#include "ProjectFish/Skill/Skill.h"
|
|
||||||
|
|
||||||
void USkillEffect_EnhanceFishRod::Execute(const FSkillContext& context)
|
|
||||||
{
|
|
||||||
Super::Execute(context);
|
|
||||||
TArray<UObject*> targets = GetApplyTargets(context);
|
|
||||||
for (auto target: targets)
|
|
||||||
{
|
|
||||||
if (!target->GetClass()->IsChildOf(APawnWithSkill::StaticClass()))
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a pawn with fish rod"), *(OwnerSkill->GetSkillName()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//修改技能的冷却时间
|
|
||||||
APawnWithSkill* OwnerPawn = Cast<APawnWithSkill>(target);
|
|
||||||
if (OwnerPawn->GetComponentByClass(UFishingRodComponent::StaticClass()) != NULL)
|
|
||||||
{
|
|
||||||
UFishingRodComponent* rod = Cast<UFishingRodComponent>(OwnerPawn->GetComponentByClass(UFishingRodComponent::StaticClass()));
|
|
||||||
rod->AddFishRodDamage( (int32)(effectData.EffectValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FString USkillEffect_EnhanceFishRod::GetSkillEffectDes()
|
|
||||||
{
|
|
||||||
return FString::Printf(TEXT("使鱼竿的伤害增加 %d点"), (int32)(effectData.EffectValue));
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "ProjectFish/Skill/SkillEffect.h"
|
|
||||||
#include "SkillEffect_EnhanceFishRod.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class PROJECTFISH_API USkillEffect_EnhanceFishRod : public USkillEffect
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
void Execute(const FSkillContext& context) override;
|
|
||||||
FString GetSkillEffectDes() override;
|
|
||||||
};
|
|
@ -1,32 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "SkillEffect_EnhanceSkill.h"
|
|
||||||
#include "ProjectFish/Skill/Skill.h"
|
|
||||||
|
|
||||||
void USkillEffect_EnhanceSkill::Execute(const FSkillContext& context)
|
|
||||||
{
|
|
||||||
Super::Execute(context);
|
|
||||||
TArray<UObject*> targets = GetApplyTargets(context);
|
|
||||||
for (auto target: targets)
|
|
||||||
{
|
|
||||||
if (!target->GetClass()->IsChildOf(USkill::StaticClass()))
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Error, TEXT("skill %s apply target is not a skill"), *(OwnerSkill->GetSkillName()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//修改技能的冷却时间
|
|
||||||
USkill* targetSkill = Cast<USkill>(target);
|
|
||||||
for (auto skilleffect: targetSkill->GetAllSkillEffects())
|
|
||||||
{
|
|
||||||
skilleffect->GetEffectData().EffectValue +=(int32)(effectData.EffectValue)*(skilleffect->GetEffectData().EffectValue/FMath::Abs(skilleffect->GetEffectData().EffectValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FString USkillEffect_EnhanceSkill::GetSkillEffectDes()
|
|
||||||
{
|
|
||||||
return FString::Printf(TEXT("增强目标技能 %d点"), (int32)(effectData.EffectValue));
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "ProjectFish/Skill/SkillEffect.h"
|
|
||||||
#include "SkillEffect_EnhanceSkill.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class PROJECTFISH_API USkillEffect_EnhanceSkill : public USkillEffect
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
void Execute(const FSkillContext& context) override;
|
|
||||||
FString GetSkillEffectDes() override;
|
|
||||||
};
|
|
@ -36,9 +36,9 @@ void USkillEffect_ModifySpeed::Execute(const FSkillContext& context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USkillEffect_ModifySpeed::EffectEnded(const FSkillContext& context)
|
void USkillEffect_ModifySpeed::EffectEnded()
|
||||||
{
|
{
|
||||||
Super::EffectEnded(context);
|
Super::EffectEnded();
|
||||||
//GetWorld()->GetTimerManager().ClearTimer(TimerHandle);
|
//GetWorld()->GetTimerManager().ClearTimer(TimerHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class PROJECTFISH_API USkillEffect_ModifySpeed : public USkillEffect
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
void Execute(const FSkillContext& context) override;
|
void Execute(const FSkillContext& context) override;
|
||||||
void EffectEnded(const FSkillContext& context) override;
|
void EffectEnded() override;
|
||||||
FString GetSkillEffectDes() override;
|
FString GetSkillEffectDes() override;
|
||||||
private:
|
private:
|
||||||
FTimerHandle TimerHandle;
|
FTimerHandle TimerHandle;
|
||||||
|
@ -22,120 +22,20 @@ TStatId USkillManager::GetStatId() const
|
|||||||
return Super::GetStatID();
|
return Super::GetStatID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void USkillManager::AddPawn(class APawnWithSkill* Pawn, FIntPoint BagSize)
|
void USkillManager::InitPawns(TArray<APawnWithSkill*> Pawns)
|
||||||
{
|
{
|
||||||
PawnInfo.Add(Pawn, BagSize);
|
this->SkillPawns = Pawns;
|
||||||
TMap<FIntPoint, int32> states;
|
|
||||||
for (int y = 0; y < BagSize.Y; y++)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < BagSize.X; x++)
|
|
||||||
{
|
|
||||||
states.Add(FIntPoint(x, y), -1);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PawnBagState.Add(Pawn, states);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void USkillManager::InitPawns(TArray<APawnWithSkill*> Pawns)
|
USkill* USkillManager::CreateSkill(FSkillData data, APawnWithSkill* Pawn)
|
||||||
// {
|
|
||||||
// this->SkillPawns = Pawns;
|
|
||||||
// }
|
|
||||||
|
|
||||||
USkill* USkillManager::AddSkill(FSkillData data, APawnWithSkill* Pawn, FIntPoint& BagPos)
|
|
||||||
{
|
{
|
||||||
TMap<FIntPoint, int32>* states = PawnBagState.Find(Pawn);
|
|
||||||
FIntPoint BagSize = *PawnInfo.Find(Pawn);
|
|
||||||
bool bAddAble = true;
|
|
||||||
for (int y = 0; y < BagSize.Y; y++)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < BagSize.X; x++)
|
|
||||||
{
|
|
||||||
bAddAble = true;
|
|
||||||
for (int skillX = 0; skillX < data.SkillWeight.X; skillX++)
|
|
||||||
{
|
|
||||||
for (int skillY = 0; skillY < data.SkillWeight.Y; skillY++)
|
|
||||||
{
|
|
||||||
if (states->Find(FIntPoint(x, y) + FIntPoint(skillX, skillY)) == nullptr
|
|
||||||
|| *states->Find(FIntPoint(x, y) + FIntPoint(skillX, skillY)) != -1)
|
|
||||||
{
|
|
||||||
bAddAble = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//满足条件
|
|
||||||
if (bAddAble)
|
|
||||||
{
|
|
||||||
BagPos = FIntPoint(x, y);
|
|
||||||
USkill* skill = NewObject<USkill>(this);
|
USkill* skill = NewObject<USkill>(this);
|
||||||
skill->InitSkill(Pawn, this, data, BagPos);
|
skill->InitSkill(Pawn, this, data);
|
||||||
Skills.Add(skill);
|
Skills.Add(skill);
|
||||||
//设置占用状态
|
|
||||||
for (int xTemp = 0; xTemp < data.SkillWeight.X; xTemp++)
|
|
||||||
{
|
|
||||||
for (int yTemp = 0; yTemp < data.SkillWeight.Y; yTemp++)
|
|
||||||
{
|
|
||||||
states->Add(FIntPoint(xTemp, yTemp) + FIntPoint(x, y), GetSkillIndex(skill));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return skill;
|
return skill;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void USkillManager::OnAllSkillAdded()
|
|
||||||
{
|
|
||||||
//所有技能初始化后,初始化技能的触发器
|
|
||||||
for (auto Skill : Skills)
|
|
||||||
{
|
|
||||||
Skill->InitSkillTrigger();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class USkill* USkillManager::GetSkillByTag(FGameplayTag Tag)
|
|
||||||
{
|
|
||||||
for (auto Skill : Skills)
|
|
||||||
{
|
|
||||||
if (Skill->GetSkillData().SkillTag == Tag)
|
|
||||||
return Skill;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 USkillManager::GetSkillIndex(USkill* Skill)
|
|
||||||
{
|
|
||||||
return Skills.Find(Skill);
|
|
||||||
}
|
|
||||||
|
|
||||||
TArray<USkill*> USkillManager::GetSkillsAround(USkill* TargetSkill)
|
|
||||||
{
|
|
||||||
TArray<USkill*> aroundSkills;
|
|
||||||
TMap<FIntPoint, int32> *BagStates = PawnBagState.Find(TargetSkill->GetOwner());
|
|
||||||
FIntPoint BagPos = TargetSkill->GetBagPos();
|
|
||||||
FIntPoint BagSize = *PawnInfo.Find(TargetSkill->GetOwner());
|
|
||||||
FSkillData data = TargetSkill->GetSkillData();
|
|
||||||
int beginX = FMath::Max(0, BagPos.X- 1);
|
|
||||||
int endX = FMath::Min(BagSize.X - 1, BagPos.X + 1);
|
|
||||||
int beginY = FMath::Max(0, BagPos.Y - 1);
|
|
||||||
int endY = FMath::Min(BagSize.Y - 1, BagPos.Y + 1);
|
|
||||||
for (int x = beginX; x <= endX; x++)
|
|
||||||
{
|
|
||||||
for (int y = beginY; y <= endY; y++)
|
|
||||||
{
|
|
||||||
|
|
||||||
int32 skillIndex = *BagStates->Find(FIntPoint(x, y));
|
|
||||||
if (skillIndex != -1 && skillIndex != GetSkillIndex(TargetSkill) && !aroundSkills.Contains(Skills[skillIndex]))
|
|
||||||
{
|
|
||||||
aroundSkills.Add(Skills[skillIndex]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return aroundSkills;
|
|
||||||
}
|
|
||||||
|
|
||||||
void USkillManager::RemoveSkill(USkill* Skill)
|
void USkillManager::RemoveSkill(USkill* Skill)
|
||||||
{
|
{
|
||||||
@ -144,23 +44,7 @@ void USkillManager::RemoveSkill(USkill* Skill)
|
|||||||
|
|
||||||
TArray<APawnWithSkill*> USkillManager::GetAllPawns()
|
TArray<APawnWithSkill*> USkillManager::GetAllPawns()
|
||||||
{
|
{
|
||||||
TArray<APawnWithSkill*> Pawns;
|
return SkillPawns;
|
||||||
for (auto info: PawnInfo)
|
|
||||||
{
|
|
||||||
Pawns.Add(info.Key);
|
|
||||||
}
|
|
||||||
return Pawns;
|
|
||||||
}
|
|
||||||
|
|
||||||
TArray<class USkill*> USkillManager::GetSkillsByOwner(APawnWithSkill* Pawn)
|
|
||||||
{
|
|
||||||
TArray<class USkill*> skills;
|
|
||||||
for (auto Skill : Skills)
|
|
||||||
{
|
|
||||||
if (Skill->GetOwner() == Pawn)
|
|
||||||
skills.Add(Skill);
|
|
||||||
}
|
|
||||||
return skills;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TArray< USkill*> USkillManager::GetAllSkills()
|
TArray< USkill*> USkillManager::GetAllSkills()
|
||||||
|
@ -20,23 +20,11 @@ public:
|
|||||||
virtual bool IsTickable() const override;
|
virtual bool IsTickable() const override;
|
||||||
virtual TStatId GetStatId() const override;
|
virtual TStatId GetStatId() const override;
|
||||||
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void AddPawn(class APawnWithSkill* Pawn, FIntPoint BagSize);
|
void InitPawns(TArray<APawnWithSkill*> Pawns);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
USkill* AddSkill(FSkillData data, APawnWithSkill* Pawn, FIntPoint& BagPos);
|
USkill* CreateSkill(FSkillData data, APawnWithSkill* Pawn);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
|
||||||
void OnAllSkillAdded();
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
|
||||||
class USkill* GetSkillByTag(FGameplayTag Tag);
|
|
||||||
|
|
||||||
int32 GetSkillIndex(USkill* Skill);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
|
||||||
TArray<USkill*> GetSkillsAround(USkill *TargetSkill);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void RemoveSkill(class USkill *Skill);
|
void RemoveSkill(class USkill *Skill);
|
||||||
@ -44,20 +32,13 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
TArray<APawnWithSkill*> GetAllPawns();
|
TArray<APawnWithSkill*> GetAllPawns();
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintCallable)
|
||||||
TArray<class USkill*> GetSkillsByOwner(APawnWithSkill* Pawn);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
|
||||||
TArray<class USkill*> GetAllSkills();
|
TArray<class USkill*> GetAllSkills();
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
TArray<class USkill *> Skills;
|
TArray<class USkill *> Skills;
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
TMap<class APawnWithSkill*, FIntPoint> PawnInfo;
|
TArray<class APawnWithSkill *> SkillPawns;
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
bool bGameEnd = false;
|
bool bGameEnd = false;
|
||||||
|
|
||||||
TMap<APawnWithSkill*, TMap<FIntPoint, int32>> PawnBagState;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "SkillTrigger.h"
|
|
||||||
|
|
||||||
#include "Skill.h"
|
|
||||||
|
|
||||||
|
|
||||||
void USkillTrigger::Init_Implementation(FSkillContext context)
|
|
||||||
{
|
|
||||||
SkillContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
void USkillTrigger::OnTrigger()
|
|
||||||
{
|
|
||||||
SkillContext.OwnerSkill->ExecuteSkill();
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "ProjectFish/Definations.h"
|
|
||||||
#include "UObject/Object.h"
|
|
||||||
#include "SkillTrigger.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS(Blueprintable)
|
|
||||||
class PROJECTFISH_API USkillTrigger : public UObject
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
UFUNCTION(BlueprintNativeEvent)
|
|
||||||
void Init(FSkillContext context);
|
|
||||||
UFUNCTION(BlueprintCallable)
|
|
||||||
void OnTrigger();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
UPROPERTY(BlueprintReadOnly)
|
|
||||||
FSkillContext SkillContext;
|
|
||||||
};
|
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user