40 lines
1006 B
C++
40 lines
1006 B
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#include "HYShopNPCActor.h"
|
|
#include "Blueprint/UserWidget.h"
|
|
#include "HYPlayerCharacController.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();
|
|
//}
|
|
}
|
|
|
|
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;
|
|
} |