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