Project02/ProjectFish/Source/ProjectFish/Skill/SkillEffects/SkillEffect_EnhanceFishRod.cpp

39 lines
1.1 KiB
C++

// 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));
}