|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
#include <Kismet/GameplayStatics.h>
|
|
|
|
|
|
|
|
|
|
#include "HealthBar.h"
|
|
|
|
|
#include "MyGameState.h"
|
|
|
|
|
#include "MyPlayerController.h"
|
|
|
|
|
#include "MyPlayerState.h"
|
|
|
|
|
#include "MyProjectile.h"
|
|
|
|
@ -128,7 +129,7 @@ void ATrooper::Tick(float const DeltaTime) {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
void ATrooper::MoveTrooper(FVector const NewPos) {
|
|
|
|
|
void ATrooper::MoveTrooper_Implementation(FVector const NewPos) {
|
|
|
|
|
TargetLocation = NewPos;
|
|
|
|
|
bIsMoving = true;
|
|
|
|
|
ActionPoints -= (NewPos - CurrentLocation).Size() * MoveCost;
|
|
|
|
@ -158,7 +159,7 @@ void ATrooper::GetLifetimeReplicatedProps(
|
|
|
|
|
DOREPLIFETIME(ATrooper, CurrentAbilityDestination);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8 ATrooper::GetPlayerIndex() const {
|
|
|
|
|
int8 ATrooper::GetPlayerIndex() const {
|
|
|
|
|
return PlayerIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -246,17 +247,18 @@ UAbility *ATrooper::GetAbility(int AbilityIndex) const {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ATrooper::TakeDamage(float Damage) {
|
|
|
|
|
if (bIsTakingDamage) {
|
|
|
|
|
return false;
|
|
|
|
|
void ATrooper::TakeDamage_Implementation(float Damage) {
|
|
|
|
|
if (bIsTakingDamage || bIsDead) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
HitPoints = FMath::Max<float>(0, HitPoints - Damage);
|
|
|
|
|
if (HitPoints == 0) {
|
|
|
|
|
bIsDead = true;
|
|
|
|
|
return true;
|
|
|
|
|
SetLifeSpan(DyingAnimationDuration);
|
|
|
|
|
GetWorld()->GetGameState<AMyGameState>()->DecreaseLivingTroopers(PlayerIndex);
|
|
|
|
|
} else {
|
|
|
|
|
bIsTakingDamage = true;
|
|
|
|
|
}
|
|
|
|
|
bIsTakingDamage = true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSubclassOf<AMyProjectile> ATrooper::GetProjectileClass(
|
|
|
|
@ -312,7 +314,7 @@ int ATrooper::GetAnimationValue() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATrooper::Attack(int AbilityIndex, FVector ToLocation) {
|
|
|
|
|
void ATrooper::Attack_Implementation(int AbilityIndex, FVector ToLocation) {
|
|
|
|
|
bIsAttacking = true;
|
|
|
|
|
bIsWaitingForFire = true;
|
|
|
|
|
ActionPoints -= GetAbility(AbilityIndex)->ActionCost;
|
|
|
|
|