tested commit
This commit is contained in:
@ -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;
|
||||
}
|
Reference in New Issue
Block a user