tested commit
This commit is contained in:
parent
1096753f5f
commit
36727688ac
BIN
hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset
(Stored with Git LFS)
BIN
hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset
(Stored with Git LFS)
BIN
hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
hwanyoung2/Content/Hwanyoung/Levels/Sprink_TEST.umap
(Stored with Git LFS)
BIN
hwanyoung2/Content/Hwanyoung/Levels/Sprink_TEST.umap
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -50,10 +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)
|
||||
// Filtering match the case.(Item can be bought, ItemValue is less and equal than honbaek amount and over than 0)
|
||||
TArray<FInventoryItem*> FilteredItemData = ItemData.FilterByPredicate([CurrentHonbaekAmount](const FInventoryItem* ItemDataRow)
|
||||
{
|
||||
return ItemDataRow->ItemValue > 0 && ItemDataRow->ItemValue <= CurrentHonbaekAmount;
|
||||
return !ItemDataRow->OnlyDropped && ItemDataRow->ItemValue > 0 && ItemDataRow->ItemValue <= CurrentHonbaekAmount;
|
||||
});
|
||||
|
||||
int maxLoopNum = FMath::Min(5, FilteredItemData.Num());
|
||||
@ -82,7 +82,7 @@ TMap<FInventoryItem, int> AHYShopAOE::GetTradableItemSets(int CurrentHonbaekAmou
|
||||
for (FInventoryItem TempItem : TempItems)
|
||||
{
|
||||
int MaxAmount = CurrentHonbaekAmount / TempItem.ItemValue;
|
||||
int Amount = FMath::Clamp(FMath::RandRange(0, MaxAmount), 1, MaxAmount);
|
||||
int Amount = FMath::Clamp(FMath::RandRange(0, MaxAmount), 1, 10);
|
||||
|
||||
Item.Add({ TempItem, Amount });
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "HYShopNPCActor.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "HYPlayerCharacController.h"
|
||||
|
||||
void AHYShopNPCActor::Interact_Implementation(APlayerController* Controller)
|
||||
{
|
||||
@ -17,4 +18,23 @@ void AHYShopNPCActor::Interact_Implementation(APlayerController* Controller)
|
||||
// ShopWidget = CreateWidget<UUserWidget>(Controller, ShopWidgetClass);
|
||||
// ShopWidget->AddToViewport();
|
||||
//}
|
||||
}
|
||||
|
||||
void AHYShopNPCActor::BuyTradableItem_Implementation(APlayerController* Controller, const FInventoryItem ItemToBuy, const int Amount)
|
||||
{
|
||||
int CurrentAmount = *TradableItems.Find(ItemToBuy);
|
||||
|
||||
TradableItems[ItemToBuy] = CurrentAmount - Amount;
|
||||
|
||||
AHYPlayerCharacController* PlayerController = Cast<AHYPlayerCharacController>(Controller);
|
||||
|
||||
if (PlayerController)
|
||||
{
|
||||
for (int i = 0; i < Amount; ++i)
|
||||
{
|
||||
PlayerController->AddItemToInventoryByID(ItemToBuy.ItemID);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
@ -15,8 +15,18 @@ class HWANYOUNG2_API AHYShopNPCActor : public AHYInteractableActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void Interact_Implementation(APlayerController* Controller);
|
||||
|
||||
// This Function will be called when player buy the item.
|
||||
// @param Controller: Player Controller, ItemToBuy: the item structure(Data) to buy, Amount: the number of the item.
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void BuyTradableItem(APlayerController* Controller, const FInventoryItem ItemToBuy, const int Amount);
|
||||
|
||||
// This Function will be called when player buy the item.
|
||||
// @param Controller: Player Controller, ItemToBuy: the item structure(Data) to buy, Amount: the number of the item.
|
||||
virtual void BuyTradableItem_Implementation(APlayerController* Controller, const FInventoryItem ItemToBuy, const int Amount);
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TMap<FInventoryItem, int> TradableItems;
|
||||
|
Loading…
x
Reference in New Issue
Block a user