diff --git a/hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset b/hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset index d4e82df7..3a999b59 100644 --- a/hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset +++ b/hwanyoung2/Content/Hwanyoung/BP_ShopNPC.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4a8c86a2570fc1fbdbb6ff1b364063d1786d1f82b3045f626dd053d036a17261 -size 33246 +oid sha256:a639ad2cf0336103582b83ed15debf86b4e96cb0a209727019be58948569556c +size 58999 diff --git a/hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset b/hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset index f093cac3..89a4a6bd 100644 --- a/hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset +++ b/hwanyoung2/Content/Hwanyoung/Illusions/GeneralizedBlueprints/AOEBP/BP_ShopAOE.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:afcdd07406d027fbf41155e3dc37e53579251281becf10ef6fd584a06cfe4713 -size 145464 +oid sha256:911edfe10257ea0ad8aee77fa92e95361624c9b969b400cf16fed52070ef2484 +size 124050 diff --git a/hwanyoung2/Content/Hwanyoung/Levels/Sprink_TEST.umap b/hwanyoung2/Content/Hwanyoung/Levels/Sprink_TEST.umap index 7ac79562..f717d1f2 100644 --- a/hwanyoung2/Content/Hwanyoung/Levels/Sprink_TEST.umap +++ b/hwanyoung2/Content/Hwanyoung/Levels/Sprink_TEST.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ae1110cb70738ceecf2981820c2cee426e72c426ec04c205dd47ade128637fd -size 21818428 +oid sha256:8adfca0a3dda5c912a27a7bb3c817d9c7d5a2f5e3a5aef0769c70e564df9b621 +size 21818877 diff --git a/hwanyoung2/Intermediate/Build/SourceFileCache.bin b/hwanyoung2/Intermediate/Build/SourceFileCache.bin index 206bf341..f6f0412c 100644 Binary files a/hwanyoung2/Intermediate/Build/SourceFileCache.bin and b/hwanyoung2/Intermediate/Build/SourceFileCache.bin differ diff --git a/hwanyoung2/Intermediate/ReimportCache/3688439234.bin b/hwanyoung2/Intermediate/ReimportCache/3688439234.bin index 47317651..4f7c257d 100644 Binary files a/hwanyoung2/Intermediate/ReimportCache/3688439234.bin and b/hwanyoung2/Intermediate/ReimportCache/3688439234.bin differ diff --git a/hwanyoung2/Source/hwanyoung2/HYShopAOE.cpp b/hwanyoung2/Source/hwanyoung2/HYShopAOE.cpp index f386c539..82fc5624 100644 --- a/hwanyoung2/Source/hwanyoung2/HYShopAOE.cpp +++ b/hwanyoung2/Source/hwanyoung2/HYShopAOE.cpp @@ -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 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 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 }); } diff --git a/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.cpp b/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.cpp index 5b814744..062cf147 100644 --- a/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.cpp +++ b/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.cpp @@ -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(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(Controller); + + if (PlayerController) + { + for (int i = 0; i < Amount; ++i) + { + PlayerController->AddItemToInventoryByID(ItemToBuy.ItemID); + } + } + + return; } \ No newline at end of file diff --git a/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.h b/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.h index 809e16e1..f30172b2 100644 --- a/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.h +++ b/hwanyoung2/Source/hwanyoung2/HYShopNPCActor.h @@ -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 TradableItems;