[박치영] 포션 UI 기능 추가
parent
1bc4df3e52
commit
29d650d432
Binary file not shown.
Binary file not shown.
|
|
@ -9,7 +9,7 @@ ABaseConsumable::ABaseConsumable()
|
||||||
{
|
{
|
||||||
//초기화 구문
|
//초기화 구문
|
||||||
MaxNumberOfUses = 3;
|
MaxNumberOfUses = 3;
|
||||||
CurrentNumberOfUses = 0;
|
CurrentNumberOfUses = MaxNumberOfUses;
|
||||||
|
|
||||||
//Settings OwnedGameplayTags
|
//Settings OwnedGameplayTags
|
||||||
OwnedGameplayTags.AddTag(FCombatGameplayTags::Get().Item_Consumable_Potion);
|
OwnedGameplayTags.AddTag(FCombatGameplayTags::Get().Item_Consumable_Potion);
|
||||||
|
|
@ -17,7 +17,7 @@ ABaseConsumable::ABaseConsumable()
|
||||||
|
|
||||||
void ABaseConsumable::UseItem()
|
void ABaseConsumable::UseItem()
|
||||||
{
|
{
|
||||||
if(MaxNumberOfUses < CurrentNumberOfUses)
|
if(CurrentNumberOfUses <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ICombatInterface* ActionObjects = Cast<ICombatInterface>(GetOwner());
|
ICombatInterface* ActionObjects = Cast<ICombatInterface>(GetOwner());
|
||||||
|
|
@ -25,5 +25,12 @@ void ABaseConsumable::UseItem()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ActionObjects->PerformCustomAction(FCombatGameplayTags::Get().Character_Action_Attack_UseItem, FCombatGameplayTags::Get().Character_State_GeneralActionState, UseItemMontage);
|
ActionObjects->PerformCustomAction(FCombatGameplayTags::Get().Character_Action_Attack_UseItem, FCombatGameplayTags::Get().Character_State_GeneralActionState, UseItemMontage);
|
||||||
CurrentNumberOfUses++;
|
CurrentNumberOfUses--;
|
||||||
|
|
||||||
|
OnConsumeUpdated.Broadcast(GetNumberOfConsumable());
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 ABaseConsumable::GetNumberOfConsumable()
|
||||||
|
{
|
||||||
|
return FMath::Clamp(CurrentNumberOfUses, 0, CurrentNumberOfUses);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
DECLARE_MULTICAST_DELEGATE_OneParam(FOnConsumeUpdated, int32)
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class D1_API ABaseConsumable : public ABaseEquippable
|
class D1_API ABaseConsumable : public ABaseEquippable
|
||||||
{
|
{
|
||||||
|
|
@ -18,6 +20,11 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void UseItem() override;
|
virtual void UseItem() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
int32 GetNumberOfConsumable();
|
||||||
|
|
||||||
|
public: //Delegate
|
||||||
|
FOnConsumeUpdated OnConsumeUpdated;
|
||||||
private:
|
private:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
||||||
TObjectPtr<UAnimMontage> UseItemMontage;
|
TObjectPtr<UAnimMontage> UseItemMontage;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
#include "CombatPlayerCharacter.h"
|
#include "CombatPlayerCharacter.h"
|
||||||
|
|
||||||
|
#include "CombatPlayerController.h"
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
#include "Components/CapsuleComponent.h"
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "Components/InputComponent.h"
|
#include "Components/InputComponent.h"
|
||||||
|
|
@ -16,10 +18,14 @@
|
||||||
#include "Definitions/CombatGameplayTags.h"
|
#include "Definitions/CombatGameplayTags.h"
|
||||||
#include "Engine/DamageEvents.h"
|
#include "Engine/DamageEvents.h"
|
||||||
#include "NiagaraFunctionLibrary.h"
|
#include "NiagaraFunctionLibrary.h"
|
||||||
|
#include "Actor/BaseConsumable.h"
|
||||||
#include "DamageType/AttackDamageType.h"
|
#include "DamageType/AttackDamageType.h"
|
||||||
#include "Kismet/KismetSystemLibrary.h"
|
#include "Kismet/KismetSystemLibrary.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "UI/CombatHUD.h"
|
||||||
|
#include "UI/UI_MainHUD.h"
|
||||||
|
#include "UI/UI_PotionAmountText.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// ACombatCharacter
|
// ACombatCharacter
|
||||||
|
|
@ -131,6 +137,11 @@ void ACombatPlayerCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
SpawnItem->OnEquipped();
|
SpawnItem->OnEquipped();
|
||||||
EquippedItems.Add(SpawnItem);
|
EquippedItems.Add(SpawnItem);
|
||||||
|
if(ABaseConsumable* consumableItem = Cast<ABaseConsumable>(SpawnItem))
|
||||||
|
{
|
||||||
|
if(UUI_PotionAmountText* PotionAmountText = Cast<UUI_PotionAmountText>(PotionUI))
|
||||||
|
PotionAmountText->InitializePotionData(consumableItem); //TODO : [UMG] 관련 부분 구조 변경 필요
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -432,6 +443,11 @@ void ACombatPlayerCharacter::SetMovementSpeedMode(EMovementSpeedMode NewSpeedMod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACombatPlayerCharacter::SetPotionUI(UUserWidget* potionUI)
|
||||||
|
{
|
||||||
|
PotionUI = potionUI;
|
||||||
|
}
|
||||||
|
|
||||||
void ACombatPlayerCharacter::Move(const FInputActionValue& Value)
|
void ACombatPlayerCharacter::Move(const FInputActionValue& Value)
|
||||||
{
|
{
|
||||||
if(!bCanMove) //Value changes SetCanMove Func Call to Animnotify
|
if(!bCanMove) //Value changes SetCanMove Func Call to Animnotify
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ public:
|
||||||
public:
|
public:
|
||||||
void SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode);
|
void SetMovementSpeedMode(EMovementSpeedMode NewSpeedMode);
|
||||||
FORCEINLINE EMovementSpeedMode GetMovementSpeedMode() const { return MovementSpeedMode; }
|
FORCEINLINE EMovementSpeedMode GetMovementSpeedMode() const { return MovementSpeedMode; }
|
||||||
|
void SetPotionUI(UUserWidget* potionUI);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//Input Funcs
|
//Input Funcs
|
||||||
|
|
@ -245,7 +246,8 @@ public:
|
||||||
TObjectPtr<UAnimMontage> KnockdownBackMontage;
|
TObjectPtr<UAnimMontage> KnockdownBackMontage;
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage|Death", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage|Death", meta = (AllowPrivateAccess = "true"))
|
||||||
TArray<TObjectPtr<UAnimMontage>> DeathAnimations;
|
TArray<TObjectPtr<UAnimMontage>> DeathAnimations;
|
||||||
|
|
||||||
|
TObjectPtr<class UUserWidget> PotionUI;
|
||||||
|
|
||||||
private: //Timeline
|
private: //Timeline
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Timeline", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Timeline", meta = (AllowPrivateAccess = "true"))
|
||||||
|
|
|
||||||
|
|
@ -56,5 +56,4 @@ public:
|
||||||
virtual bool PerformCustomAction(FGameplayTag ActionTag, FGameplayTag StateTag, UAnimMontage* InMontage, float fMontagePlayRate = 1.f, bool bAutoReset = false);
|
virtual bool PerformCustomAction(FGameplayTag ActionTag, FGameplayTag StateTag, UAnimMontage* InMontage, float fMontagePlayRate = 1.f, bool bAutoReset = false);
|
||||||
UFUNCTION(Category="CombatActions")
|
UFUNCTION(Category="CombatActions")
|
||||||
virtual bool UseItemByTag(FGameplayTag ItemTag);
|
virtual bool UseItemByTag(FGameplayTag ItemTag);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,3 @@ void ACombatHUD::BeginPlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACombatHUD::UpdateHealthPotionAmount()
|
|
||||||
{
|
|
||||||
if(!IsValid(MainUI))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,8 @@ class D1_API ACombatHUD : public AHUD
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void UpdateHealthPotionAmount();
|
|
||||||
private:
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category = UI)
|
UPROPERTY(EditDefaultsOnly, Category = UI)
|
||||||
TSubclassOf<class UUI_MainHUD> MainUI;
|
TSubclassOf<class UUI_MainHUD> MainUI;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,6 @@ public:
|
||||||
TObjectPtr<class UUI_StatBar> HealthBar;
|
TObjectPtr<class UUI_StatBar> HealthBar;
|
||||||
UPROPERTY(meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
TObjectPtr<class UUI_StatBar> StaminaBar;
|
TObjectPtr<class UUI_StatBar> StaminaBar;
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<class UUI_PotionAmountText> HealthPotionAmountText;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "UI/UI_PotionAmountText.h"
|
||||||
|
|
||||||
|
#include "CombatPlayerCharacter.h"
|
||||||
|
#include "Actor/BaseConsumable.h"
|
||||||
|
#include "Components/TextBlock.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
void UUI_PotionAmountText::NativeConstruct()
|
||||||
|
{
|
||||||
|
Super::NativeConstruct();
|
||||||
|
|
||||||
|
ACombatPlayerCharacter* player = Cast<ACombatPlayerCharacter>(UGameplayStatics::GetPlayerController(this, 0)->GetPawn());
|
||||||
|
if(player) //TODO : [UMG] 관련 부분 구조 변경 필요
|
||||||
|
player->SetPotionUI(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UUI_PotionAmountText::InitializePotionData(ABaseConsumable* instance)
|
||||||
|
{
|
||||||
|
if(instance != nullptr)
|
||||||
|
{
|
||||||
|
PotionInstance = instance;
|
||||||
|
PotionInstance->OnConsumeUpdated.AddUObject(this, &UUI_PotionAmountText::SetPotionAmount);
|
||||||
|
SetPotionAmount(PotionInstance->GetNumberOfConsumable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UUI_PotionAmountText::SetPotionAmount(int32 amount)
|
||||||
|
{
|
||||||
|
FString potionStr = FString::Printf(TEXT("%d"), amount);
|
||||||
|
PotionAmountText->SetText(FText::FromString(potionStr));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
#include "UI_PotionAmountText.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ABaseConsumable;
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class D1_API UUI_PotionAmountText : public UUserWidget
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void NativeConstruct() override;
|
||||||
|
public:
|
||||||
|
void InitializePotionData(ABaseConsumable* instance);
|
||||||
|
//Delegate
|
||||||
|
void SetPotionAmount(int32 amount);
|
||||||
|
|
||||||
|
private:
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget, AllowPrivateAccess="true"))
|
||||||
|
TObjectPtr<class UTextBlock> PotionAmountText;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true"))
|
||||||
|
TObjectPtr<ABaseConsumable> PotionInstance;
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue