添加减伤技能效果
This commit is contained in:
parent
25f8adc0a8
commit
aded160ce0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -18,7 +18,8 @@ enum class ESkillEffectType: uint8
|
||||
ModifySpeed UMETA(DisplayName = "速度修改", ToolTip = "使技能冷却进度倍率进展 持续指定时间"),
|
||||
SkillEnduranceRestore UMETA(DisplayName = "技能耐久度恢复", ToolTip = "使技能耐久度恢复"),
|
||||
EnhanceFishRod UMETA(DisplayName = "增强鱼竿", ToolTip = "使鱼竿上海增加"),
|
||||
EnhanceSkill UMETA(DisplayName = "增强技能", ToolTip = "增强指定的技能数值")
|
||||
EnhanceSkill UMETA(DisplayName = "增强技能", ToolTip = "增强指定的技能数值"),
|
||||
DamageReduce UMETA(DisplayName = "减伤", ToolTip = "减少所受的伤害"),
|
||||
};
|
||||
|
||||
//技能对象类型
|
||||
|
@ -13,7 +13,15 @@ APawnWithSkill::APawnWithSkill()
|
||||
|
||||
void APawnWithSkill::ApplyyEndurance_Implementation(float enduranceOffset)
|
||||
{
|
||||
if (enduranceOffset < 0)
|
||||
{
|
||||
//受到伤害
|
||||
OnReceiveDamage.Broadcast();
|
||||
//受到的伤害最低为1点
|
||||
enduranceOffset = FMath::Min(-1, enduranceOffset + DamageReduce);
|
||||
}
|
||||
CurrentEndurance += enduranceOffset;;
|
||||
|
||||
}
|
||||
|
||||
void APawnWithSkill::ApplyyTenacity_Implementation(float tenacityOffset)
|
||||
@ -21,6 +29,11 @@ void APawnWithSkill::ApplyyTenacity_Implementation(float tenacityOffset)
|
||||
CurrentTenacity += tenacityOffset;
|
||||
}
|
||||
|
||||
void APawnWithSkill::SetDamageReduce(int32 damageReduce)
|
||||
{
|
||||
DamageReduce = damageReduce;
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void APawnWithSkill::BeginPlay()
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "GameFramework/Pawn.h"
|
||||
#include "PawnWithSkill.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnReceiveDamage);
|
||||
UCLASS()
|
||||
class PROJECTFISH_API APawnWithSkill : public APawn
|
||||
{
|
||||
@ -18,6 +19,8 @@ public:
|
||||
void ApplyyEndurance(float enduranceOffset);
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
|
||||
void ApplyyTenacity(float tenacityOffset);
|
||||
|
||||
void SetDamageReduce(int32 damageReduce);
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
@ -32,6 +35,9 @@ public:
|
||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "当前耐久度"))
|
||||
float CurrentEndurance;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "减伤值"))
|
||||
float DamageReduce;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "最大耐久度"))
|
||||
float MaxEndurance;
|
||||
|
||||
@ -43,5 +49,8 @@ public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= Default, meta = (DisplayPriority = 0, ToolTip = "韧性归零时眩晕时长"))
|
||||
float TenacityStun_Time = 5;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnReceiveDamage OnReceiveDamage;
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "SkillTrigger.h"
|
||||
#include "SkillEffects/SkillEffect_Charge.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"
|
||||
@ -50,6 +51,9 @@ void USkill::InitSkill(APawnWithSkill* owner, USkillManager* skillManager, FSkil
|
||||
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)))
|
||||
@ -77,7 +81,7 @@ void USkill::InitSkillTrigger()
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("没有Trigger的被动技能,直接触发"));
|
||||
//UE_LOG(LogTemp, Warning, TEXT("没有Trigger的被动技能,直接触发"));
|
||||
ExecuteSkill();
|
||||
}
|
||||
}
|
||||
@ -100,9 +104,12 @@ void USkill::TickSkill(float deltaTime)
|
||||
}
|
||||
if (RemainingEndurance == 0)
|
||||
{
|
||||
FSkillContext context;
|
||||
context.OwnerSkill = this;
|
||||
context.SkillManager = SkillManager;
|
||||
for (auto Effect: SkillEffects)
|
||||
{
|
||||
Effect->EffectEnded();
|
||||
Effect->EffectEnded(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void USkillEffect::Execute(const FSkillContext& context)
|
||||
, *( GetSkillEffectDes()));
|
||||
}
|
||||
|
||||
void USkillEffect::EffectEnded()
|
||||
void USkillEffect::EffectEnded(const FSkillContext& context)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ class USkillEffect : public UObject
|
||||
public:
|
||||
void InitSkillEffect(class USkill* skill, FSkillEffectData data);
|
||||
virtual void Execute(const FSkillContext& context) ;
|
||||
virtual void EffectEnded();
|
||||
virtual void EffectEnded(const FSkillContext& context);
|
||||
TArray<UObject*> GetApplyTargets(const FSkillContext& context);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
|
@ -0,0 +1,49 @@
|
||||
// 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));
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
// 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;
|
||||
};
|
@ -36,9 +36,9 @@ void USkillEffect_ModifySpeed::Execute(const FSkillContext& context)
|
||||
}
|
||||
}
|
||||
|
||||
void USkillEffect_ModifySpeed::EffectEnded()
|
||||
void USkillEffect_ModifySpeed::EffectEnded(const FSkillContext& context)
|
||||
{
|
||||
Super::EffectEnded();
|
||||
Super::EffectEnded(context);
|
||||
//GetWorld()->GetTimerManager().ClearTimer(TimerHandle);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class PROJECTFISH_API USkillEffect_ModifySpeed : public USkillEffect
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
void Execute(const FSkillContext& context) override;
|
||||
void EffectEnded() override;
|
||||
void EffectEnded(const FSkillContext& context) override;
|
||||
FString GetSkillEffectDes() override;
|
||||
private:
|
||||
FTimerHandle TimerHandle;
|
||||
|
Loading…
x
Reference in New Issue
Block a user