Improved ShopAOE logic and made blueprint prototype
This commit is contained in:
BIN
hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset
(Stored with Git LFS)
Normal file
BIN
hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset
(Stored with Git LFS)
Normal file
BIN
hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset
(Stored with Git LFS)
Normal file
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.
@ -50,9 +50,10 @@ bool AHYShopAOE::RandomizeTradableItemSets(int CurrentHonbaekAmount)
|
|||||||
return false;
|
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)
|
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());
|
int maxLoopNum = FMath::Min(5, FilteredItemData.Num());
|
||||||
@ -73,16 +74,18 @@ bool AHYShopAOE::RandomizeTradableItemSets(int CurrentHonbaekAmount)
|
|||||||
return false;
|
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();
|
TArray<FInventoryItem> TempItems = FinalItemSets.Array();
|
||||||
|
|
||||||
for (FInventoryItem TempItem : TempItems)
|
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 });
|
Item.Add({ TempItem, Amount });
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return Item;
|
||||||
}
|
}
|
@ -31,7 +31,7 @@ public:
|
|||||||
// @param Item is NPC Actor's Array.
|
// @param Item is NPC Actor's Array.
|
||||||
// Make random amount of the tradable items set.
|
// Make random amount of the tradable items set.
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void GetTradableItemSets(TMap<FInventoryItem, int>& Item);
|
TMap<FInventoryItem, int> GetTradableItemSets(int CurrentHonbaekAmount);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Data")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Data")
|
||||||
|
@ -1,8 +1,20 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
#include "HYShopNPCActor.h"
|
#include "HYShopNPCActor.h"
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
|
||||||
void AHYShopNPCActor::Interact_Implementation(APlayerController* Controller)
|
void AHYShopNPCActor::Interact_Implementation(APlayerController* Controller)
|
||||||
{
|
{
|
||||||
|
Super::Interact_Implementation(Controller);
|
||||||
|
|
||||||
|
//if (ShopWidget)
|
||||||
|
//{
|
||||||
|
// ShopWidget->RemoveFromParent();
|
||||||
|
// ShopWidget = nullptr;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// ShopWidget = CreateWidget<UUserWidget>(Controller, ShopWidgetClass);
|
||||||
|
// ShopWidget->AddToViewport();
|
||||||
|
//}
|
||||||
}
|
}
|
@ -21,4 +21,9 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TMap<FInventoryItem, int> TradableItems;
|
TMap<FInventoryItem, int> TradableItems;
|
||||||
|
|
||||||
|
/*UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widget")
|
||||||
|
TSubclassOf<class UUserWidget> ShopWidgetClass;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Widget")
|
||||||
|
TObjectPtr<class UUserWidget> ShopWidget;*/
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user