57 lines
1.3 KiB
C++
Raw Normal View History

2025-06-18 10:07:14 +08:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "PawnWithSkill.h"
// Sets default values
APawnWithSkill::APawnWithSkill()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
void APawnWithSkill::ApplyyEndurance_Implementation(float enduranceOffset)
{
2025-07-22 18:06:10 +08:00
if (enduranceOffset < 0)
{
//受到伤害
OnReceiveDamage.Broadcast();
//受到的伤害最低为1点
enduranceOffset = FMath::Min(-1, enduranceOffset + DamageReduce);
}
2025-06-18 10:07:14 +08:00
CurrentEndurance += enduranceOffset;;
2025-07-22 18:06:10 +08:00
2025-06-18 10:07:14 +08:00
}
2025-07-15 16:52:32 +08:00
void APawnWithSkill::ApplyyTenacity_Implementation(float tenacityOffset)
{
CurrentTenacity += tenacityOffset;
}
2025-07-22 18:06:10 +08:00
void APawnWithSkill::SetDamageReduce(int32 damageReduce)
{
DamageReduce = damageReduce;
}
2025-06-18 10:07:14 +08:00
// Called when the game starts or when spawned
void APawnWithSkill::BeginPlay()
{
Super::BeginPlay();
CurrentEndurance += MaxEndurance;
CurrentTenacity += MaxTenacity;
2025-06-18 10:07:14 +08:00
}
// Called every frame
void APawnWithSkill::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void APawnWithSkill::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}