Compare commits

..

2 Commits

Author SHA1 Message Date
baz 1bc85f970a Bind EXP Bar value 2024-08-20 23:32:48 +01:00
baz 45b2120cb5 Add Leveling to EXPComponent 2024-08-20 23:32:24 +01:00
3 changed files with 30 additions and 4 deletions

BIN
Content/Widgets/HUD/BP_HUDWidget.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -15,17 +15,35 @@ UEXPComponent::UEXPComponent()
void UEXPComponent::IncrementEXP(int value)
{
// TODO: I should be updating the level here
int oldEXP = CurrentEXP;
int oldLevel = CurrentLevel;
CurrentEXP += value;
OnEXPGained.ExecuteIfBound(value);
CurrentLevel = FMath::Floor(CurrentEXP / 100.0f);
if (CurrentLevel != oldLevel)
{
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
}
}
void UEXPComponent::SetCurrentEXP(int value)
{
int oldEXP = CurrentEXP;
int oldLevel = CurrentLevel;
// TODO: I should be updating the level here
CurrentEXP = value;
OnEXPGained.ExecuteIfBound(value);
CurrentLevel = FMath::Floor(CurrentEXP / 100.0f);
if (CurrentLevel != oldLevel)
{
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
}
}
int UEXPComponent::GetCurrentEXP()
@ -46,6 +64,11 @@ void UEXPComponent::Reset()
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
}
float UEXPComponent::GetCurrentLevelPercent()
{
return (CurrentEXP % 100) / 100.0f;
}
// Called when the game starts
void UEXPComponent::BeginPlay()
{

View File

@ -42,6 +42,9 @@ public:
UFUNCTION(BlueprintCallable)
void Reset();
UFUNCTION(BlueprintCallable, BlueprintPure)
float GetCurrentLevelPercent();
protected:
// Called when the game starts
virtual void BeginPlay() override;