Updated InventoryComponent and Shop
Fixed InventoryComponent to now work with singular items so you can purchase items from the shop!
This commit is contained in:
parent
0c0876770b
commit
900feee5a9
BIN
Content/Blueprints/BP_HealingJellyItem.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/BP_HealingJellyItem.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/BP_Interaction.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/BP_Interaction.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/BP_MyTempCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/BP_MyTempCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Items/BP_HealingJelly.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/BP_HealingJelly.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
Binary file not shown.
@ -33,22 +33,24 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
|
|||||||
//if the items is over the maxinventoryslots then it wont add the item
|
//if the items is over the maxinventoryslots then it wont add the item
|
||||||
if (Items.Num() >= MaxItemSlots || !BaseItem)
|
if (Items.Num() >= MaxItemSlots || !BaseItem)
|
||||||
{
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("THERE ARE MORE ITEMS THAN THE INVENTORY SLOTS"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BaseItem->StoredItems = this;
|
BaseItem->StoredItems = this;
|
||||||
BaseItem->World = GetWorld();
|
BaseItem->World = GetWorld();
|
||||||
Items.Add(BaseItem);
|
Items.Add(BaseItem);
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("ITEM HAS BEEN ADDED"));
|
||||||
//Update UI
|
//Update UI
|
||||||
OnInventoryUpdated.Broadcast();
|
OnInventoryUpdated.Broadcast();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UInventoryComponent::Remove(UBaseItem* BaseItem)
|
bool UInventoryComponent::Remove(class UBaseItem* BaseItem)
|
||||||
{
|
{
|
||||||
if(BaseItem)
|
if(BaseItem)
|
||||||
{
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("ItEM HAS BEEN REMOVED"));
|
||||||
BaseItem->StoredItems = nullptr;
|
BaseItem->StoredItems = nullptr;
|
||||||
BaseItem->World = nullptr;
|
BaseItem->World = nullptr;
|
||||||
Items.RemoveSingle(BaseItem);
|
Items.RemoveSingle(BaseItem);
|
||||||
@ -58,3 +60,8 @@ bool UInventoryComponent::Remove(UBaseItem* BaseItem)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UBaseItem* UInventoryComponent::GetItem(int32 Index)
|
||||||
|
{
|
||||||
|
return Items[Index];
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ public:
|
|||||||
UPROPERTY(BlueprintAssignable, Category= "Inventory")
|
UPROPERTY(BlueprintAssignable, Category= "Inventory")
|
||||||
FOnInventoryUpdated OnInventoryUpdated; //This is our delegate
|
FOnInventoryUpdated OnInventoryUpdated; //This is our delegate
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Items")
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category= "Items")
|
||||||
TArray<class UBaseItem*> Items; // The items currently in the inventory
|
TArray<class UBaseItem*> Items; // The items currently in the inventory
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category= "Inventory")
|
||||||
|
class UBaseItem* GetItem(int32 Index);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// 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 "TempCharacter.h"
|
#include "TempCharacter.h"
|
||||||
|
|
||||||
|
#include "IDetailTreeNode.h"
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
||||||
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
||||||
@ -82,9 +84,11 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
if(GoldBalance >= 100)
|
if(GoldBalance >= 100)
|
||||||
{
|
{
|
||||||
GoldBalance -= 100;
|
GoldBalance -= 100;
|
||||||
|
Inventory->AddItem(OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0));
|
||||||
|
//Inventory->AddItem(Cast<UBaseItem>(OutHit.GetActor()));
|
||||||
|
//Inventory->AddItem(OutHit.GetActor()->Get("HealingJelly"));
|
||||||
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
||||||
// UInventoryComponent* tempInventory = GetOwner()->FindComponentByClass<UInventoryComponent>();
|
|
||||||
// tempInventory->AddItem(ItemToBuy);
|
|
||||||
}
|
}
|
||||||
if(GoldBalance <= 0)
|
if(GoldBalance <= 0)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,6 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category= "Items")
|
UFUNCTION(BlueprintCallable, Category= "Items")
|
||||||
void BuyItem(class UBaseItem* BuyItem);
|
void BuyItem(class UBaseItem* BuyItem);
|
||||||
|
|
||||||
// UPROPERTY(EditAnywhere, Category= "Items")
|
UPROPERTY(EditAnywhere, Category= "Items")
|
||||||
// UBaseItem ItemToBuy;
|
UBaseItem* ItemToBuy;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user