57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
// 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)
|
|
{
|
|
if (enduranceOffset < 0)
|
|
{
|
|
//受到伤害
|
|
OnReceiveDamage.Broadcast();
|
|
//受到的伤害最低为1点
|
|
enduranceOffset = FMath::Min(-1, enduranceOffset + DamageReduce);
|
|
}
|
|
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
|
|
void APawnWithSkill::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
CurrentEndurance += MaxEndurance;
|
|
CurrentTenacity += MaxTenacity;
|
|
}
|
|
|
|
// 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);
|
|
}
|
|
|