Compare commits
No commits in common. "ba0243bd6516c12e50376bebb20a4bd8ec80d6dd" and "7396d50db91677d0ef282d769e7ce18d280dd937" have entirely different histories.
ba0243bd65
...
7396d50db9
BIN
Content/Enemy/DemolitionWorker/C_DemolitionWorker.uasset (Stored with Git LFS)
BIN
Content/Enemy/DemolitionWorker/C_DemolitionWorker.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Worker/C_Worker.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/C_Worker.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/UI/EnemyHealthbar/EnemyHealthbar.uasset (Stored with Git LFS)
BIN
Content/UI/EnemyHealthbar/EnemyHealthbar.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/UI/EnemyHealthbar/M_WhitePixel.uasset (Stored with Git LFS)
BIN
Content/UI/EnemyHealthbar/M_WhitePixel.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/UI/EnemyHealthbar/T_WhitePixel.uasset (Stored with Git LFS)
BIN
Content/UI/EnemyHealthbar/T_WhitePixel.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -8,7 +8,6 @@
|
||||||
#include "BehaviorTree/BehaviorTree.h"
|
#include "BehaviorTree/BehaviorTree.h"
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
#include "BehaviorTree/BlackboardData.h"
|
#include "BehaviorTree/BlackboardData.h"
|
||||||
#include "UI/EnemyHealthbarUserWidget.h"
|
|
||||||
|
|
||||||
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
||||||
|
|
||||||
|
@ -22,12 +21,6 @@ AEnemyCharacter::AEnemyCharacter(const FObjectInitializer& ObjectInitializer) :
|
||||||
GetHealthComponent()->OnDeath.BindUFunction(this, "OnDeath");
|
GetHealthComponent()->OnDeath.BindUFunction(this, "OnDeath");
|
||||||
GetHealthComponent()->SetMaxHealth(100.0f);
|
GetHealthComponent()->SetMaxHealth(100.0f);
|
||||||
|
|
||||||
HealthbarWidgetComponent = CreateDefaultSubobject<UWidgetComponent>(TEXT("Healthbar"));
|
|
||||||
HealthbarWidgetComponent->SetupAttachment(RootComponent);
|
|
||||||
HealthbarWidgetComponent->SetRelativeLocation(FVector(0,0,90));
|
|
||||||
HealthbarWidgetComponent->SetTwoSided(true);
|
|
||||||
HealthbarWidgetComponent->SetBackgroundColor(FLinearColor(1,1,1,0));
|
|
||||||
|
|
||||||
this->Tags.Add(FName("Enemy"));
|
this->Tags.Add(FName("Enemy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +63,6 @@ void AEnemyCharacter::BeginPlay()
|
||||||
AEnemyAIController* controller = Cast<AEnemyAIController>(GetController());
|
AEnemyAIController* controller = Cast<AEnemyAIController>(GetController());
|
||||||
controller->GetBlackboardComponent()->SetValueAsFloat("CurrentHealth", GetHealthComponent()->GetCurrentHealth());
|
controller->GetBlackboardComponent()->SetValueAsFloat("CurrentHealth", GetHealthComponent()->GetCurrentHealth());
|
||||||
GetHealthComponent()->OnDamaged.BindUFunction(this, "OnDamaged");
|
GetHealthComponent()->OnDamaged.BindUFunction(this, "OnDamaged");
|
||||||
|
|
||||||
if (HealthbarWidgetComponent->GetWidget())
|
|
||||||
{
|
|
||||||
UEnemyHealthbarUserWidget* healthbar = Cast<UEnemyHealthbarUserWidget>(HealthbarWidgetComponent->GetWidget());
|
|
||||||
healthbar->BindOwner(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::PlayOnFireAnimations()
|
void AEnemyCharacter::PlayOnFireAnimations()
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "PatrolRoute.h"
|
#include "PatrolRoute.h"
|
||||||
#include "BehaviorTree/BehaviorTreeComponent.h"
|
#include "BehaviorTree/BehaviorTreeComponent.h"
|
||||||
#include "RandomWeaponParameters.h"
|
#include "RandomWeaponParameters.h"
|
||||||
#include "Components/WidgetComponent.h"
|
|
||||||
#include "EnemyCharacter.generated.h"
|
#include "EnemyCharacter.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,9 +28,6 @@ public:
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float DefendRadius = 500.0f;
|
float DefendRadius = 500.0f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
|
||||||
UWidgetComponent* HealthbarWidgetComponent;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||||
UBehaviorTree* BehaviourTree;
|
UBehaviorTree* BehaviourTree;
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "../UI/EnemyHealthbarUserWidget.h"
|
|
||||||
|
|
||||||
#include "Nakatomi/EnemyCharacter.h"
|
|
||||||
|
|
||||||
void UEnemyHealthbarUserWidget::BindOwner(AEnemyCharacter* NewOwner)
|
|
||||||
{
|
|
||||||
Owner = NewOwner;
|
|
||||||
|
|
||||||
if (Owner)
|
|
||||||
{
|
|
||||||
auto healthComponent = Owner->GetHealthComponent();
|
|
||||||
healthComponent->OnDamaged.BindUFunction(this, "UpdateHealthbar");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UEnemyHealthbarUserWidget::UpdateHealthbar()
|
|
||||||
{
|
|
||||||
if (Owner)
|
|
||||||
{
|
|
||||||
float percent = Owner->GetHealthComponent()->GetCurrentHealth() / Owner->GetHealthComponent()->GetMaxHealth();
|
|
||||||
Healthbar->SetPercent(percent);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "Blueprint/UserWidget.h"
|
|
||||||
#include "Components/ProgressBar.h"
|
|
||||||
#include "Nakatomi/EnemyCharacter.h"
|
|
||||||
#include "EnemyHealthbarUserWidget.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class NAKATOMI_API UEnemyHealthbarUserWidget : public UUserWidget
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
|
||||||
UProgressBar* Healthbar;
|
|
||||||
|
|
||||||
AEnemyCharacter* Owner;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void BindOwner(AEnemyCharacter* NewOwner);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void UpdateHealthbar();
|
|
||||||
};
|
|
Loading…
Reference in New Issue