Add Kill Counter
This commit is contained in:
parent
1bc85f970a
commit
2ad6b53ab3
BIN
Content/Widgets/HUD/BP_HUDWidget.uasset (Stored with Git LFS)
BIN
Content/Widgets/HUD/BP_HUDWidget.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include "EnemyCharacter.h"
|
#include "EnemyCharacter.h"
|
||||||
|
|
||||||
|
#include "VampireGameMode.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
AEnemyCharacter::AEnemyCharacter(const FObjectInitializer& ObjectInitializer)
|
AEnemyCharacter::AEnemyCharacter(const FObjectInitializer& ObjectInitializer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -39,5 +42,8 @@ void AEnemyCharacter::OnDeath()
|
||||||
|
|
||||||
GetWorld()->SpawnActor<AEXPPickup>(EXPPickupTemplate, GetActorLocation(), FRotator::ZeroRotator,
|
GetWorld()->SpawnActor<AEXPPickup>(EXPPickupTemplate, GetActorLocation(), FRotator::ZeroRotator,
|
||||||
actorSpawnParameters);
|
actorSpawnParameters);
|
||||||
|
|
||||||
|
AVampireGameMode* gamemode = Cast<AVampireGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
|
||||||
|
gamemode->IncrementEnemyDeathCount();
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,11 @@ void AVampireGameMode::BeginPlay()
|
||||||
GetWorldTimerManager().SetTimer(SpawnEnemyTimerDelegate, this, &AVampireGameMode::SpawnEnemy, 1.0f, true);
|
GetWorldTimerManager().SetTimer(SpawnEnemyTimerDelegate, this, &AVampireGameMode::SpawnEnemy, 1.0f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AVampireGameMode::GetEnemyDeathCount()
|
||||||
|
{
|
||||||
|
return EnemyDeathCount;
|
||||||
|
}
|
||||||
|
|
||||||
void AVampireGameMode::SpawnEnemy()
|
void AVampireGameMode::SpawnEnemy()
|
||||||
{
|
{
|
||||||
FVector TopLeft, TopLeftDir;
|
FVector TopLeft, TopLeftDir;
|
||||||
|
@ -68,3 +73,8 @@ void AVampireGameMode::SpawnEnemy()
|
||||||
Actor->SetActorLocation(SpawnLocation + Direction);
|
Actor->SetActorLocation(SpawnLocation + Direction);
|
||||||
Actor->SpawnDefaultController();
|
Actor->SpawnDefaultController();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AVampireGameMode::IncrementEnemyDeathCount()
|
||||||
|
{
|
||||||
|
EnemyDeathCount++;
|
||||||
|
}
|
||||||
|
|
|
@ -28,9 +28,20 @@ private:
|
||||||
|
|
||||||
FTimerHandle SpawnEnemyTimerDelegate;
|
FTimerHandle SpawnEnemyTimerDelegate;
|
||||||
|
|
||||||
|
int EnemyDeathCount = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||||
|
int GetEnemyDeathCount();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void IncrementEnemyDeathCount();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void SpawnEnemy();
|
void SpawnEnemy();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue