Compare commits
5 Commits
3b2301b270
...
4386f0e383
Author | SHA1 | Date |
---|---|---|
baz | 4386f0e383 | |
baz | 0c90ade615 | |
baz | 6106a2dae6 | |
baz | dd8cc06e33 | |
baz | 0bdda47b8b |
BIN
Content/Pickups/EXP/BP_BlueEXPPickup.uasset (Stored with Git LFS)
BIN
Content/Pickups/EXP/BP_BlueEXPPickup.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Player/BP_PlayerController.uasset (Stored with Git LFS)
BIN
Content/Player/BP_PlayerController.uasset (Stored with Git LFS)
Binary file not shown.
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.
|
@ -19,13 +19,13 @@ void UEXPComponent::IncrementEXP(int value)
|
|||
int oldLevel = CurrentLevel;
|
||||
|
||||
CurrentEXP += value;
|
||||
OnEXPGained.ExecuteIfBound(value);
|
||||
OnEXPGained.Broadcast(CurrentEXP, GetCurrentLevelPercent());
|
||||
|
||||
CurrentLevel = FMath::Floor(CurrentEXP / 100.0f);
|
||||
|
||||
if (CurrentLevel != oldLevel)
|
||||
{
|
||||
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
|
||||
OnEXPLevelUp.Broadcast(CurrentLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ void UEXPComponent::SetCurrentEXP(int value)
|
|||
|
||||
// TODO: I should be updating the level here
|
||||
CurrentEXP = value;
|
||||
OnEXPGained.ExecuteIfBound(value);
|
||||
OnEXPGained.Broadcast(CurrentEXP, GetCurrentLevelPercent());
|
||||
|
||||
CurrentLevel = FMath::Floor(CurrentEXP / 100.0f);
|
||||
|
||||
if (CurrentLevel != oldLevel)
|
||||
{
|
||||
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
|
||||
OnEXPLevelUp.Broadcast(CurrentLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ void UEXPComponent::Reset()
|
|||
{
|
||||
CurrentEXP = 0;
|
||||
CurrentLevel = 0;
|
||||
OnEXPGained.ExecuteIfBound(CurrentEXP);
|
||||
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
|
||||
OnEXPGained.Broadcast(CurrentEXP, GetCurrentLevelPercent());
|
||||
OnEXPLevelUp.Broadcast(CurrentLevel);
|
||||
}
|
||||
|
||||
float UEXPComponent::GetCurrentLevelPercent()
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include "Components/ActorComponent.h"
|
||||
#include "EXPComponent.generated.h"
|
||||
|
||||
DECLARE_DELEGATE_OneParam(FOnEXPGainedDelegate, int)
|
||||
DECLARE_DELEGATE_OneParam(FOnEXPLevelUpDelegate, int)
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnEXPGainedDelegate, int, exp, float, currentLevelPercent);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEXPLevelUpDelegate, int, level);
|
||||
|
||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||
class VAMPIRES_API UEXPComponent : public UActorComponent
|
||||
|
@ -15,7 +15,10 @@ class VAMPIRES_API UEXPComponent : public UActorComponent
|
|||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category="EXP")
|
||||
FOnEXPGainedDelegate OnEXPGained;
|
||||
UPROPERTY(BlueprintAssignable, Category="EXP")
|
||||
FOnEXPLevelUpDelegate OnEXPLevelUp;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -54,16 +54,6 @@ APlayerCharacter::APlayerCharacter()
|
|||
void APlayerCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (PlayerHUD)
|
||||
{
|
||||
currentPlayerHUD = UUserWidget::CreateWidgetInstance(*GetWorld(), PlayerHUD, FName("Player HUD"));
|
||||
|
||||
if (currentPlayerHUD)
|
||||
{
|
||||
currentPlayerHUD->AddToViewport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
|
|
|
@ -48,17 +48,12 @@ public:
|
|||
|
||||
FVector2D PreviousMovementDirection = FVector2d(1.0f, 0.0f);
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSubclassOf<UUserWidget> PlayerHUD = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UWidgetComponent* HealthBarWidgetComponent;
|
||||
|
||||
private:
|
||||
FTimerHandle GarlicTimerHandle;
|
||||
|
||||
UUserWidget* currentPlayerHUD = nullptr;
|
||||
|
||||
public:
|
||||
APlayerCharacter();
|
||||
|
||||
|
|
|
@ -3,3 +3,36 @@
|
|||
|
||||
#include "VampirePlayerController.h"
|
||||
|
||||
#include "EXPComponent.h"
|
||||
#include "HealthComponent.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "Widgets/HUDWidget.h"
|
||||
|
||||
void AVampirePlayerController::OnPossess(APawn* aPawn)
|
||||
{
|
||||
Super::OnPossess(aPawn);
|
||||
|
||||
if (PlayerHUD)
|
||||
{
|
||||
currentPlayerHUD = CreateWidget<UHUDWidget, AVampirePlayerController*>(this, PlayerHUD.Get());
|
||||
|
||||
if (UEXPComponent* expComponent = aPawn->GetComponentByClass<UEXPComponent>())
|
||||
{
|
||||
expComponent->OnEXPGained.AddUniqueDynamic(this, &AVampirePlayerController::UpdatePlayerEXPHUD);
|
||||
UpdatePlayerEXPHUD(expComponent->GetCurrentEXP(), expComponent->GetCurrentLevelPercent());
|
||||
}
|
||||
|
||||
if (currentPlayerHUD)
|
||||
{
|
||||
currentPlayerHUD->AddToViewport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AVampirePlayerController::UpdatePlayerEXPHUD(int exp, float currentLevelPercent)
|
||||
{
|
||||
if (currentPlayerHUD)
|
||||
{
|
||||
currentPlayerHUD->UpdateEXPBar(currentLevelPercent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,27 @@
|
|||
#include "GameFramework/PlayerController.h"
|
||||
#include "VampirePlayerController.generated.h"
|
||||
|
||||
class UHUDWidget;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
UCLASS(Abstract)
|
||||
class VAMPIRES_API AVampirePlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TSubclassOf<UHUDWidget> PlayerHUD = nullptr;
|
||||
|
||||
private:
|
||||
|
||||
TObjectPtr<UHUDWidget> currentPlayerHUD = nullptr;
|
||||
|
||||
protected:
|
||||
virtual void OnPossess(APawn* aPawn) override;
|
||||
|
||||
UFUNCTION()
|
||||
void UpdatePlayerEXPHUD(int exp, float currentLevelPercent);
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ void AWeapon::BeginPlay()
|
|||
|
||||
if (expcomponent)
|
||||
{
|
||||
expcomponent->OnEXPLevelUp.BindUObject(this, &AWeapon::UpgradeWeapon);
|
||||
expcomponent->OnEXPLevelUp.AddUniqueDynamic(this, &AWeapon::UpgradeWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,3 +3,21 @@
|
|||
|
||||
#include "HUDWidget.h"
|
||||
|
||||
#include "Components/ProgressBar.h"
|
||||
|
||||
void UHUDWidget::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void UHUDWidget::UpdateEXPBar(float currentLevelPercent)
|
||||
{
|
||||
EXPbar->SetPercent(currentLevelPercent);
|
||||
}
|
||||
|
||||
void UHUDWidget::UpdateLevelBlock()
|
||||
{
|
||||
}
|
||||
|
||||
void UHUDWidget::UpdateTimerBlock()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ UCLASS()
|
|||
class VAMPIRES_API UHUDWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
|
@ -26,5 +26,16 @@ public:
|
|||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UTextBlock* TimerBLock;
|
||||
|
||||
void Init();
|
||||
|
||||
UFUNCTION()
|
||||
void UpdateEXPBar(float currentLevelPercent);
|
||||
|
||||
UFUNCTION()
|
||||
void UpdateLevelBlock();
|
||||
|
||||
UFUNCTION()
|
||||
void UpdateTimerBlock();
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue