Improved ShopAOE logic and made blueprint prototype

This commit is contained in:
7heIVIaze
2025-06-02 22:06:16 +09:00
parent 051c65fde0
commit 1096753f5f
7 changed files with 33 additions and 7 deletions

BIN
hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -50,9 +50,10 @@ bool AHYShopAOE::RandomizeTradableItemSets(int CurrentHonbaekAmount)
return false;
}
// Filtering match the case.(ItemValue is less and equal than honbaek amount and over than 0)
TArray<FInventoryItem*> FilteredItemData = ItemData.FilterByPredicate([CurrentHonbaekAmount](const FInventoryItem* ItemDataRow)
{
return ItemDataRow->ItemValue <= CurrentHonbaekAmount;
return ItemDataRow->ItemValue > 0 && ItemDataRow->ItemValue <= CurrentHonbaekAmount;
});
int maxLoopNum = FMath::Min(5, FilteredItemData.Num());
@ -73,16 +74,18 @@ bool AHYShopAOE::RandomizeTradableItemSets(int CurrentHonbaekAmount)
return false;
}
void AHYShopAOE::GetTradableItemSets(TMap<FInventoryItem, int>& Item)
TMap<FInventoryItem, int> AHYShopAOE::GetTradableItemSets(int CurrentHonbaekAmount)
{
TMap<FInventoryItem, int> Item;
TArray<FInventoryItem> TempItems = FinalItemSets.Array();
for (FInventoryItem TempItem : TempItems)
{
int Amount = FMath::RandRange(0, 100);
int MaxAmount = CurrentHonbaekAmount / TempItem.ItemValue;
int Amount = FMath::Clamp(FMath::RandRange(0, MaxAmount), 1, MaxAmount);
Item.Add({ TempItem, Amount });
}
return;
return Item;
}

View File

@ -31,7 +31,7 @@ public:
// @param Item is NPC Actor's Array.
// Make random amount of the tradable items set.
UFUNCTION(BlueprintCallable)
void GetTradableItemSets(TMap<FInventoryItem, int>& Item);
TMap<FInventoryItem, int> GetTradableItemSets(int CurrentHonbaekAmount);
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Data")

View File

@ -1,8 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYShopNPCActor.h"
#include "Blueprint/UserWidget.h"
void AHYShopNPCActor::Interact_Implementation(APlayerController* Controller)
{
Super::Interact_Implementation(Controller);
//if (ShopWidget)
//{
// ShopWidget->RemoveFromParent();
// ShopWidget = nullptr;
//}
//else
//{
// ShopWidget = CreateWidget<UUserWidget>(Controller, ShopWidgetClass);
// ShopWidget->AddToViewport();
//}
}

View File

@ -21,4 +21,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TMap<FInventoryItem, int> TradableItems;
/*UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widget")
TSubclassOf<class UUserWidget> ShopWidgetClass;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Widget")
TObjectPtr<class UUserWidget> ShopWidget;*/
};