Merge branch 'merchant-system' into Turn-Base-System

# Conflicts:
#	Content/Blueprints/WBP_PlayerInventory.uasset
#	Content/Merchant/BP_MerchantGameMode.uasset
This commit is contained in:
Philip W 2022-11-15 03:28:55 +00:00
commit 9b9cc6f02b
18 changed files with 134 additions and 21 deletions

BIN
Content/Blueprints/BP_HealingJellyItem.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/BP_Interaction.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Content/Blueprints/Items/BP_BuffJelly.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/WBP_ItemDisplay.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Content/Blueprints/WBP_Shop.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Levels/MerchantPrototype.umap (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

View File

@ -3,8 +3,7 @@
#include "InventoryComponent.h" #include "InventoryComponent.h"
#include "Items/BaseItem.h" #include "Items/BaseItem.h"
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
// Sets default values for this component's properties // Sets default values for this component's properties
@ -36,7 +35,6 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
{ {
return false; return false;
} }
BaseItem->StoredItems = this; BaseItem->StoredItems = this;
BaseItem->World = GetWorld(); BaseItem->World = GetWorld();
Items.Add(BaseItem); Items.Add(BaseItem);

View File

@ -45,16 +45,14 @@ public:
//The cost of the item //The cost of the item
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item")
int32 ItemCostPrice; int ItemCostPrice;
//ADD A HEALING ITEM VALUE?
//reference to the UInventoryComponent script //reference to the UInventoryComponent script
UPROPERTY() UPROPERTY()
class UInventoryComponent* StoredItems; class UInventoryComponent* StoredItems;
//The buy class to purchase the item //The buy class to purchase the item
virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER virtual void Buy(class ATempCharacter* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER
//The use Item class to use the item in the player Inventory //The use Item class to use the item in the player Inventory
virtual void Use(class ATempCharacter* Character); virtual void Use(class ATempCharacter* Character);
@ -62,4 +60,7 @@ public:
//This is the same as the use item class but its in BP instead //This is the same as the use item class but its in BP instead
UFUNCTION(BlueprintImplementableEvent) UFUNCTION(BlueprintImplementableEvent)
void OnUse(class ATempCharacter* Character); void OnUse(class ATempCharacter* Character);
UFUNCTION(BlueprintImplementableEvent)
void OnBuy(class ATempCharacter* PurchaseItem);
}; };

View File

@ -3,13 +3,39 @@
#include "EatableItems.h" #include "EatableItems.h"
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
UEatableItems::UEatableItems()
{
}
void UEatableItems::Use(ATempCharacter* Character) void UEatableItems::Use(ATempCharacter* Character)
{ {
if(Character) if(Character)
{ {
Character->Health += 10; Character->Health += 10;
if(StoredItems)
{
StoredItems->Remove(this);
}
}
}
void UEatableItems::Buy(ATempCharacter* PurchaseItem)
{
if(PurchaseItem)
{
if(PurchaseItem->GoldBalance <= 0)
{
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
}
else
{
PurchaseItem->GoldBalance -= ItemCostPrice;
}
} }
} }

View File

@ -13,8 +13,11 @@ UCLASS()
class THE_TWILIGHT_ABYSS_API UEatableItems : public UBaseItem class THE_TWILIGHT_ABYSS_API UEatableItems : public UBaseItem
{ {
GENERATED_BODY() GENERATED_BODY()
UEatableItems();
protected: protected:
virtual void Use(class ATempCharacter* Character) override; virtual void Use(class ATempCharacter* Character) override;
virtual void Buy(ATempCharacter* PurchaseItem) override;
}; };

View File

@ -0,0 +1,19 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ShopItems.h"
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
UShopItems::UShopItems()
{
}
// void UShopItems::Buy(ATempCharacter* PurchaseItem)
// {
// if(PurchaseItem)
// {
// PurchaseItem->GoldBalance -= ItemCostPrice;
// }
// }

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BaseItem.h"
#include "ShopItems.generated.h"
/**
*
*/
UCLASS()
class THE_TWILIGHT_ABYSS_API UShopItems : public UBaseItem
{
GENERATED_BODY()
UShopItems();
// protected:
// virtual void Buy(ATempCharacter* PurchaseItem) override;
};

View File

@ -77,6 +77,20 @@ void ATempCharacter::LineTraceLogic()
{ {
return; return;
} }
if(OutHit.GetActor()->ActorHasTag("HealingJelly"))
{
if(GoldBalance >= 100)
{
GoldBalance -= 100;
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
// UInventoryComponent* tempInventory = GetOwner()->FindComponentByClass<UInventoryComponent>();
// tempInventory->AddItem(ItemToBuy);
}
if(GoldBalance <= 0)
{
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
}
}
if (AInteraction* MyInteractable = Cast<AInteraction>(OutHit.GetActor())) if (AInteraction* MyInteractable = Cast<AInteraction>(OutHit.GetActor()))
{ {
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f);
@ -94,3 +108,13 @@ void ATempCharacter::UseItem(class UBaseItem* Item)
Item->OnUse(this); //Blueprint Version Item->OnUse(this); //Blueprint Version
} }
} }
void ATempCharacter::BuyItem(UBaseItem* BuyItem)
{
if(BuyItem)
{
BuyItem->Buy(this);
BuyItem->OnBuy(this);
}
}

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
#include "TempCharacter.generated.h" #include "TempCharacter.generated.h"
UCLASS() UCLASS()
@ -43,7 +44,16 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health")
float Health; float Health;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Gold")
int GoldBalance;
//Using the item in the inventory //Using the item in the inventory
UFUNCTION(BlueprintCallable, Category= "Items") UFUNCTION(BlueprintCallable, Category= "Items")
void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class
UFUNCTION(BlueprintCallable, Category= "Items")
void BuyItem(class UBaseItem* BuyItem);
// UPROPERTY(EditAnywhere, Category= "Items")
// UBaseItem ItemToBuy;
}; };